This commit is contained in:
CMHopeSunshine 2022-06-21 18:37:10 +08:00
parent ed0e759d8b
commit f0dade19f9
2 changed files with 4 additions and 3 deletions

View File

@ -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}'))

View File

@ -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: