summaryrefslogtreecommitdiff
path: root/ATRI/plugins/repo.py
diff options
context:
space:
mode:
Diffstat (limited to 'ATRI/plugins/repo.py')
-rw-r--r--ATRI/plugins/repo.py48
1 files changed, 21 insertions, 27 deletions
diff --git a/ATRI/plugins/repo.py b/ATRI/plugins/repo.py
index 9c52610..40869eb 100644
--- a/ATRI/plugins/repo.py
+++ b/ATRI/plugins/repo.py
@@ -1,7 +1,8 @@
from random import choice
-from nonebot.typing import T_State
-from nonebot.adapters.cqhttp import Bot, MessageEvent
+from nonebot.matcher import Matcher
+from nonebot.params import CommandArg, ArgPlainText
+from nonebot.adapters.onebot.v11 import Bot, MessageEvent, Message
from ATRI.service import Service
from ATRI.config import BotSelfConfig
@@ -25,46 +26,39 @@ class Repo(Service):
Service.__init__(self, "反馈", "向维护者发送消息")
-repo = Repo().on_command("来杯红茶", "向维护者发送消息", aliases={"反馈", "报告"})
+reporter = Repo().on_command("来杯红茶", "向维护者发送消息", aliases={"反馈", "报告"})
[email protected]_parser # type: ignore
-async def _get_repo(bot: Bot, event: MessageEvent, state: T_State):
- msg = str(event.message).strip()
- quit_list = ["算了", "罢了", "取消"]
- if msg in quit_list:
- await repo.finish("好吧...")
- if not msg:
- await repo.reject("需要反馈的内容呢?~")
- else:
- state["repo"] = msg
-
-
-async def _ready_repo(bot: Bot, event: MessageEvent, state: T_State):
+async def _ready_repo(
+ matcher: Matcher, event: MessageEvent, args: Message = CommandArg()
+):
user_id = event.get_user_id()
if not _repo_flmt.check(user_id):
- await repo.finish(_repo_flmt_notice)
+ await reporter.finish(_repo_flmt_notice)
if not _repo_dlmt.check(user_id):
- await repo.finish(_repo_dlmt_notice)
+ await reporter.finish(_repo_dlmt_notice)
- msg = str(event.message).strip()
+ msg = args.extract_plain_text()
if msg:
- state["repo"] = msg
+ matcher.set_arg("repo", args)
[email protected]("repo", "需要反馈的内容呢?~")
-async def _deal_repo(bot: Bot, event: MessageEvent, state: T_State):
- msg = state["repo"]
[email protected]("repo", "需要反馈的内容呢?~")
+async def _deal_repo(
+ bot: Bot,
+ event: MessageEvent,
+ repo_msg: str = ArgPlainText("repo"),
+):
user_id = event.get_user_id()
- repo_0 = REPO_FORMAT.format(user=user_id, msg=msg)
+ repo_0 = REPO_FORMAT.format(user=user_id, msg=repo_msg)
for superuser in BotSelfConfig.superusers:
try:
await bot.send_private_msg(user_id=superuser, message=repo_0)
except BaseException:
- await repo.finish("发送失败了呢...")
+ await reporter.finish("发送失败了呢...")
_repo_flmt.start_cd(user_id)
_repo_dlmt.increase(user_id)
- await repo.finish("吾辈的心愿已由咱转告维护者!")
+ await reporter.finish("吾辈的心愿已由咱转告维护者!")