mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-09-28 16:20:56 +08:00
* bugfix:修复notice事件扩散问题 * 优化并发调度 * bugfix:修复签到样式 * bugfix:功能调用统计修复 * bugfix:修复私聊时功能调用统计显示已退群问题 * 提高插件适配兼容性 * 优化发送队列 * 修改权限检查设计 * 继续修改权限检查设计 * 完善权限检查设计 * 优化sqlite配置 * 优化数据库初始化 * 代码整理,无用代码清理 * bugfix:修复启动时数据库校验问题 * bugfix:修复预算裁剪过于激进问题
56 lines
1.6 KiB
Python
56 lines
1.6 KiB
Python
from tortoise import fields
|
|
|
|
from zhenxun.services.db_context import Model
|
|
from zhenxun.utils.enum import BotSentType
|
|
|
|
from ._bot_message_buffer import append_bot_message_store_record
|
|
|
|
|
|
class BotMessageStore(Model):
|
|
id = fields.IntField(pk=True, generated=True, auto_increment=True)
|
|
"""自增id"""
|
|
bot_id = fields.CharField(255, null=True)
|
|
"""bot id"""
|
|
user_id = fields.CharField(255, null=True)
|
|
"""目标id"""
|
|
group_id = fields.CharField(255, null=True)
|
|
"""群组id"""
|
|
sent_type = fields.CharEnumField(BotSentType)
|
|
"""类型"""
|
|
text = fields.TextField(null=True)
|
|
"""文本内容"""
|
|
plain_text = fields.TextField(null=True)
|
|
"""纯文本"""
|
|
platform = fields.CharField(255, null=True)
|
|
"""平台"""
|
|
create_time = fields.DatetimeField(auto_now_add=True)
|
|
"""创建时间"""
|
|
|
|
class Meta: # pyright: ignore [reportIncompatibleVariableOverride]
|
|
table = "bot_message_store"
|
|
table_description = "Bot发送消息列表"
|
|
|
|
@classmethod
|
|
async def append_buffered(
|
|
cls,
|
|
*,
|
|
bot_id: str | None = None,
|
|
user_id: str | None = None,
|
|
group_id: str | None = None,
|
|
sent_type: BotSentType,
|
|
text: str | None = None,
|
|
plain_text: str | None = None,
|
|
platform: str | None = None,
|
|
) -> None:
|
|
await append_bot_message_store_record(
|
|
cls(
|
|
bot_id=bot_id,
|
|
user_id=user_id,
|
|
group_id=group_id,
|
|
sent_type=sent_type,
|
|
text=text,
|
|
plain_text=plain_text,
|
|
platform=platform,
|
|
)
|
|
)
|