2026-01-20 10:13:51 +08:00
|
|
|
'''
|
|
|
|
|
读取反应定义文件列表和内容
|
|
|
|
|
'''
|
2026-01-02 21:47:28 +08:00
|
|
|
import json
|
|
|
|
|
|
|
|
|
|
def readReactionList() -> dict:
|
2026-01-05 13:07:53 +08:00
|
|
|
with open("resources/reactions/list.json", "r", encoding="utf8") as f:
|
2026-01-02 21:47:28 +08:00
|
|
|
text = f.read()
|
|
|
|
|
result = json.loads(text)
|
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
2026-01-20 12:15:48 +08:00
|
|
|
def readMatchList() -> dict:
|
|
|
|
|
with open("resources/reactions/match.json", "r", encoding="utf8") as f:
|
|
|
|
|
text = f.read()
|
|
|
|
|
result = json.loads(text)
|
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
2026-01-20 09:34:24 +08:00
|
|
|
reaction_list = readReactionList()
|
2026-01-20 12:15:48 +08:00
|
|
|
match_list = readMatchList()
|
2026-01-20 09:34:24 +08:00
|
|
|
|
2026-01-02 21:47:28 +08:00
|
|
|
def readReaction(id: str):
|
2026-01-20 09:34:24 +08:00
|
|
|
path = reaction_list.get(id, -1)
|
2026-01-05 09:30:43 +08:00
|
|
|
if (path == -1):
|
|
|
|
|
return {"message": f"No Reaction {id}"}
|
2026-01-05 13:07:53 +08:00
|
|
|
with open(f"resources/reactions/{path}.json", "r", encoding="utf8") as f:
|
2026-01-05 09:30:43 +08:00
|
|
|
text = f.read()
|
|
|
|
|
result = json.loads(text)
|
|
|
|
|
|
2026-01-20 12:15:48 +08:00
|
|
|
return {"message": "OK", "content": result}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def selectReaction(id: str):
|
|
|
|
|
matter_id = match_list.get(id, -1)
|
2026-01-20 12:18:30 +08:00
|
|
|
if matter_id == -1:
|
2026-01-20 12:15:48 +08:00
|
|
|
return {"message": f"No Matter {id}"}
|
|
|
|
|
|
|
|
|
|
return matter_id
|