Update emoji_manager.py

This commit is contained in:
雅诺狐
2025-08-17 13:59:09 +08:00
committed by Windpicker-owo
parent 55a25d071a
commit 762cdf327b

View File

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