ForcePilot/backend/package/yuxi/channel/extensions/slack/commands.py

80 lines
2.5 KiB
Python
Raw Normal View History

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