From 8dbd7316f60fe024457f7d0eb5e6c941d4c30f51 Mon Sep 17 00:00:00 2001 From: Zhao Zuohong Date: Wed, 16 Aug 2023 12:20:51 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A3=81=E7=BC=9D=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/riic_report_analysis.py | 37 +++++++++++++++++++++++++++++++++++- bot.py | 3 ++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/apps/riic_report_analysis.py b/apps/riic_report_analysis.py index 029bb75..b825c4e 100644 --- a/apps/riic_report_analysis.py +++ b/apps/riic_report_analysis.py @@ -1,10 +1,12 @@ 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 rapidocr_onnxruntime import RapidOCR import os import asyncio import functools import re -from typing import Dict +from typing import Dict, Optional rapid_ocr = None @@ -199,3 +201,36 @@ 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")) + + +@as_command( + need_prefix=False, + aliases=["裁缝计算"], + include_class_name=False, + require_at=False, +) +class TailoringCommand: + async def initial(self, sender: CommandSender, arg: Optional[str] = CLIArgument()): + if not arg: + await sender.reply(Text("请输入效率!")) + return + if arg.endswith("%"): + arg = arg[:-1] + try: + efficiency = float(arg) + except: + await sender.reply(Text("输入无效!")) + return + if efficiency > 30: + efficiency /= 100 + total_efficiency = efficiency + 1.1 + equiv_efficiency = total_efficiency * 1.241 + gold_efficiency = total_efficiency * 0.233 + lmb = equiv_efficiency * 24 * 60 / 70.138 * 500 + gold = gold_efficiency * 24 * 60 / 72 * 500 + output = f"整站效率:{total_efficiency * 100:.0f}%\n" + output += f"等效贸易:{(equiv_efficiency - 1) * 100:.0f}%\n" + output += f"等效制造:{gold_efficiency * 100:.0f}%\n" + output += f"订单收益:{lmb:.0f}\n" + output += f"赤金收益:{gold:.0f}" + await sender.reply(Text(output)) diff --git a/bot.py b/bot.py index e0eb2a6..efefc97 100644 --- a/bot.py +++ b/bot.py @@ -2,7 +2,7 @@ from pepperbot import PepperBot from pepperbot.store.meta import BotRoute from apps.wuhu_takeoff import WuHuTakeoff -from apps.riic_report_analysis import RIICReportAnalysis +from apps.riic_report_analysis import RIICReportAnalysis, TailoringCommand bot = PepperBot(port=5800) @@ -31,6 +31,7 @@ bot.apply_routes( }, friends=None, handlers=[RIICReportAnalysis], + commands=[TailoringCommand], ), ] )