ForcePilot/backend/package/yuxi/channel/extensions/slack/commands.py
Kris bfc7755137 feat(channel): 添加 Slack 渠道扩展
新增 Slack 渠道扩展,支持在 Yuxi 平台中集成 Slack 团队协作平台。

包含以下功能模块:
- config: 渠道配置管理
- gateway: SSE/WebSocket 网关接入
- outbound: 外发消息管理
- streaming: 流式消息处理
- pairing: 用户配对与绑定
- security: 安全校验
- monitor: 渠道状态监控
- status: 会话状态管理
- actions: 交互动作处理
- interactive: 交互式消息
- commands: 斜杠指令
- threading: 线程管理
- mentions: @提及
- constants: 常量定义
- types: 类型定义
2026-05-21 11:43:23 +08:00

80 lines
2.5 KiB
Python

from yuxi.channel.protocols import ChannelCommand
class SlackCommands:
enforce_owner_for_commands = False
skip_when_config_empty = True
native_commands_auto_enabled = False
native_skills_auto_enabled = False
def get_commands(self) -> list[ChannelCommand]:
return [
ChannelCommand(
name="help",
aliases=["h"],
description="显示帮助信息",
usage="/help",
handler="help",
),
ChannelCommand(
name="reset",
aliases=["agentstatus"],
description="重置当前会话",
usage="/reset",
handler="reset",
),
]
async def handle_command(self, config: dict, command_name: str, args: list[str], msg, ctx) -> str:
match command_name:
case "help":
return self._handle_help(config)
case "reset":
return self._handle_reset(config)
case _:
return f"未知命令: {command_name}"
def _handle_help(self, config: dict) -> str:
return (
"*ForcePilot Slack Bot 帮助*\n"
"• `/help` — 显示此帮助信息\n"
"• `/reset` — 重置当前会话\n"
"• 在频道中使用 @提及 来触发我\n"
"• 直接私信我可以进行一对一对话"
)
def _handle_reset(self, config: dict) -> str:
return "会话已重置。请发送新消息开始对话。"
def resolve_native_command_name(self, command_key: str, default_name: str) -> str | None:
if command_key == "reset":
return "agentstatus"
return default_name
def build_commands_list_channel_data(self, current_page: int, total_pages: int, agent_id: str | None = None):
return None
def build_models_menu_channel_data(self, providers: list[dict]):
return None
def build_models_provider_channel_data(self, providers: list[dict]):
return None
def build_models_add_provider_channel_data(self, providers: list[dict]):
return None
def build_models_list_channel_data(
self,
provider: str,
models: list[str],
current_model: str | None = None,
current_page: int = 0,
total_pages: int = 0,
page_size: int | None = None,
model_names: dict | None = None,
):
return None
def build_model_browse_channel_data(self):
return None