diff options
author | Kyomotoi <[email protected]> | 2021-05-04 14:27:56 +0800 |
---|---|---|
committer | Kyomotoi <[email protected]> | 2021-05-04 14:27:56 +0800 |
commit | ea7f48011c34fdaec7e91af7eb373c8174e439e6 (patch) | |
tree | e4f14eaacde37774d49e7f98ac1ff4635049d80a /ATRI/plugins/utils/__init__.py | |
parent | 07a7e41f72cfa9dfd207a04445f4aa5b0b6fa3ce (diff) | |
download | ATRI-ea7f48011c34fdaec7e91af7eb373c8174e439e6.tar.gz ATRI-ea7f48011c34fdaec7e91af7eb373c8174e439e6.tar.bz2 ATRI-ea7f48011c34fdaec7e91af7eb373c8174e439e6.zip |
✨🐛 更新
新增:老婆!
新增:涩图
修复:manage中出现的bug
优化:nsfw不再用float,换为int
Diffstat (limited to 'ATRI/plugins/utils/__init__.py')
-rw-r--r-- | ATRI/plugins/utils/__init__.py | 89 |
1 files changed, 73 insertions, 16 deletions
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') +) + [email protected]_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('涩批一下') +) + +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 + +async def _sepi(bot: Bot, event: MessageEvent, state: T_State) -> None: + msg = str(event.message).strip() + if msg: + state['sepi_msg'] = msg + [email protected]('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 |