"""Microsoft Teams 欢迎卡片。 在 Bot 被添加到个人或群组对话时发送欢迎卡片,支持自定义 prompt starters。 """ from __future__ import annotations from typing import Any def build_personal_welcome_card( bot_name: str = "ForcePilot", subtitle: str = "你好!我是你的智能助手,可以帮你回答问题、处理数据、管理任务。", prompt_starters: list[str] | None = None, ) -> dict[str, Any]: starters = prompt_starters or [ "你能做什么?", "帮我总结今天的要点", "查看我的会话上下文", ] body: list[dict[str, Any]] = [ { "type": "TextBlock", "size": "Large", "weight": "Bolder", "text": f"欢迎使用 {bot_name}", }, { "type": "TextBlock", "text": subtitle, "wrap": True, "spacing": "Medium", }, { "type": "TextBlock", "text": "试试这些:", "spacing": "Medium", "isSubtle": True, }, ] for i, starter in enumerate(starters[:3]): body.append( { "type": "TextBlock", "text": f"{i + 1}. {starter}", "wrap": True, "spacing": "Small", } ) return { "type": "AdaptiveCard", "version": "1.5", "body": body, } def build_group_welcome_message(bot_name: str = "ForcePilot") -> str: return ( f"大家好!我是 **{bot_name}**,已加入此对话。\n\n" "你可以 @提及 我或直接向我发送消息来获得帮助。\n\n" "发送 `/help` 查看可用命令。" ) def build_welcome_response( conversation_type: str, bot_name: str, prompt_starters: list[str] | None = None, ) -> dict[str, Any]: if conversation_type == "personal": card = build_personal_welcome_card( bot_name=bot_name, prompt_starters=prompt_starters, ) return { "type": "card", "content": f"欢迎使用 {bot_name}", "adaptive_card": card, } return { "type": "text", "content": build_group_welcome_message(bot_name), }