mirror of https://github.com/Mai-with-u/MaiBot.git
fix: 修复 emoji 管理器中的一个 bug
parent
2ccd2a533f
commit
71e485ae76
|
|
@ -709,36 +709,36 @@ class EmojiManager:
|
||||||
return emoji
|
return emoji
|
||||||
return None # 如果循环结束还没找到,则返回 None
|
return None # 如果循环结束还没找到,则返回 None
|
||||||
|
|
||||||
async def get_emoji_tag_by_hash(self, emoji_hash: str) -> Optional[str]:
|
async def get_emoji_tag_by_hash(self, emoji_hash: str) -> Optional[List[str]]:
|
||||||
"""根据哈希值获取已注册表情包的描述
|
"""根据哈希值获取已注册表情包的情感标签列表
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
emoji_hash: 表情包的哈希值
|
emoji_hash: 表情包的哈希值
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Optional[str]: 表情包描述,如果未找到则返回None
|
Optional[List[str]]: 情感标签列表,如果未找到则返回None
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
# 先从内存中查找
|
# 先从内存中查找
|
||||||
emoji = await self.get_emoji_from_manager(emoji_hash)
|
emoji = await self.get_emoji_from_manager(emoji_hash)
|
||||||
if emoji and emoji.emotion:
|
if emoji and emoji.emotion:
|
||||||
logger.info(f"[缓存命中] 从内存获取表情包描述: {emoji.emotion}...")
|
logger.info(f"[缓存命中] 从内存获取表情包情感标签: {emoji.emotion}...")
|
||||||
return ",".join(emoji.emotion)
|
return emoji.emotion
|
||||||
|
|
||||||
# 如果内存中没有,从数据库查找
|
# 如果内存中没有,从数据库查找
|
||||||
self._ensure_db()
|
self._ensure_db()
|
||||||
try:
|
try:
|
||||||
emoji_record = Emoji.get_or_none(Emoji.emoji_hash == emoji_hash)
|
emoji_record = Emoji.get_or_none(Emoji.emoji_hash == emoji_hash)
|
||||||
if emoji_record and emoji_record.emotion:
|
if emoji_record and emoji_record.emotion:
|
||||||
logger.info(f"[缓存命中] 从数据库获取表情包描述: {emoji_record.emotion[:50]}...")
|
logger.info(f"[缓存命中] 从数据库获取表情包情感标签: {emoji_record.emotion[:50]}...")
|
||||||
return emoji_record.emotion
|
return emoji_record.emotion.split(',')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"从数据库查询表情包描述时出错: {e}")
|
logger.error(f"从数据库查询表情包情感标签时出错: {e}")
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"获取表情包描述失败 (Hash: {emoji_hash}): {str(e)}")
|
logger.error(f"获取表情包情感标签失败 (Hash: {emoji_hash}): {str(e)}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
async def get_emoji_description_by_hash(self, emoji_hash: str) -> Optional[str]:
|
async def get_emoji_description_by_hash(self, emoji_hash: str) -> Optional[str]:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue