Skip to content

Commit

Permalink
feat: Taiwan #1
Browse files Browse the repository at this point in the history
  • Loading branch information
howardt12345 committed Sep 19, 2024
1 parent 3a2ceff commit 0e380ea
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 0 deletions.
20 changes: 20 additions & 0 deletions resources/reacts/tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@
"嘉義",
"美麗島"
]
},
{
"match_whole_word": true,
"keywords": [
"(?:台|臺)灣(?:[\\s-]*(?:is|be|are|=|:|\\bis\\b|\\bare\\b))?[\\s-]*(?:(?:number|#|n[o°]|n°)\\s*(?:1|one|won|一|壹|①)|(?:first|1st|best|top|greatest|最(?:棒|強|好)|第一))",
"Taiwan(?:[\\s-]*(?:is|be|are|=|:|\\bis\\b|\\bare\\b))?[\\s-]*(?:(?:number|#|n[o°]|n°)\\s*(?:1|one|won|①)|(?:first|1st|best|top|greatest))",
"Taiwán(?:[\\s-]*(?:is|be|are|=|:|\\bis\\b|\\bare\\b))?[\\s-]*(?:(?:number|#|n[o°]|n°)\\s*(?:1|one|won|①)|(?:first|1st|best|top|greatest))"
],
"criteria_link": "tw_no_1"
}
],
"possible_reactions": [
Expand Down Expand Up @@ -85,6 +94,17 @@
"<:PineappleCake:1156373382565212323>",
"<:StinkyTofu:1156373383643152445>"
]
},
{
"condition": "tw_no_1",
"chance": 1,
"content": [
"<:tw_heart:1133045893227102299>",
"#️⃣",
"1️⃣"
],
"react_with_all": true,
"react_in_order": true
}
],
"possible_replies": [
Expand Down
77 changes: 77 additions & 0 deletions tests/test_reacts/test_reacts_tw.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,53 @@
"美麗島",
)

TEST_CASES_TW_NO_1_TRUE = [
"Taiwan #1",
"Taiwan number 1",
"Taiwan is number one",
"Taiwan Number One",
"Taiwan is #1",
"Taiwan No. 1",
"Taiwan n° 1",
"Taiwán número uno",
"臺灣第一",
"台灣最棒",
"Taiwan is the best",
"Taiwan = first",
"Taiwan: top",
"Taiwan are greatest",
"Taiwan - number 1",
"Taiwan # 1",
"臺灣第一名",
"台灣最強",
"台灣是第一",
"Taiwan 第一",
"臺灣 number one",
"Taiwan won",
"Taiwan ①",
"Taiwan 壹",
"TAIWAN NUMBER ONE",
"taiwan #1",
"I believe Taiwan is truly number one in Asia",
"Taiwan, often called Formosa, is number 1 in my heart"
]

TEST_CASES_TW_NO_1_FALSE = [
"Thailand #1",
"Taiwan is great",
"Number 1 Taiwan",
"Taiwan number 2",
"Taiwan was number 1",
"Taiwanese number 1",
"Taiwan numbers",
"Taiwan",
"#1",
"Number one",
"Taiwan #",
"Taiwan number"
]


ALL_TEST_CASES = TEST_CASE_EN + TEST_CASE_TW


Expand Down Expand Up @@ -100,3 +147,33 @@ def test_react_tw_regex_no_match(test_str: str):
"""Tests that these strings return FALSE."""
# * surrounded by text
assert not check_resource_match(f"a{test_str}b", resource_name='tw')

@pytest.mark.parametrize(
"test_str",
TEST_CASES_TW_NO_1_TRUE,
)
def test_react_tw_no_1_regex_yes_match(test_str: str):
"""Tests that these strings return TRUE."""
# * isolated string
assert check_resource_match(test_str, resource_name='tw')
# * surrounded by spaces
assert check_resource_match(f" {test_str} ", resource_name='tw')
# * to lowercase
assert check_resource_match(test_str.lower(), resource_name='tw')
# * to title case
assert check_resource_match(test_str.title(), resource_name='tw')

@pytest.mark.parametrize(
"test_str",
TEST_CASES_TW_NO_1_FALSE,
)
def test_react_tw_no_1_regex_no_match(test_str: str):
"""Tests that these strings return FALSE."""
# * isolated string
assert not check_resource_match(test_str, resource_name='tw')
# * surrounded by spaces
assert not check_resource_match(f" {test_str} ", resource_name='tw')
# * to lowercase
assert not check_resource_match(test_str.lower(), resource_name='tw')
# * to title case
assert not check_resource_match(test_str.title(), resource_name='tw')

0 comments on commit 0e380ea

Please sign in to comment.