aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/examples/plugins/draftbottles
diff options
context:
space:
mode:
Diffstat (limited to 'examples/plugins/draftbottles')
-rw-r--r--examples/plugins/draftbottles/__init__.py48
-rw-r--r--examples/plugins/draftbottles/config.py52
-rw-r--r--examples/plugins/draftbottles/database.py11
-rw-r--r--examples/plugins/draftbottles/inspector.py128
-rw-r--r--examples/plugins/draftbottles/permission.py10
-rw-r--r--examples/plugins/draftbottles/workroutes.py9
6 files changed, 0 insertions, 258 deletions
diff --git a/examples/plugins/draftbottles/__init__.py b/examples/plugins/draftbottles/__init__.py
deleted file mode 100644
index 1a71f1d..0000000
--- a/examples/plugins/draftbottles/__init__.py
+++ /dev/null
@@ -1,48 +0,0 @@
-from typing import Union
-from iamai import Plugin, Event, Depends
-from iamai.log import logger
-from .config import Config
-from iamai.event import MessageEvent
-from .database import Database
-from .permission import Permission
-from .workroutes import WorkRoutes
-from .inspector import Inspector
-
-
-class Bottles(Plugin, config=Config):
- database: Database = Depends()
- permission: Permission = Depends()
- workroutes: WorkRoutes = Depends()
- inspector: Inspector = Depends()
-
- def __init__(self):
- self.text = None
- self.prefix = None
- self.suffix = None
-
- async def handle(self) -> None:
- self.namespace = next(
- (
- key
- for key, value in self.config.command_list.items()
- if value == self.prefix
- ),
- "",
- )
- if method := getattr(self.inspector, self.namespace, None):
- result = await method(self.suffix, self.config)
- if result:
- await self.event.reply(result)
-
- async def rule(self) -> bool:
- if not isinstance(self.event, MessageEvent):
- return False
- if not self.permission.is_admin():
- return False
- self.text = self.event.get_plain_text()
- for prefix in list(self.config.command_list.values()):
- if self.text.startswith(prefix):
- self.prefix = prefix
- self.suffix = self.text[len(self.prefix) + 1 :]
- return True
- return False
diff --git a/examples/plugins/draftbottles/config.py b/examples/plugins/draftbottles/config.py
deleted file mode 100644
index f5aaa72..0000000
--- a/examples/plugins/draftbottles/config.py
+++ /dev/null
@@ -1,52 +0,0 @@
-from iamai import ConfigModel
-
-
-class Config(ConfigModel):
- __config_name__ = "draft_bottles"
-
- usage: str = """\
- 指令:
- 扔漂流瓶 [文本/图片]
- 捡漂流瓶
- 查看漂流瓶 [漂流瓶编号]
- 点赞漂流瓶 [漂流瓶编号]
- 评论漂流瓶 [漂流瓶编号] [文本]
- 举报漂流瓶 [漂流瓶编号]
- 删除漂流瓶 [漂流瓶编号]
- 我的漂流瓶
- SUPERUSER指令:
- 清空漂流瓶
- 恢复漂流瓶 [漂流瓶编号]
- 删除漂流瓶评论 [漂流瓶编号] [QQ号]
- 漂流瓶白名单 [QQ / 群聊 / 举报] [QQ号 / 群号]
- 漂流瓶黑名单 [QQ / 群聊] [QQ号 / 群号]
- 漂流瓶详情 [漂流瓶编号]
- """.strip()
-
- command_list: dict = {
- "test": "/dfb",
- "throw": "扔漂流瓶",
- "get": "捡漂流瓶",
- "report": "举报漂流瓶",
- "comment": "评论漂流瓶",
- "check": "查看漂流瓶",
- "remove": "删除漂流瓶",
- "listb": "我的漂流瓶",
- "like": "点赞漂流瓶",
- "resume": "恢复漂流瓶",
- "clear": "清空漂流瓶",
- "delete": "删除漂流瓶评论",
- "details": "漂流瓶详情",
- }
-
- ban_list: dict = {
- "groups": [],
- "users": [],
- }
-
- white_list: dict = {
- "groups": [],
- "users": [],
- }
-
- max_content_length: int = 1024
diff --git a/examples/plugins/draftbottles/database.py b/examples/plugins/draftbottles/database.py
deleted file mode 100644
index dededac..0000000
--- a/examples/plugins/draftbottles/database.py
+++ /dev/null
@@ -1,11 +0,0 @@
-class Database:
- admin_list: list = [2753364619]
-
- def __init__(self) -> None:
- ...
-
- def connect(self):
- ...
-
- def close(self):
- ...
diff --git a/examples/plugins/draftbottles/inspector.py b/examples/plugins/draftbottles/inspector.py
deleted file mode 100644
index de757b2..0000000
--- a/examples/plugins/draftbottles/inspector.py
+++ /dev/null
@@ -1,128 +0,0 @@
-from iamai import Event, Depends, Bot
-from .database import Database
-from .permission import Permission
-from .workroutes import WorkRoutes
-from .config import Config
-from iamai.exceptions import GetEventTimeout
-from iamai.adapter.onebot11.message import CQHTTPMessageSegment as ms
-import oneroll
-
-class Inspector:
- event: Event = Depends()
- bot: Bot = Depends()
- database: Database = Depends()
- permission: Permission = Depends()
- workroutes: WorkRoutes = Depends()
-
- async def test(self, *args):
- suffix = list(args)[0]
- a = "1"
- try:
- return f"{eval(suffix)}"
- except Exception as e:
- return f"{e!r}"
-
- async def throw(self, *args):
- suffix = list(args)[0]
- config = list(args)[1]
- if len(suffix) == 0:
- """没有内容,则进入输入流"""
- try:
- content_event = await self.event.ask(
- "在漂流瓶中要写下什么呢?(输入“取消”来取消扔漂流瓶操作。)", timeout=10
- ) # type: ignore
- except GetEventTimeout:
- return "超时。"
- except Exception as e:
- return f"{e!r}"
- else:
- if content_event.message.get_plain_text().lower() in ["取消", "cancel"]:
- return ms.reply(content_event.message_id) + ms.text("已取消扔漂流瓶操作。")
- """有内容,进行审核"""
- content = content_event.message.get_plain_text()
- self._throw(content=content, event=content_event)
- else:
- """有内容,进行审核"""
- self._throw(content=suffix, event=self.event)
-
- async def get(self, *args):
- suffix = list(args)[0]
- try:
- return f"{eval(suffix)}"
- except Exception as e:
- return f"{e!r}"
-
- async def report(self, *args):
- suffix = list(args)[0]
- try:
- return f"{eval(suffix)}"
- except Exception as e:
- return f"{e!r}"
-
- async def comment(self, *args):
- suffix = list(args)[0]
- try:
- return f"{eval(suffix)}"
- except Exception as e:
- return f"{e!r}"
-
- async def check(self, *args):
- suffix = list(args)[0]
- try:
- return f"{eval(suffix)}"
- except Exception as e:
- return f"{e!r}"
-
- async def remove(self, *args):
- suffix = list(args)[0]
- try:
- return f"{eval(suffix)}"
- except Exception as e:
- return f"{e!r}"
-
- async def listb(self, *args):
- suffix = list(args)[0]
- try:
- return f"{eval(suffix)}"
- except Exception as e:
- return f"{e!r}"
-
- async def like(self, *args):
- suffix = list(args)[0]
- try:
- return f"{eval(suffix)}"
- except Exception as e:
- return f"{e!r}"
-
- async def resume(self, *args):
- suffix = list(args)[0]
- try:
- return f"{eval(suffix)}"
- except Exception as e:
- return f"{e!r}"
-
- async def clear(self, *args):
- suffix = list(args)[0]
- try:
- return f"{eval(suffix)}"
- except Exception as e:
- return f"{e!r}"
-
- async def delete(self, *args):
- suffix = list(args)[0]
- try:
- return f"{eval(suffix)}"
- except Exception as e:
- return f"{e!r}"
-
- async def details(self, *args):
- suffix = list(args)[0]
- try:
- return f"{eval(suffix)}"
- except Exception as e:
- return f"{e!r}"
-
- @staticmethod
- def _throw(content: str, **kwargs):
- """扔出漂流瓶"""
- event = kwargs.pop('event', None)
diff --git a/examples/plugins/draftbottles/permission.py b/examples/plugins/draftbottles/permission.py
deleted file mode 100644
index 456dc8b..0000000
--- a/examples/plugins/draftbottles/permission.py
+++ /dev/null
@@ -1,10 +0,0 @@
-from iamai import Event, Depends
-from .database import Database
-
-
-class Permission:
- event: Event = Depends()
- database: Database = Depends()
-
- def is_admin(self):
- return self.event.user_id in self.database.admin_list
diff --git a/examples/plugins/draftbottles/workroutes.py b/examples/plugins/draftbottles/workroutes.py
deleted file mode 100644
index f539780..0000000
--- a/examples/plugins/draftbottles/workroutes.py
+++ /dev/null
@@ -1,9 +0,0 @@
-from iamai import Event, Depends
-from .permission import Permission
-from .database import Database
-
-
-class WorkRoutes:
- event: Event = Depends()
- database: Database = Depends()
- permission: Permission = Depends()