From c38bab21b3c85e82250e3b82ebde31e2aca2db92 Mon Sep 17 00:00:00 2001 From: Kyomotoi Date: Sat, 5 Feb 2022 00:47:52 +0800 Subject: =?UTF-8?q?=F0=9F=9A=91=EF=B8=8F=F0=9F=94=92=EF=B8=8F=F0=9F=94=A7?= =?UTF-8?q?=20=E5=A4=A7=E5=9E=8B=E4=BF=AE=E5=A4=8D=E5=B7=A5=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 针对传回消息不同适配、外置限制改为nb内置限制 --- ATRI/plugins/util/__init__.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'ATRI/plugins/util') diff --git a/ATRI/plugins/util/__init__.py b/ATRI/plugins/util/__init__.py index b67a988..e63870b 100644 --- a/ATRI/plugins/util/__init__.py +++ b/ATRI/plugins/util/__init__.py @@ -4,8 +4,8 @@ from random import choice, random from nonebot.matcher import Matcher from nonebot.params import CommandArg, ArgPlainText from nonebot.adapters.onebot.v11 import MessageEvent, Message +from nonebot.adapters.onebot.v11.helpers import Cooldown -from ATRI.utils.limit import FreqLimiter from .data_source import Encrypt, Utils, Yinglish @@ -69,18 +69,14 @@ async def _deal_de(text: str = ArgPlainText("encr_de_text")): sepi = Utils().on_command("涩批一下", "将正常的句子涩一涩~") -_sepi_flmt = FreqLimiter(3) -_sepi_flmt_notice = ["涩批爬", "✌🥵✌"] +_sepi_flmt_notice = choice(["涩批爬", "✌🥵✌"]) -@sepi.handle() + +@sepi.handle([Cooldown(3, prompt=_sepi_flmt_notice)]) async def _ready_sepi( - matcher: Matcher, event: MessageEvent, args: Message = CommandArg() + matcher: Matcher, args: Message = CommandArg() ): - user_id = event.get_user_id() - if not _sepi_flmt.check(user_id): - await sepi.finish(choice(_sepi_flmt_notice)) - msg = args.extract_plain_text() if msg: matcher.set_arg("sepi_text", args) @@ -93,5 +89,4 @@ async def _deal_sepi(event: MessageEvent, msg: str = ArgPlainText("sepi_text")): await sepi.finish("这么短?涩不起来!") result = Yinglish.deal(msg, random()) - _sepi_flmt.start_cd(user_id) await sepi.finish(result) -- cgit v1.2.3