1
0
forked from bot/app

📝 将 Satori 用户缓存更新日志的输出时机由原来的每次调用函数调整为每次用户信息发生变更

This commit is contained in:
Expliyh
2024-05-17 14:42:37 +08:00
parent 322ad19889
commit 077658c68d
2 changed files with 32 additions and 6 deletions

View File

@ -1,3 +1,5 @@
import nonebot
from liteyuki.utils import satori_utils
from nonebot.message import event_preprocessor
# from nonebot_plugin_alconna.typings import Event
@ -10,13 +12,11 @@ from liteyuki.plugins.liteyuki_status.counter_for_satori import satori_counter
@event_preprocessor
async def pre_handle(event: Event):
print("UPDATE_USER")
print(event.__dict__)
if isinstance(event, satori.MessageEvent):
if event.user.id == event.self_id:
satori_counter.msg_sent += 1
else:
satori_counter.msg_received += 1
if event.user.name is not None:
await satori_utils.user_infos.put(event.user)
print(event.user)
if await satori_utils.user_infos.put(event.user):
nonebot.logger.info(f"Satori user {event.user.name}<{event.user.id}> updated")