From f0dade19f98c4c5975d68d096c684b6a2e925e1e Mon Sep 17 00:00:00 2001 From: CMHopeSunshine <277073121@qq.com> Date: Tue, 21 Jun 2022 18:37:10 +0800 Subject: [PATCH] fix bug --- Paimon_Chat/__init__.py | 5 +++-- utils/aiorequests.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Paimon_Chat/__init__.py b/Paimon_Chat/__init__.py index e515c3a..106f25b 100644 --- a/Paimon_Chat/__init__.py +++ b/Paimon_Chat/__init__.py @@ -73,7 +73,7 @@ def create_matcher(chat_word: str, pattern: str, cooldown: int, pro: float, resp return random.random() < pro def check_cooldown(event: Union[GroupMessageEvent, PrivateMessageEvent]) -> bool: - return chat_lmt.check(event.group_id, chat_word) + return isinstance(event, PrivateMessageEvent) or chat_lmt.check(event.group_id, chat_word) hammer = on_regex(pattern, priority=10, rule=Rule(check_group, check_pro, check_cooldown)) hammer.plugin_name = 'Paimon_Chat' @@ -81,7 +81,8 @@ def create_matcher(chat_word: str, pattern: str, cooldown: int, pro: float, resp @hammer.handle() async def handler(event: Union[GroupMessageEvent, PrivateMessageEvent]): try: - chat_lmt.start_cd(event.group_id, chat_word, cooldown) + if isinstance(event, GroupMessageEvent): + chat_lmt.start_cd(event.group_id, chat_word, cooldown) response: str = random.choice(responses) if response.endswith('.mp3'): await hammer.finish(await MessageBuild.StaticRecord(url=f'LittlePaimon/voice/{response}')) diff --git a/utils/aiorequests.py b/utils/aiorequests.py index ae8e9c4..1698d95 100644 --- a/utils/aiorequests.py +++ b/utils/aiorequests.py @@ -94,7 +94,7 @@ async def get_img(url: str, timeout=timeout, **kwargs) resp = resp.read() - if 'NoSuchKey' in resp: + if b'NoSuchKey' in resp: return 'No Such File' img = Image.open(BytesIO(resp)) except SSLCertVerificationError: