mirror of
https://github.com/TriM-Organization/LiteyukiBot-TriM.git
synced 2026-06-14 00:22:26 +00:00
@@ -15,19 +15,19 @@ from pypinyin import Style, pinyin
|
||||
resource_dir = Path(__file__).parent / "resources"
|
||||
fonts_dir = resource_dir / "fonts"
|
||||
data_dir = resource_dir / "data"
|
||||
idiom_path = data_dir / "idioms.txt"
|
||||
answer_path = data_dir / "answers.json"
|
||||
answer_hard_path = data_dir / "answers_hard.json"
|
||||
handle_idiom_path = data_dir / "idioms.json"
|
||||
handle_answer_path = data_dir / "answers.json"
|
||||
handle_answer_hard_path = data_dir / "answers_hard.json"
|
||||
|
||||
|
||||
LEGAL_PHRASES = [
|
||||
idiom.strip() for idiom in idiom_path.open("r", encoding="utf-8").readlines()
|
||||
]
|
||||
ANSWER_PHRASES: List[Dict[str, str]] = json.load(
|
||||
answer_path.open("r", encoding="utf-8")
|
||||
HANDLE_LEGAL_PHRASES: List[str] = json.load(
|
||||
handle_idiom_path.open("r", encoding="utf-8")
|
||||
)
|
||||
HARD_ANSWER_PHRASES: List[Dict[str, str]] = json.load(
|
||||
answer_hard_path.open("r", encoding="utf-8")
|
||||
HANDLE_ANSWER_PHRASES: List[Dict[str, str]] = json.load(
|
||||
handle_answer_path.open("r", encoding="utf-8")
|
||||
)
|
||||
HANDLE_HARD_ANSWER_PHRASES: List[Dict[str, str]] = json.load(
|
||||
handle_answer_hard_path.open("r", encoding="utf-8")
|
||||
)
|
||||
|
||||
# class LegalPhrasesModifiedHandler(FileSystemEventHandler):
|
||||
@@ -59,11 +59,13 @@ HARD_ANSWER_PHRASES: List[Dict[str, str]] = json.load(
|
||||
|
||||
|
||||
def legal_idiom(word: str) -> bool:
|
||||
return word in LEGAL_PHRASES
|
||||
return word in HANDLE_LEGAL_PHRASES
|
||||
|
||||
|
||||
def random_idiom(is_hard: bool = False) -> Tuple[str, str]:
|
||||
answer = random.choice(HARD_ANSWER_PHRASES if is_hard else ANSWER_PHRASES)
|
||||
answer = random.choice(
|
||||
HANDLE_HARD_ANSWER_PHRASES if is_hard else HANDLE_ANSWER_PHRASES
|
||||
)
|
||||
return answer["word"], answer["explanation"]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user