Merge branch 'dev' of https://github.com/A-Dawn/MaiBot into dev
This commit is contained in:
@@ -56,7 +56,7 @@ BOT_CONFIG_PATH: Path = (CONFIG_DIR / "bot_config.toml").resolve().absolute()
|
||||
MODEL_CONFIG_PATH: Path = (CONFIG_DIR / "model_config.toml").resolve().absolute()
|
||||
LEGACY_ENV_PATH: Path = (PROJECT_ROOT / ".env").resolve().absolute()
|
||||
A_MEMORIX_LEGACY_CONFIG_PATH: Path = (CONFIG_DIR / "a_memorix.toml").resolve().absolute()
|
||||
MMC_VERSION: str = "1.0.0-pre.15"
|
||||
MMC_VERSION: str = "1.0.0-pre.16"
|
||||
CONFIG_VERSION: str = "8.10.15"
|
||||
MODEL_CONFIG_VERSION: str = "1.16.1"
|
||||
|
||||
|
||||
@@ -388,7 +388,6 @@ class EmojiManager:
|
||||
if existing_record := session.exec(statement).first():
|
||||
existing_record.full_path = str(emoji.full_path)
|
||||
existing_record.no_file_flag = False
|
||||
existing_record.is_banned = False
|
||||
existing_record.last_used_time = datetime.now()
|
||||
existing_record.query_count += 1
|
||||
session.add(existing_record)
|
||||
@@ -473,7 +472,6 @@ class EmojiManager:
|
||||
image_record.full_path = str(new_emoji.full_path)
|
||||
image_record.description = new_emoji.description
|
||||
image_record.no_file_flag = False
|
||||
image_record.is_banned = False
|
||||
session.add(image_record)
|
||||
except Exception as exc:
|
||||
logger.error(f"Update cached emoji description failed: {exc}")
|
||||
@@ -531,6 +529,9 @@ class EmojiManager:
|
||||
statement = select(Images).filter_by(image_hash=emoji.file_hash, image_type=ImageType.EMOJI).limit(1)
|
||||
existing_record = session.exec(statement).first()
|
||||
if existing_record:
|
||||
if existing_record.is_banned:
|
||||
logger.info(f"[register_emoji] Emoji is banned, skipping: {emoji.file_hash}")
|
||||
return "skipped"
|
||||
if existing_record.is_registered and _is_available_emoji_record(existing_record):
|
||||
# logger.info(f"[register_emoji] Emoji already registered, skipping: {emoji.file_hash}")
|
||||
return "skipped"
|
||||
@@ -1085,6 +1086,10 @@ class EmojiManager:
|
||||
return "failed"
|
||||
|
||||
if existing_record is not None:
|
||||
if existing_record.is_banned:
|
||||
logger.info(f"[register_emoji] Emoji is banned, skipping: {target_emoji.file_name}")
|
||||
return "skipped"
|
||||
|
||||
if existing_record.is_registered and _is_available_emoji_record(existing_record):
|
||||
logger.info(f"[register_emoji] Emoji already registered, skipping: {target_emoji.file_name}")
|
||||
return "skipped"
|
||||
|
||||
@@ -213,7 +213,7 @@ def resolve_installed_plugin_path(plugin_id: str) -> Optional[Path]:
|
||||
return _resolve_safe_plugin_directory(new_format_path, plugins_dir, strict=True)
|
||||
if old_format_path.exists():
|
||||
return _resolve_safe_plugin_directory(old_format_path, plugins_dir, strict=True)
|
||||
return None
|
||||
return find_plugin_path_by_id(plugin_id)
|
||||
|
||||
|
||||
def parse_repository_url(repository_url: str) -> Tuple[str, str, str]:
|
||||
@@ -256,11 +256,29 @@ def iter_plugin_directories() -> List[Path]:
|
||||
|
||||
|
||||
def find_plugin_path_by_id(plugin_id: str) -> Optional[Path]:
|
||||
casefold_matched_path: Optional[Path] = None
|
||||
normalized_plugin_id = plugin_id.casefold()
|
||||
|
||||
for plugin_path in iter_plugin_directories():
|
||||
manifest_path = resolve_plugin_file_path(plugin_path, "_manifest.json")
|
||||
manifest = load_manifest_json(manifest_path)
|
||||
if manifest is not None and (manifest.get("id") == plugin_id or plugin_path.name == plugin_id):
|
||||
if manifest is None:
|
||||
continue
|
||||
|
||||
manifest_id = str(manifest.get("id", ""))
|
||||
if manifest_id == plugin_id or plugin_path.name == plugin_id:
|
||||
return plugin_path
|
||||
|
||||
if (
|
||||
casefold_matched_path is None
|
||||
and (manifest_id.casefold() == normalized_plugin_id or plugin_path.name.casefold() == normalized_plugin_id)
|
||||
):
|
||||
casefold_matched_path = plugin_path
|
||||
|
||||
if casefold_matched_path is not None:
|
||||
logger.warning(f"插件 ID 大小写不一致,已按大小写不敏感匹配: {plugin_id} -> {casefold_matched_path}")
|
||||
return casefold_matched_path
|
||||
|
||||
return None
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user