From 854c97976aa78f14a233cbd980f53fb05b85157f Mon Sep 17 00:00:00 2001 From: Zhao Zuohong Date: Thu, 7 Sep 2023 10:21:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=88=E5=B9=B6=E8=BD=AC=E5=8F=91=E5=9F=BA?= =?UTF-8?q?=E6=8A=A5=E5=88=86=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/riic_report_analysis.py | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/apps/riic_report_analysis.py b/apps/riic_report_analysis.py index 587510b..e43becd 100644 --- a/apps/riic_report_analysis.py +++ b/apps/riic_report_analysis.py @@ -1,6 +1,7 @@ from pepperbot.core.message.chain import MessageChain, Image, Text, At from pepperbot.extensions.command import as_command, CLIArgument from pepperbot.extensions.command.sender import CommandSender +from pepperbot.adapters.universal.api import UniversalGroupBot from rapidocr_onnxruntime import RapidOCR import os import asyncio @@ -16,7 +17,12 @@ if not rapid_ocr: class RIICReportAnalysis: - async def group_message(self, chain: MessageChain, raw_event: Dict): + async def group_message( + self, + chain: MessageChain, + raw_event: Dict, + bot: UniversalGroupBot, + ): if len(chain) != 1 or len(chain.images) != 1: return img_seg: Image = chain[0] @@ -102,6 +108,7 @@ class RIICReportAnalysis: gold_list.sort(key=lambda x: x[0]) exp_list.sort(key=lambda x: x[0]) + output_list = [] output = "" lmb_avg = 0 order_avg = 0 @@ -124,6 +131,9 @@ class RIICReportAnalysis: output += f"🧈 {gold_list[i][1]}赤金\n" output += f"📼 {exp_list[i][1]}经验\n\n" + output_list.append(output.strip()) + output = "" + lmb_avg /= len(date_list) order_avg /= len(date_list) gold_avg /= len(date_list) @@ -199,7 +209,22 @@ class RIICReportAnalysis: output += f"{kaltsit:.0f}凯 = 贸 + 金 + 书向上取整到万\n" output += f"{stupid:.1f}友 = 贸 + 书" - await chain.onebot_reply(Text(output.strip())) + output_list.append(output.strip()) + + await bot.arbitrary.onebot.send_group_forward_msg( + raw_event["group_id"], + [ + { + "type": "node", + "data": { + "name": card, + "uin": raw_event["user_id"], + "content": [{"type": "text", "data": {"text": i}}], + }, + } + for i in output_list + ], + ) except Exception as e: err_msg = "出错啦!\n" err_msg += f"date_list = {date_list}\n"