diff options
author | Kyomotoi <[email protected]> | 2021-01-26 18:43:13 +0800 |
---|---|---|
committer | Kyomotoi <[email protected]> | 2021-01-26 18:43:13 +0800 |
commit | 7640568a42493bc5a5e44bc82b1ecfa87e51c5f1 (patch) | |
tree | 60f29b756d58b085c95573515d3e4bd6f41426a8 /ATRI/plugins/utils/__init__.py | |
parent | d0d31b2630697c97e848f00142f06b81f63b255a (diff) | |
download | ATRI-7640568a42493bc5a5e44bc82b1ecfa87e51c5f1.tar.gz ATRI-7640568a42493bc5a5e44bc82b1ecfa87e51c5f1.tar.bz2 ATRI-7640568a42493bc5a5e44bc82b1ecfa87e51c5f1.zip |
[Update]
Diffstat (limited to 'ATRI/plugins/utils/__init__.py')
-rw-r--r-- | ATRI/plugins/utils/__init__.py | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/ATRI/plugins/utils/__init__.py b/ATRI/plugins/utils/__init__.py new file mode 100644 index 0000000..4204cfb --- /dev/null +++ b/ATRI/plugins/utils/__init__.py @@ -0,0 +1,76 @@ +import re +from nonebot.matcher import Matcher +from nonebot.plugin import on_command +from nonebot.adapters.cqhttp import Bot, Event + +from ATRI.config import UTILS_CONFIG +from ATRI.rule import is_in_ban_list, is_in_dormant, is_in_service + +from .data_source import Function + +# ===========================[Begin Command Processing]=========================== + + +__plugin_name_0__ = 'roll' +roll = on_command(UTILS_CONFIG['utils']['roll']['command'][0], + aliases=set(UTILS_CONFIG['utils']['roll']['command']), + rule=is_in_ban_list() & is_in_dormant() + & is_in_service(__plugin_name_0__)) + +__plugin_name_1__ = 'rcnb' +rcnbEncode = on_command( + UTILS_CONFIG['utils']['rcnb']['encode']['command'][0], + aliases=set( + UTILS_CONFIG['utils']['rcnb']['encode']['command']), + rule=is_in_ban_list() & is_in_dormant() + & is_in_service(__plugin_name_1__)) + +rcnbDecode = on_command( + UTILS_CONFIG['utils']['rcnb']['decode']['command'][0], + aliases=set( + UTILS_CONFIG['utils']['rcnb']['decode']['command']), + rule=is_in_ban_list() & is_in_dormant() + & is_in_service(__plugin_name_1__)) + + +async def _(bot, event: Event, state: dict) -> None: + args = str(event.get_message()).strip() + print(args) + if args: + state['result'] = args + [email protected]('result', prompt='roll参数不能为空!..\ndemo: 1d10 或 2d10+3d10') +async def _(matcher: Matcher, bot: Bot, event: Event, state: dict) -> None: + resu = state['result'] + match = re.match(r'^([\dd+\s]+?)$', resu) + print(match) + if not match: + await matcher.reject('格式不-正-确!\ndemo: 1d10 或 2d10+3d10') + await bot.send(event, Function.roll_dice(par=resu)) + + +async def _(bot, event: Event, state: dict) -> None: + args = str(event.get_message()).strip() + if args: + state['result'] = args + [email protected]('result', prompt='请告诉咱需要加密的字符~!') +async def _(bot: Bot, event: Event, state: dict) -> None: + print(state['result']) + await bot.send(event, Function.RCNB.encode(state['result'])) + + +async def _(bot, event: Event, state: dict) -> None: + args = str(event.get_message()).strip() + if args: + state['result'] = args + [email protected]('result', prompt='请告诉咱需要解密的字符~!') +async def _(bot: Bot, event: Event, state: dict) -> None: + await bot.send(event, Function.RCNB.decode(state['result'])) + + +# ===========================[End Command Processing]============================= |