From ea7f48011c34fdaec7e91af7eb373c8174e439e6 Mon Sep 17 00:00:00 2001 From: Kyomotoi <1172294279@qq.com> Date: Tue, 4 May 2021 14:27:56 +0800 Subject: =?UTF-8?q?=E2=9C=A8=F0=9F=90=9B=20=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增:老婆! 新增:涩图 修复:manage中出现的bug 优化:nsfw不再用float,换为int --- ATRI/plugins/utils/__init__.py | 89 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 73 insertions(+), 16 deletions(-) (limited to 'ATRI/plugins/utils/__init__.py') diff --git a/ATRI/plugins/utils/__init__.py b/ATRI/plugins/utils/__init__.py index ff28e59..fa59690 100644 --- a/ATRI/plugins/utils/__init__.py +++ b/ATRI/plugins/utils/__init__.py @@ -1,9 +1,12 @@ import re +from random import random + +from nonebot.typing import T_State from nonebot.adapters.cqhttp import Bot, MessageEvent from ATRI.service import Service as sv from ATRI.rule import is_in_service -from .data_source import roll_dice, Encrypt +from .data_source import roll_dice, Encrypt, Yinglish __doc__ = """ @@ -17,24 +20,37 @@ roll一下 /roll 1d10+10d9+4d5+2d3 """ -roll = sv.on_command(cmd="/roll", docs=__doc__, rule=is_in_service("roll")) - +roll = sv.on_command( + cmd="/roll", + docs=__doc__, + rule=is_in_service('roll') +) + +@roll.args_parser # type: ignore +async def _load_roll(bot: Bot, event: MessageEvent, state: T_State) -> None: + msg = str(event.message).strip() + quit_list = ['算了', '罢了', '取消'] + if msg in quit_list: + await roll.finish('好吧...') + if not msg: + await roll.reject('点呢?(1d10+...)') + else: + state['resu'] = msg @roll.handle() -async def _roll(bot: Bot, event: MessageEvent, state: dict) -> None: +async def _roll(bot: Bot, event: MessageEvent, state: T_State) -> None: args = str(event.message).strip() if args: - state["resu"] = args - + state['resu'] = args @roll.got("resu", prompt="roll 参数不能为空~!\ndemo:1d10 或 2d10+2d10") -async def _(bot: Bot, event: MessageEvent, state: dict) -> None: - resu = state["resu"] - match = re.match(r"^([\dd+\s]+?)$", resu) - +async def _deal_roll(bot: Bot, event: MessageEvent, state: T_State) -> None: + resu = state['resu'] + match = re.match(r'^([\dd+\s]+?)$', resu) + if not match: await roll.finish("请输入正确的参数!!\ndemo:1d10 或 2d10+2d10") - + await roll.finish(roll_dice(resu)) @@ -50,19 +66,60 @@ __doc__ = """ /enc e アトリは高性能ですから! """ -encrypt = sv.on_command(cmd="/enc", docs=__doc__, rule=is_in_service("enc")) - +encrypt = sv.on_command( + cmd="/enc", + docs=__doc__, + rule=is_in_service('enc') +) @encrypt.handle() async def _encrypt(bot: Bot, event: MessageEvent) -> None: - msg = str(event.message).split(" ") + msg = str(event.message).split(' ') _type = msg[0] s = msg[1] e = Encrypt() - + if _type == "e": await encrypt.finish(e.encode(s)) elif _type == "d": await encrypt.finish(e.decode(s)) else: - await encrypt.finish("请检查输入~!") + await encrypt.finish('请检查输入~!') + + +__doc__ = """ +涩批一下! +权限组:所有人 +用法: + 涩批一下 (msg) +""" + +sepi = sv.on_command( + cmd="涩批一下", + docs=__doc__, + rule=is_in_service('涩批一下') +) + +@sepi.handle() +async def _load_sepi(bot: Bot, event: MessageEvent, state: T_State) -> None: + msg = str(event.message).strip() + quit_list = ['算了', '罢了', '取消'] + if msg in quit_list: + await sepi.finish('好吧...') + if not msg: + await sepi.reject('话呢?') + else: + state['sepi_msg'] = msg + +@sepi.handle() +async def _sepi(bot: Bot, event: MessageEvent, state: T_State) -> None: + msg = str(event.message).strip() + if msg: + state['sepi_msg'] = msg + +@sepi.got('sepi_msg', prompt='话呢?') +async def _deal_sepi(bot: Bot, event: MessageEvent, state: T_State) -> None: + msg = state['sepi_msg'] + if len(msg) < 4: + await sepi.finish('这么短?涩不起来!') + await sepi.finish(Yinglish.deal(msg, random())) \ No newline at end of file -- cgit v1.2.3