From 8f6e365febb4d0895948885dca186eac0f2ae118 Mon Sep 17 00:00:00 2001 From: Zhao Zuohong Date: Mon, 14 Aug 2023 11:01:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BE=E7=89=87=E5=88=A0=E9=99=A4=E4=BC=98?= =?UTF-8?q?=E5=8C=96=EF=BC=9B=E5=9F=BA=E5=BB=BA=E5=B8=83=E5=B1=80=E8=AF=86?= =?UTF-8?q?=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/riic_report_analysis.py | 39 ++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/apps/riic_report_analysis.py b/apps/riic_report_analysis.py index b949ba0..8bee06a 100644 --- a/apps/riic_report_analysis.py +++ b/apps/riic_report_analysis.py @@ -4,6 +4,7 @@ import os import asyncio import functools import re +from typing import Dict rapid_ocr = None @@ -12,19 +13,47 @@ if not rapid_ocr: class RIICReportAnalysis: - async def group_message(self, chain: MessageChain): + async def group_message(self, chain: MessageChain, raw_event: Dict): if len(chain) != 1 or len(chain.images) != 1: return img_seg: Image = chain[0] img_path = await img_seg.download() - loop = asyncio.get_running_loop() - result, elapse = await loop.run_in_executor( None, functools.partial(rapid_ocr, img_path) ) + os.remove(img_path) if not result or not "副手简报" in [i[1] for i in result]: - os.remove(img_path) + return + + card = raw_event["sender"]["card"] + + err_msg = "请修改群昵称(群名片),标注基建布局。若使用2电站布局,请额外标注贸易站等级。\n" + err_msg += "如:\n" + err_msg += "EE0000 252 11贸\n" + err_msg += "教捐 252(33贸易站)\n" + err_msg += "千梵 243烟火 单推狮蝎\n" + err_msg += "琉璃 243-153" + + if not card: + await chain.onebot_reply(Text(err_msg)) + return + elif "153" in card or "243" in card: + await chain.onebot_reply(Text("3电站,龙舌兰")) + elif "252" in card: + if m := re.search(r"([1-3][1-3])贸", card): + await chain.onebot_reply(Text(f"252,贸易站等级是{m.group(1)}")) + else: + await chain.onebot_reply(Text(err_msg)) + return + elif "342" in card: + if m := re.search(r"([1-3][1-3][1-3])贸", card): + await chain.onebot_reply(Text(f"342,贸易站等级是{m.group(1)}")) + else: + await chain.onebot_reply(Text(err_msg)) + return + else: + await chain.onebot_reply(Text(err_msg)) return lmb_height = 0 @@ -73,5 +102,3 @@ class RIICReportAnalysis: err_msg += f"gold_list = {gold_list}\n" err_msg += f"exp_list = {exp_list}" await chain.onebot_reply(Text(err_msg), At("1040110848")) - - os.remove(img_path)