From b81b77c204174f05ac07087a1836891c01a9767f Mon Sep 17 00:00:00 2001 From: Tiger Date: Tue, 20 Jan 2026 12:15:48 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=80=83=E8=99=91=E5=88=B0=E5=90=8C?= =?UTF-8?q?=E6=A0=B7=E7=89=A9=E8=B4=A8=E5=A4=9A=E7=A7=8D=E5=8F=8D=E5=BA=94?= =?UTF-8?q?=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 +++- app/utils/matters.py | 16 ++-------------- app/utils/reactions.py | 18 +++++++++++++++++- resources/reactions/match.json | 4 +++- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 9fd23ee..ec3764e 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,9 @@ backend/ ```json { - "Carbon-Oxygen-": "CarbonDioxide", + "Carbon-Oxygen-": [ + "CarbonDioxide" + ], "...": "..." } ``` diff --git a/app/utils/matters.py b/app/utils/matters.py index 6bcb2c0..f03b810 100644 --- a/app/utils/matters.py +++ b/app/utils/matters.py @@ -10,15 +10,10 @@ def readMatterList() -> dict: return result -def readMatchList() -> dict: - with open("resources/reactions/match.json", "r", encoding="utf8") as f: - text = f.read() - result = json.loads(text) - - return result + matter_list = readMatterList() -match_list = readMatchList() + def readMatter(id: str): path = matter_list.get(id, -1) @@ -29,10 +24,3 @@ def readMatter(id: str): result = json.loads(text) return {"message": "OK", "content": result} - -def selectMatter(id: str): - matter_id = match_list.get(id, -1) - if (matter_id == -1): - return {"message": f"No Matter {id}"} - - return readMatter(matter_id) \ No newline at end of file diff --git a/app/utils/reactions.py b/app/utils/reactions.py index c24e684..269e80b 100644 --- a/app/utils/reactions.py +++ b/app/utils/reactions.py @@ -10,7 +10,15 @@ def readReactionList() -> dict: return result +def readMatchList() -> dict: + with open("resources/reactions/match.json", "r", encoding="utf8") as f: + text = f.read() + result = json.loads(text) + + return result + reaction_list = readReactionList() +match_list = readMatchList() def readReaction(id: str): path = reaction_list.get(id, -1) @@ -20,4 +28,12 @@ def readReaction(id: str): text = f.read() result = json.loads(text) - return {"message": "OK", "content": result} \ No newline at end of file + return {"message": "OK", "content": result} + + +def selectReaction(id: str): + matter_id = match_list.get(id, -1) + if (matter_id == -1): + return {"message": f"No Matter {id}"} + + return matter_id \ No newline at end of file diff --git a/resources/reactions/match.json b/resources/reactions/match.json index 9bc2f02..0e6c9e9 100644 --- a/resources/reactions/match.json +++ b/resources/reactions/match.json @@ -1,3 +1,5 @@ { - "Carbon-Oxygen-": "CarbonDioxide" + "Carbon-Oxygen-": [ + "CarbonDioxide" + ] } \ No newline at end of file