该提交实现了完整的ClickUp聊天渠道插件,包含以下核心功能: 1. 基础的@提及提取与格式化能力 2. 账号配对与会话管理 3. 消息流与流式回复支持 4. 重试限流与消息去重 5. 富文本格式转换与内容 sanitize 6. 安全策略与配置校验 7. Webhook接收与自动轮询回退 8. 消息收发、编辑、删除与回复 9. 频道与私信管理、反应功能 10. 完整的状态监控与健康检查
47 lines
1.6 KiB
Python
47 lines
1.6 KiB
Python
import logging
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class ClickUpSecurity:
|
|
def resolve_dm_policy(self) -> dict:
|
|
return {"mode": "open", "allow_from": []}
|
|
|
|
def resolve_dm_policy_for_account(self, account: dict) -> dict:
|
|
mode = account.get("dm_policy", "open")
|
|
return {"mode": mode, "allow_from": account.get("allow_from", [])}
|
|
|
|
async def check_allowlist(self, peer_id: str, channel_type: str) -> bool:
|
|
return True
|
|
|
|
def resolve_require_mention(self, ctx) -> bool | None:
|
|
config = getattr(ctx, "config", {}) if ctx else {}
|
|
channel_id = getattr(ctx, "channel_id", None) if ctx else None
|
|
|
|
if channel_id:
|
|
channels = config.get("channels", {})
|
|
channel_cfg = channels.get(channel_id, {})
|
|
if "require_mention" in channel_cfg:
|
|
return channel_cfg["require_mention"]
|
|
|
|
channel_policy = config.get("channel_policy", "activate_on_mention")
|
|
return channel_policy == "activate_on_mention"
|
|
|
|
def resolve_group_intro_hint(self, ctx) -> str | None:
|
|
return None
|
|
|
|
def resolve_tool_policy(self, ctx) -> dict | None:
|
|
return None
|
|
|
|
def apply_config_fixes(self, config: dict) -> dict:
|
|
return config
|
|
|
|
def collect_warnings(self, config: dict, account_id: str | None = None, account: dict | None = None) -> list[str]:
|
|
warnings = []
|
|
channel_policy = account.get("channel_policy", "") if account else config.get("channel_policy", "")
|
|
|
|
if channel_policy == "always" and not config.get("channels"):
|
|
warnings.append("channelPolicy is 'always' without channels allowlist")
|
|
|
|
return warnings
|