This commit is contained in:
Furina-1013-create
2025-08-17 14:00:42 +08:00
3 changed files with 14 additions and 19 deletions

1
.gitignore vendored
View File

@@ -1,4 +1,5 @@
data/
/backups/
data1/
mongodb/
NapCat.Framework.Windows.Once/

View File

@@ -6,7 +6,7 @@
- [x] 基于关键帧的视频识别功能
- [ ] 对XML,JSON等特殊消息解析
- [x] 插件热重载
- [ ] 适配器黑/白名单迁移至独立配置文件,并支持热重载
- [x] 适配器黑/白名单迁移至独立配置文件,并支持热重载
- [x] 添加MySQL支持,重构数据库
- [ ] 戳一戳插件支持
- [x] 设置表情插件支持

View File

@@ -444,7 +444,6 @@ class EmojiManager:
Optional[Tuple[str, str]]: (表情包完整文件路径, 表情包描述)如果没有找到则返回None
"""
try:
self._ensure_db()
_time_start = time.time()
# 获取所有表情包 (从内存缓存中获取)
@@ -661,7 +660,6 @@ class EmojiManager:
"""获取所有表情包并初始化为MaiEmoji类对象更新 self.emoji_objects"""
try:
with get_db_session() as session:
self._ensure_db()
logger.debug("[数据库] 开始加载所有表情包记录 ...")
emoji_instances = session.execute(select(Emoji)).scalars().all()
@@ -692,22 +690,21 @@ class EmojiManager:
"""
try:
with get_db_session() as session:
self._ensure_db()
if emoji_hash:
query = session.execute(select(Emoji).where(Emoji.emoji_hash == emoji_hash)).scalars().all()
else:
logger.warning(
"[查询] 未提供 hash将尝试加载所有表情包建议使用 get_all_emoji_from_db 更新管理器状态。"
)
query = session.execute(select(Emoji)).scalars().all()
if emoji_hash:
query = session.execute(select(Emoji).where(Emoji.emoji_hash == emoji_hash)).scalars().all()
else:
logger.warning(
"[查询] 未提供 hash将尝试加载所有表情包建议使用 get_all_emoji_from_db 更新管理器状态。"
)
query = session.execute(select(Emoji)).scalars().all()
emoji_instances = query
emoji_objects, load_errors = _to_emoji_objects(emoji_instances)
emoji_instances = query
emoji_objects, load_errors = _to_emoji_objects(emoji_instances)
if load_errors > 0:
logger.warning(f"[查询] 加载过程中出现 {load_errors} 个错误。")
return emoji_objects
if load_errors > 0:
logger.warning(f"[查询] 加载过程中出现 {load_errors} 个错误。")
return emoji_objects
except Exception as e:
logger.error(f"[错误] 从数据库获取表情包对象失败: {str(e)}")
@@ -745,7 +742,6 @@ class EmojiManager:
return emoji.description
# 如果内存中没有,从数据库查找
self._ensure_db()
try:
with get_db_session() as session:
emoji_record = session.execute(select(Emoji).where(Emoji.emoji_hash == emoji_hash)).scalar_one_or_none()
@@ -772,7 +768,6 @@ class EmojiManager:
bool: 是否成功删除
"""
try:
self._ensure_db()
# 从emoji_objects中查找表情包对象
emoji = await self.get_emoji_from_manager(emoji_hash)
@@ -812,7 +807,6 @@ class EmojiManager:
bool: 是否成功替换表情包
"""
try:
self._ensure_db()
# 获取所有表情包对象
emoji_objects = self.emoji_objects