图片删除优化;基建布局识别
This commit is contained in:
parent
54c3ec255d
commit
8f6e365feb
1 changed files with 33 additions and 6 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue