From 8804f1e10d507ba293fafc77a7e93d3a84a5814b Mon Sep 17 00:00:00 2001 From: Lint Action Date: Tue, 4 May 2021 06:29:07 +0000 Subject: =?UTF-8?q?:rotating=5Flight:=20=E8=87=AA=E5=8A=A8=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ATRI/plugins/call_owner.py | 46 ++++++++++++++++++---------------------------- 1 file changed, 18 insertions(+), 28 deletions(-) (limited to 'ATRI/plugins/call_owner.py') diff --git a/ATRI/plugins/call_owner.py b/ATRI/plugins/call_owner.py index 3fb5a01..bcbae73 100644 --- a/ATRI/plugins/call_owner.py +++ b/ATRI/plugins/call_owner.py @@ -1,9 +1,6 @@ from nonebot.permission import SUPERUSER from nonebot.typing import T_State -from nonebot.adapters.cqhttp import ( - Bot, - MessageEvent -) +from nonebot.adapters.cqhttp import Bot, MessageEvent from ATRI.service import Service as sv from ATRI.config import BotSelfConfig @@ -21,48 +18,44 @@ __doc__ = """ repo = sv.on_command(cmd="来杯红茶", docs=__doc__) + @repo.args_parser # type: ignore async def _repo_load(bot: Bot, event: MessageEvent, state: T_State) -> None: msg = str(event.message) if msg == "算了": - await repo.finish('好吧') - + await repo.finish("好吧") + if not msg: - await repo.reject('话呢?') + await repo.reject("话呢?") else: - state['msg_repo'] = msg + state["msg_repo"] = msg + @repo.handle() async def _repo(bot: Bot, event: MessageEvent, state: T_State) -> None: msg = str(event.message).strip() if msg: - state['msg_repo'] = msg + state["msg_repo"] = msg + -@repo.got('msg_repo', prompt="请告诉咱需要反馈的内容~!") +@repo.got("msg_repo", prompt="请告诉咱需要反馈的内容~!") async def _repo_deal(bot: Bot, event: MessageEvent, state: T_State) -> None: global repo_list - msg = state['msg_repo'] + msg = state["msg_repo"] user = event.user_id - + if count_list(repo_list, user) == 5: await repo.finish("吾辈已经喝了五杯红茶啦!明天再来吧。") - + repo_list.append(user) for sup in BotSelfConfig.superusers: - await bot.send_private_msg( - user_id=sup, - message=f"来自用户[{user}]反馈:\n{msg}" - ) - + await bot.send_private_msg(user_id=sup, message=f"来自用户[{user}]反馈:\n{msg}") + await repo.finish("吾辈的心愿已由咱转告给咱的维护者了~!") -@scheduler.scheduled_job( - "cron", - hour=0, - misfire_grace_time=60 -) +@scheduler.scheduled_job("cron", hour=0, misfire_grace_time=60) async def _() -> None: global repo_list repo_list.clear() @@ -75,11 +68,8 @@ __doc__ = """ /重置红茶 """ -reset_repo = sv.on_command( - cmd="重置红茶", - docs=__doc__, - permission=SUPERUSER -) +reset_repo = sv.on_command(cmd="重置红茶", docs=__doc__, permission=SUPERUSER) + @reset_repo.handle() async def _reset_repo(bot: Bot, event: MessageEvent) -> None: -- cgit v1.2.3