裁缝计算

This commit is contained in:
zhbaor 2023-08-16 12:20:51 +08:00
parent 391572bf20
commit 8dbd7316f6
2 changed files with 38 additions and 2 deletions

View file

@ -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))

3
bot.py
View file

@ -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],
),
]
)