diff options
Diffstat (limited to 'ATRI/plugins/util/__init__.py')
-rw-r--r-- | ATRI/plugins/util/__init__.py | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/ATRI/plugins/util/__init__.py b/ATRI/plugins/util/__init__.py index 19fdcaf..26ef570 100644 --- a/ATRI/plugins/util/__init__.py +++ b/ATRI/plugins/util/__init__.py @@ -3,13 +3,18 @@ from random import choice, random from nonebot.matcher import Matcher from nonebot.params import CommandArg, ArgPlainText -from nonebot.adapters.onebot.v11 import MessageEvent, Message +from nonebot.adapters.onebot.v11 import Message from nonebot.adapters.onebot.v11.helpers import Cooldown -from .data_source import Encrypt, Utils, Yinglish +from ATRI.service import Service +from .data_source import Encrypt, Yinglish, roll_dice -roll = Utils().on_command("/roll", "骰子~用法:1d10 或 2d10+2d10+more") + +utils = Service("小工具").document("非常实用(?)的工具们!") + + +roll = utils.on_command("/roll", "骰子~用法: 1d10 或 2d10+2d10+more") @roll.handle() @@ -19,18 +24,18 @@ async def _ready_roll(matcher: Matcher, args: Message = CommandArg()): matcher.set_arg("roll", args) [email protected]("roll", "参数呢?!格式:1d10 或 2d10+2d10+more") [email protected]("roll", "参数呢?! 格式: 1d10 或 2d10+2d10+more") async def _deal_roll(roll_msg: str = ArgPlainText("roll")): match = re.match(r"^([\dd+\s]+?)$", roll_msg) if not match: - await roll.finish("阿——!参数不对!格式:1d10 或 2d10+2d10+more") + await roll.finish("阿——! 参数不对! 格式: 1d10 或 2d10+2d10+more") - msg = Utils().roll_dice(roll_msg) + msg = roll_dice(roll_msg) await roll.finish(msg) -encrypt_en = Utils().on_command("加密", "我们之间的秘密❤") +encrypt_en = utils.on_command("加密", "我们之间的秘密❤") @encrypt_en.handle() @@ -50,7 +55,7 @@ async def _deal_en(text: str = ArgPlainText("encr_en_text")): await encrypt_en.finish(result) -encrypt_de = Utils().on_command("解密", "解开我们的秘密❤") +encrypt_de = utils.on_command("解密", "解开我们的秘密❤") @encrypt_de.handle() @@ -67,7 +72,7 @@ async def _deal_de(text: str = ArgPlainText("encr_de_text")): await encrypt_de.finish(result) -sepi = Utils().on_command("涩批一下", "将正常的句子涩一涩~") +sepi = utils.on_command("涩批一下", "将正常的句子涩一涩~") _sepi_flmt_notice = choice(["涩批爬", "✌🥵✌"]) @@ -81,10 +86,9 @@ async def _ready_sepi(matcher: Matcher, args: Message = CommandArg()): @sepi.got("sepi_text", "内容呢?!") -async def _deal_sepi(event: MessageEvent, msg: str = ArgPlainText("sepi_text")): - user_id = event.get_user_id() +async def _deal_sepi(msg: str = ArgPlainText("sepi_text")): if len(msg) < 4: await sepi.finish("这么短?涩不起来!") - result = Yinglish.deal(msg, random()) + result = Yinglish(msg).deal(random()) await sepi.finish(result) |