summaryrefslogtreecommitdiff
path: root/ATRI/plugins/utils/__init__.py
diff options
context:
space:
mode:
authorKyomotoi <[email protected]>2021-02-20 08:19:41 +0800
committerKyomotoi <[email protected]>2021-02-20 08:19:41 +0800
commitae7ea2d379ec7fb0edb8e333145bb141106a2fd2 (patch)
tree3243cb1dd668d36f92f17e958ff2a38e7b2c450c /ATRI/plugins/utils/__init__.py
parent3d16960b487f8911fb3817c2abcdb252ad848f58 (diff)
downloadATRI-ae7ea2d379ec7fb0edb8e333145bb141106a2fd2.tar.gz
ATRI-ae7ea2d379ec7fb0edb8e333145bb141106a2fd2.tar.bz2
ATRI-ae7ea2d379ec7fb0edb8e333145bb141106a2fd2.zip
✨ 更新插件,埋下bug
- 更新插件: - call-owner - code-runner - status - anime-search - tex(待修复) - 埋下bug: - service中limit作为机器人服务中的开关,目前写入文件亟待修复
Diffstat (limited to 'ATRI/plugins/utils/__init__.py')
-rw-r--r--ATRI/plugins/utils/__init__.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/ATRI/plugins/utils/__init__.py b/ATRI/plugins/utils/__init__.py
index e69de29..1bf1461 100644
--- a/ATRI/plugins/utils/__init__.py
+++ b/ATRI/plugins/utils/__init__.py
@@ -0,0 +1,51 @@
+import re
+
+from nonebot.plugin import on_command
+from nonebot.adapters.cqhttp import Bot, MessageEvent
+
+from ATRI.rule import (
+ is_in_banlist,
+ is_in_dormant,
+ is_in_service
+)
+from .data_source import roll_dice
+
+
+__plugin_name__ = "roll"
+
+roll = on_command(
+ "/roll",
+ rule=is_in_banlist() & is_in_dormant()
+ & is_in_service(__plugin_name__)
+)
+
+async def _roll(bot: Bot, event: MessageEvent, state: dict) -> None:
+ args = str(event.message).strip()
+ if args:
+ state['resu'] = args
+
[email protected]("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)
+
+ if not match:
+ await roll.finish("请输入正确的参数!!\ndemo:1d10 或 2d10+2d10")
+
+ await roll.finish(roll_dice(resu))
+
+
+# __plugin_name__ = "fakemsg"
+
+# fakemsg = on_command(
+# "/fakemsg",
+# rule=is_in_banlist() & is_in_dormant()
+# & is_in_service(__plugin_name__)
+# )
+
+# @fakemsg.handle()
+# async def _fakemsg(bot: Bot, event: MessageEvent, state: dict) -> None:
+# ...
+
+# @fakemsg.got() \ No newline at end of file