mirror of
https://github.com/LiteyukiStudio/LiteyukiBot.git
synced 2024-11-11 06:27:23 +08:00
📝 添加 onebot_v12_event_monitor
This commit is contained in:
parent
974b97b744
commit
246e43317f
@ -4,7 +4,7 @@ from nonebot import require
|
|||||||
from nonebot.message import event_postprocessor
|
from nonebot.message import event_postprocessor
|
||||||
|
|
||||||
from liteyuki.utils.base.data import Database, LiteModel
|
from liteyuki.utils.base.data import Database, LiteModel
|
||||||
from liteyuki.utils.base.ly_typing import v11, satori
|
from liteyuki.utils.base.ly_typing import v11, v12, satori
|
||||||
|
|
||||||
from liteyuki.utils.base.ly_typing import T_Bot, T_MessageEvent
|
from liteyuki.utils.base.ly_typing import T_Bot, T_MessageEvent
|
||||||
|
|
||||||
@ -47,6 +47,29 @@ async def onebot_v11_event_monitor(bot: v11.Bot, event: v11.MessageEvent):
|
|||||||
msg_db.save(mem)
|
msg_db.save(mem)
|
||||||
|
|
||||||
|
|
||||||
|
@event_postprocessor
|
||||||
|
async def onebot_v12_event_monitor(bot: v12.Bot, event: v12.MessageEvent):
|
||||||
|
if event.message_type == "group":
|
||||||
|
event: v12.GroupMessageEvent
|
||||||
|
group_id = str(event.group_id)
|
||||||
|
else:
|
||||||
|
group_id = ""
|
||||||
|
mem = MessageEventModel(
|
||||||
|
time=int(time.time()),
|
||||||
|
bot_id=bot.self_id,
|
||||||
|
adapter="onebot.v12",
|
||||||
|
group_id=group_id,
|
||||||
|
user_id=str(event.user_id),
|
||||||
|
|
||||||
|
message_id=str(event.message_id),
|
||||||
|
|
||||||
|
message=event.message,
|
||||||
|
message_text=event.raw_message,
|
||||||
|
message_type=event.message_type,
|
||||||
|
)
|
||||||
|
msg_db.save(mem)
|
||||||
|
|
||||||
|
|
||||||
@event_postprocessor
|
@event_postprocessor
|
||||||
async def satori_event_monitor(bot: satori.Bot, event: satori.MessageEvent):
|
async def satori_event_monitor(bot: satori.Bot, event: satori.MessageEvent):
|
||||||
if event.guild is not None:
|
if event.guild is not None:
|
||||||
|
Loading…
Reference in New Issue
Block a user