mirror of
https://github.com/xuthus83/LittlePaimon.git
synced 2025-04-12 23:29:37 +08:00
fix bug
This commit is contained in:
parent
ed0e759d8b
commit
f0dade19f9
@ -73,7 +73,7 @@ def create_matcher(chat_word: str, pattern: str, cooldown: int, pro: float, resp
|
|||||||
return random.random() < pro
|
return random.random() < pro
|
||||||
|
|
||||||
def check_cooldown(event: Union[GroupMessageEvent, PrivateMessageEvent]) -> bool:
|
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 = on_regex(pattern, priority=10, rule=Rule(check_group, check_pro, check_cooldown))
|
||||||
hammer.plugin_name = 'Paimon_Chat'
|
hammer.plugin_name = 'Paimon_Chat'
|
||||||
@ -81,6 +81,7 @@ def create_matcher(chat_word: str, pattern: str, cooldown: int, pro: float, resp
|
|||||||
@hammer.handle()
|
@hammer.handle()
|
||||||
async def handler(event: Union[GroupMessageEvent, PrivateMessageEvent]):
|
async def handler(event: Union[GroupMessageEvent, PrivateMessageEvent]):
|
||||||
try:
|
try:
|
||||||
|
if isinstance(event, GroupMessageEvent):
|
||||||
chat_lmt.start_cd(event.group_id, chat_word, cooldown)
|
chat_lmt.start_cd(event.group_id, chat_word, cooldown)
|
||||||
response: str = random.choice(responses)
|
response: str = random.choice(responses)
|
||||||
if response.endswith('.mp3'):
|
if response.endswith('.mp3'):
|
||||||
|
@ -94,7 +94,7 @@ async def get_img(url: str,
|
|||||||
timeout=timeout,
|
timeout=timeout,
|
||||||
**kwargs)
|
**kwargs)
|
||||||
resp = resp.read()
|
resp = resp.read()
|
||||||
if 'NoSuchKey' in resp:
|
if b'NoSuchKey' in resp:
|
||||||
return 'No Such File'
|
return 'No Such File'
|
||||||
img = Image.open(BytesIO(resp))
|
img = Image.open(BytesIO(resp))
|
||||||
except SSLCertVerificationError:
|
except SSLCertVerificationError:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user