feat: 现在可以设置是否自动保存表情包了
This commit is contained in:
@@ -20,6 +20,7 @@ ban_words = [
|
||||
[emoji]
|
||||
check_interval = 120 # 检查表情包的时间间隔
|
||||
register_interval = 10 # 注册表情包的时间间隔
|
||||
auto_save = true # 自动偷表情包
|
||||
check_prompt = "不要包含违反公序良俗的内容" # 表情包过滤要求
|
||||
|
||||
[cq_code]
|
||||
|
||||
@@ -30,6 +30,7 @@ class BotConfig:
|
||||
forget_memory_interval: int = 300 # 记忆遗忘间隔(秒)
|
||||
EMOJI_CHECK_INTERVAL: int = 120 # 表情包检查间隔(分钟)
|
||||
EMOJI_REGISTER_INTERVAL: int = 10 # 表情包注册间隔(分钟)
|
||||
EMOJI_SAVE: bool = True # 偷表情包
|
||||
EMOJI_CHECK_PROMPT: str = "不要包含违反公序良俗的内容" # 表情包过滤要求
|
||||
|
||||
ban_words = set()
|
||||
@@ -96,6 +97,7 @@ class BotConfig:
|
||||
config.EMOJI_CHECK_INTERVAL = emoji_config.get("check_interval", config.EMOJI_CHECK_INTERVAL)
|
||||
config.EMOJI_REGISTER_INTERVAL = emoji_config.get("register_interval", config.EMOJI_REGISTER_INTERVAL)
|
||||
config.EMOJI_CHECK_PROMPT = emoji_config.get('check_prompt',config.EMOJI_CHECK_PROMPT)
|
||||
config.EMOJI_SAVE = emoji_config.get('auto_save',config.EMOJI_SAVE)
|
||||
|
||||
if "cq_code" in toml_dict:
|
||||
cq_code_config = toml_dict["cq_code"]
|
||||
|
||||
@@ -4,6 +4,7 @@ import hashlib
|
||||
import time
|
||||
import os
|
||||
from ...common.database import Database
|
||||
from ..chat.config import global_config
|
||||
import zlib # 用于 CRC32
|
||||
import base64
|
||||
from nonebot import get_driver
|
||||
@@ -143,6 +144,8 @@ def storage_emoji(image_data: bytes) -> bytes:
|
||||
Returns:
|
||||
bytes: 原始图片数据
|
||||
"""
|
||||
if not global_config.EMOJI_SAVE:
|
||||
return image_data
|
||||
try:
|
||||
# 使用 CRC32 计算哈希值
|
||||
hash_value = format(zlib.crc32(image_data) & 0xFFFFFFFF, 'x')
|
||||
|
||||
Reference in New Issue
Block a user