上传的不是副手简报时删除图片

This commit is contained in:
zhbaor 2023-08-14 09:44:40 +08:00
parent 161a689fb4
commit c94f9f0605

View file

@ -24,9 +24,11 @@ class RIICReportAnalysis:
None, functools.partial(rapid_ocr, img_path) None, functools.partial(rapid_ocr, img_path)
) )
if not "副手简报" in [i[1] for i in result]: if not "副手简报" in [i[1] for i in result]:
os.remove(img_path)
return return
lmb_height = 0 lmb_height = 0
lmb_numers = [] lmb_list = []
date_list = [] date_list = []
exp_list = [] exp_list = []
gold_list = [] gold_list = []
@ -46,9 +48,9 @@ class RIICReportAnalysis:
continue continue
if lmb_height - 20 < i[0][0][1] < lmb_height + 20: if lmb_height - 20 < i[0][0][1] < lmb_height + 20:
if m := re.search(r"([0-9]+)", i[1]): if m := re.search(r"([0-9]+)", i[1]):
lmb_numers.append([int(i[0][0][0]), m.group(1)]) lmb_list.append([int(i[0][0][0]), m.group(1)])
lmb_numers.sort(key=lambda x: x[0]) lmb_list.sort(key=lambda x: x[0])
gold_list.sort(key=lambda x: x[0]) gold_list.sort(key=lambda x: x[0])
exp_list.sort(key=lambda x: x[0]) exp_list.sort(key=lambda x: x[0])
date_list.sort(key=lambda x: x[0]) date_list.sort(key=lambda x: x[0])
@ -57,10 +59,10 @@ class RIICReportAnalysis:
for i in range(len(date_list)): for i in range(len(date_list)):
output += f"{date_list[i][1]}\n" output += f"{date_list[i][1]}\n"
output += f"💵 {lmb_numers[2 * i][1]}订单({lmb_numers[2 * i + 1][1]})\n" output += f"💵 {lmb_list[2 * i][1]}订单({lmb_list[2 * i + 1][1]})\n"
output += f"🧈 {gold_list[i][1]}赤金\n" output += f"🧈 {gold_list[i][1]}赤金\n"
output += f"📼 {exp_list[i][1]}经验\n\n" output += f"📼 {exp_list[i][1]}经验\n\n"
await chain.onebot_reply(Text(output.strip())) await chain.onebot_reply(Text(output.strip()))
await loop.run_in_executor(None, functools.partial(os.remove, img_path)) os.remove(img_path)