mirror of
https://github.com/TriM-Organization/LiteyukiBot-TriM.git
synced 2024-11-25 00:25:04 +08:00
24722447da
get_plugin_session_enable 判断当前使用的适配器
62 lines
1.4 KiB
Python
62 lines
1.4 KiB
Python
import time
|
|
|
|
from nonebot import require
|
|
from nonebot.message import event_postprocessor
|
|
|
|
from liteyuki.utils.base.data import Database, LiteModel
|
|
from liteyuki.utils.base.ly_typing import v11, satori
|
|
|
|
from .common import MessageEventModel, msg_db
|
|
|
|
require("nonebot_plugin_alconna")
|
|
|
|
|
|
|
|
|
|
|
|
@event_postprocessor
|
|
async def onebot_v11_event_monitor(bot: v11.Bot, event: v11.MessageEvent):
|
|
if event.message_type == "group":
|
|
event: v11.GroupMessageEvent
|
|
group_id = str(event.group_id)
|
|
else:
|
|
group_id = ""
|
|
|
|
mem = MessageEventModel(
|
|
time=int(time.time()),
|
|
bot_id=bot.self_id,
|
|
adapter="onebot.v11",
|
|
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)
|
|
|
|
|
|
async def satori_event_monitor(bot: satori.Bot, event: satori.MessageEvent):
|
|
if event.guild is not None:
|
|
event: satori.MessageEvent
|
|
group_id = str(event.guild.id)
|
|
else:
|
|
group_id = ""
|
|
|
|
mem = MessageEventModel(
|
|
time=int(time.time()),
|
|
bot_id=bot.self_id,
|
|
adapter="satori",
|
|
group_id=group_id,
|
|
user_id=str(event.user.id),
|
|
|
|
message_id=str(event.message.id),
|
|
|
|
message=event.message,
|
|
message_text=event.message.content,
|
|
message_type=event.message_type,
|
|
)
|
|
msg_db.save(mem)
|