fix:偷表情包配置生效
This commit is contained in:
@@ -602,9 +602,9 @@ class EmojiManager:
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
# 检查是否需要处理表情包(数量超过最大值或不足)
|
# 检查是否需要处理表情包(数量超过最大值或不足)
|
||||||
if (self.emoji_num > self.emoji_num_max and global_config.emoji.do_replace) or (
|
if global_config.emoji.steal_emoji and ((self.emoji_num > self.emoji_num_max and global_config.emoji.do_replace) or (
|
||||||
self.emoji_num < self.emoji_num_max
|
self.emoji_num < self.emoji_num_max
|
||||||
):
|
)):
|
||||||
try:
|
try:
|
||||||
# 获取目录下所有图片文件
|
# 获取目录下所有图片文件
|
||||||
files_to_process = [
|
files_to_process = [
|
||||||
|
|||||||
@@ -202,37 +202,37 @@ class ImageManager:
|
|||||||
logger.debug(f"描述是{description}")
|
logger.debug(f"描述是{description}")
|
||||||
|
|
||||||
# 根据配置决定是否保存图片
|
# 根据配置决定是否保存图片
|
||||||
if global_config.emoji.save_pic:
|
|
||||||
# 生成文件名和路径
|
|
||||||
current_timestamp = time.time()
|
|
||||||
filename = f"{int(current_timestamp)}_{image_hash[:8]}.{image_format}"
|
|
||||||
image_dir = os.path.join(self.IMAGE_DIR, "image")
|
|
||||||
os.makedirs(image_dir, exist_ok=True)
|
|
||||||
file_path = os.path.join(image_dir, filename)
|
|
||||||
|
|
||||||
|
# 生成文件名和路径
|
||||||
|
current_timestamp = time.time()
|
||||||
|
filename = f"{int(current_timestamp)}_{image_hash[:8]}.{image_format}"
|
||||||
|
image_dir = os.path.join(self.IMAGE_DIR, "image")
|
||||||
|
os.makedirs(image_dir, exist_ok=True)
|
||||||
|
file_path = os.path.join(image_dir, filename)
|
||||||
|
|
||||||
|
try:
|
||||||
|
# 保存文件
|
||||||
|
with open(file_path, "wb") as f:
|
||||||
|
f.write(image_bytes)
|
||||||
|
|
||||||
|
# 保存到数据库 (Images表)
|
||||||
try:
|
try:
|
||||||
# 保存文件
|
img_obj = Images.get((Images.emoji_hash == image_hash) & (Images.type == "image"))
|
||||||
with open(file_path, "wb") as f:
|
img_obj.path = file_path
|
||||||
f.write(image_bytes)
|
img_obj.description = description
|
||||||
|
img_obj.timestamp = current_timestamp
|
||||||
# 保存到数据库 (Images表)
|
img_obj.save()
|
||||||
try:
|
except Images.DoesNotExist:
|
||||||
img_obj = Images.get((Images.emoji_hash == image_hash) & (Images.type == "image"))
|
Images.create(
|
||||||
img_obj.path = file_path
|
emoji_hash=image_hash,
|
||||||
img_obj.description = description
|
path=file_path,
|
||||||
img_obj.timestamp = current_timestamp
|
type="image",
|
||||||
img_obj.save()
|
description=description,
|
||||||
except Images.DoesNotExist:
|
timestamp=current_timestamp,
|
||||||
Images.create(
|
)
|
||||||
emoji_hash=image_hash,
|
logger.trace(f"保存图片元数据: {file_path}")
|
||||||
path=file_path,
|
except Exception as e:
|
||||||
type="image",
|
logger.error(f"保存图片文件或元数据失败: {str(e)}")
|
||||||
description=description,
|
|
||||||
timestamp=current_timestamp,
|
|
||||||
)
|
|
||||||
logger.trace(f"保存图片元数据: {file_path}")
|
|
||||||
except Exception as e:
|
|
||||||
logger.error(f"保存图片文件或元数据失败: {str(e)}")
|
|
||||||
|
|
||||||
# 保存描述到数据库 (ImageDescriptions表)
|
# 保存描述到数据库 (ImageDescriptions表)
|
||||||
self._save_description_to_db(image_hash, description, "image")
|
self._save_description_to_db(image_hash, description, "image")
|
||||||
|
|||||||
@@ -205,15 +205,6 @@ class EmojiConfig(ConfigBase):
|
|||||||
check_interval: int = 120
|
check_interval: int = 120
|
||||||
"""表情包检查间隔(分钟)"""
|
"""表情包检查间隔(分钟)"""
|
||||||
|
|
||||||
save_pic: bool = True
|
|
||||||
"""是否保存图片"""
|
|
||||||
|
|
||||||
save_emoji: bool = True
|
|
||||||
"""是否保存表情包"""
|
|
||||||
|
|
||||||
cache_emoji: bool = True
|
|
||||||
"""是否缓存表情包"""
|
|
||||||
|
|
||||||
steal_emoji: bool = True
|
steal_emoji: bool = True
|
||||||
"""是否偷取表情包,让麦麦可以发送她保存的这些表情包"""
|
"""是否偷取表情包,让麦麦可以发送她保存的这些表情包"""
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[inner]
|
[inner]
|
||||||
version = "2.9.1"
|
version = "2.10.0"
|
||||||
|
|
||||||
#----以下是给开发人员阅读的,如果你只是部署了麦麦,不需要阅读----
|
#----以下是给开发人员阅读的,如果你只是部署了麦麦,不需要阅读----
|
||||||
#如果你想要修改配置文件,请在修改后将version的值进行变更
|
#如果你想要修改配置文件,请在修改后将version的值进行变更
|
||||||
@@ -114,9 +114,7 @@ working_memory_processor = false # 是否启用工作记忆处理器,不稳定
|
|||||||
max_reg_num = 40 # 表情包最大注册数量
|
max_reg_num = 40 # 表情包最大注册数量
|
||||||
do_replace = true # 开启则在达到最大数量时删除(替换)表情包,关闭则达到最大数量时不会继续收集表情包
|
do_replace = true # 开启则在达到最大数量时删除(替换)表情包,关闭则达到最大数量时不会继续收集表情包
|
||||||
check_interval = 120 # 检查表情包(注册,破损,删除)的时间间隔(分钟)
|
check_interval = 120 # 检查表情包(注册,破损,删除)的时间间隔(分钟)
|
||||||
save_pic = true # 是否保存图片
|
steal_emoji = true # 是否偷取表情包,让麦麦可以将一些表情包据为己有
|
||||||
cache_emoji = true # 是否缓存表情包
|
|
||||||
steal_emoji = true # 是否偷取表情包,让麦麦可以发送她保存的这些表情包
|
|
||||||
content_filtration = false # 是否启用表情包过滤,只有符合该要求的表情包才会被保存
|
content_filtration = false # 是否启用表情包过滤,只有符合该要求的表情包才会被保存
|
||||||
filtration_prompt = "符合公序良俗" # 表情包过滤要求,只有符合该要求的表情包才会被保存
|
filtration_prompt = "符合公序良俗" # 表情包过滤要求,只有符合该要求的表情包才会被保存
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user