summaryrefslogtreecommitdiff
path: root/ATRI/rule.py
diff options
context:
space:
mode:
authorKyomotoi <[email protected]>2020-12-20 17:14:41 +0800
committerKyomotoi <[email protected]>2020-12-20 17:14:41 +0800
commit9bf222471d34cb756a4878b103ec82c6c4bfb191 (patch)
tree1420d498c41f71858e74b4926b8d7206b5235fe6 /ATRI/rule.py
parent9ac2c2eb7ef2eb267e926d599dc077f5afae98f9 (diff)
downloadATRI-9bf222471d34cb756a4878b103ec82c6c4bfb191.tar.gz
ATRI-9bf222471d34cb756a4878b103ec82c6c4bfb191.tar.bz2
ATRI-9bf222471d34cb756a4878b103ec82c6c4bfb191.zip
[Update]
- 创建项目结构
Diffstat (limited to 'ATRI/rule.py')
-rw-r--r--ATRI/rule.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/ATRI/rule.py b/ATRI/rule.py
new file mode 100644
index 0000000..1ed10d8
--- /dev/null
+++ b/ATRI/rule.py
@@ -0,0 +1,46 @@
+from re import T
+from nonebot.rule import Rule
+from nonebot.typing import Bot, Event
+
+from ATRI.service import Service
+
+
+def isInService(service: str) -> Rule:
+ async def _isInService(bot: Bot, event: Event, state: dict) -> bool:
+ return Service().Switch().auth_service(service, event.group_id)
+
+ return Rule(_isInService)
+
+
+def isInBanList() -> Rule:
+ async def _isInBanList(bot: Bot, event: Event, state: dict) -> bool:
+ return Service().BanList().is_in_list(event.user_id)
+
+ return Rule(_isInBanList)
+
+
+def isInDormant() -> Rule:
+ async def _isInDormant(bot: Bot, event: Event, state: dict) -> bool:
+ return Service().Dormant().is_sleep()
+
+ return Rule(_isInDormant)
+
+
+def toGroup() -> Rule:
+ async def _toGroup(bot: Bot, event: Event, state: dict) -> bool:
+ return bool(event.group_id)
+
+ return Rule(_toGroup)
+
+
+def toPrivate() -> Rule:
+ async def _toPrivate(bot: Bot, event: Event, state: dict) -> bool:
+ return not bool(event.group_id)
+
+ return Rule(_toPrivate)
+
+def toBot() -> Rule:
+ async def _toBot(bot: Bot, event: Event, state: dict) -> bool:
+ return bool(event.to_me)
+
+ return Rule(_toBot)