mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 07:27:15 +08:00
Merge remote-tracking branch 'origin/v3' into v3
# Conflicts: # app/api/endpoints/agent.py # app/api/endpoints/anthropic.py # app/api/endpoints/openai.py # app/chain/__init__.py # app/chain/message.py # app/chain/site.py # app/chain/subscribe.py # app/chain/transfer.py # app/modules/discord/__init__.py # app/modules/qqbot/__init__.py # app/modules/slack/__init__.py # app/modules/telegram/__init__.py # app/modules/wechat/__init__.py # app/runtime/extensions/module_manager.py # app/runtime/extensions/service_registry.py # tests/test_agent_interaction.py # tests/test_slash_command_interactions.py # tests/test_web_agent_stream.py
This commit is contained in:
@@ -9,7 +9,7 @@ from app.application.messaging.agent import (
|
||||
resolve_config_principal_ids,
|
||||
)
|
||||
from app.runtime.log import logger
|
||||
from app.modules import _ModuleBase, _MessageBase
|
||||
from app.modules._base import _MessageChannelModuleBase
|
||||
from app.modules.vocechat.vocechat import VoceChat
|
||||
from app.schemas import NotificationChannel, IncomingMessage, Message
|
||||
from app.schemas.types import ModuleType
|
||||
@@ -21,7 +21,9 @@ register_channel_admin_resolver(
|
||||
)
|
||||
|
||||
|
||||
class VoceChatModule(_ModuleBase, _MessageBase[VoceChat]):
|
||||
class VoceChatModule(_MessageChannelModuleBase[VoceChat]):
|
||||
# 管理员配置键,与渠道 resolver 保持一致
|
||||
_admin_config_key = "VOCECHAT_ADMINS"
|
||||
_IMAGE_SUFFIXES = (
|
||||
".png",
|
||||
".jpg",
|
||||
@@ -83,51 +85,9 @@ class VoceChatModule(_ModuleBase, _MessageBase[VoceChat]):
|
||||
def stop(self):
|
||||
pass
|
||||
|
||||
def test(self) -> Optional[Tuple[bool, str]]:
|
||||
"""
|
||||
测试模块连接性
|
||||
"""
|
||||
if not self.get_instances():
|
||||
return None
|
||||
for name, client in self.get_instances().items():
|
||||
state = client.get_state()
|
||||
if not state:
|
||||
return False, f"VoceChat {name} 未就绪"
|
||||
return True, ""
|
||||
|
||||
def init_setting(self) -> Tuple[str, Union[str, bool]]:
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def _get_admins(config: Optional[dict]) -> List[str]:
|
||||
"""
|
||||
解析 VoceChat 管理员配置,兼容逗号分隔和首尾空白。
|
||||
"""
|
||||
return [
|
||||
admin.strip()
|
||||
for admin in str((config or {}).get("VOCECHAT_ADMINS") or "").split(",")
|
||||
if admin.strip()
|
||||
]
|
||||
|
||||
@classmethod
|
||||
def _should_reject_admin_command(
|
||||
cls,
|
||||
config: Optional[dict],
|
||||
*user_ids: Optional[Union[str, int]],
|
||||
) -> bool:
|
||||
"""
|
||||
判断 VoceChat 斜杠命令是否应因非管理员身份被拒绝。
|
||||
"""
|
||||
admins = cls._get_admins(config)
|
||||
if not admins:
|
||||
return False
|
||||
candidates = [
|
||||
str(user_id).strip()
|
||||
for user_id in user_ids
|
||||
if user_id is not None and str(user_id).strip()
|
||||
]
|
||||
return not any(candidate in admins for candidate in candidates)
|
||||
|
||||
@staticmethod
|
||||
def _send_admin_denied(
|
||||
client: Optional[VoceChat], userid: Optional[Union[str, int]]
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
schema_version = 1
|
||||
id = "VoceChatModule"
|
||||
kind = "host_module"
|
||||
entrypoint = "app.modules.vocechat:VoceChatModule"
|
||||
depends_on = []
|
||||
|
||||
[metadata]
|
||||
name = "VoceChat"
|
||||
type = "notification"
|
||||
subtype = "VoceChat"
|
||||
priority = 4
|
||||
|
||||
[activation]
|
||||
policy = "when_configured"
|
||||
watch = ["Notifications"]
|
||||
|
||||
[activation.selector]
|
||||
kind = "system_config_item"
|
||||
key = "Notifications"
|
||||
match_field = "type"
|
||||
match_value = "vocechat"
|
||||
enabled_field = "enabled"
|
||||
Reference in New Issue
Block a user