c# - Telegram 有办法用 Bot Framework 显示轮播吗?

标签 c# botframework telegram

我正在使用 Microsoft Bot Framework 开发一个机器人,在 Facebook Messenger 上,轮播按其应有的方式显示,但在 Telegram 中,它在两条不同的消息上显示为 2 张不同的卡片。

Telegram 不支持轮播还是我的错?

代码:

    public async Task Carousel(IDialogContext context, IAwaitable<IMessageActivity> activity)
    {
        var act = await activity;
        //carousel
        var replyToConversation = context.MakeMessage();
        replyToConversation.Text = "2+ Cards are a Carousel";
        replyToConversation.Recipient = message.From;
        replyToConversation.Type = "message";
        replyToConversation.Attachments = new List<Attachment>();
        //1
        List<CardImage> cardImages = new List<CardImage>();
        cardImages.Add(new CardImage(url: "https://upload.wikimedia.org/wikipedia/commons/thumb/c/c0/Asimo_look_new_design.jpg/330px-Asimo_look_new_design.jpg"));
        List<CardAction> cardButtons = new List<CardAction>();
        CardAction plButton = new CardAction()
        {
            Value = "https://en.wikipedia.org/wiki/Robot",
            Type = "openUrl",
            Title = "WikiPedia Page"
        };
        cardButtons.Add(plButton);
        HeroCard plCard = new HeroCard()
        {
            Title = "I'm a hero card",
            Subtitle = "Robot Wikipedia Page",
            Images = cardImages,
            Buttons = cardButtons
        };
        Attachment plAttachment = plCard.ToAttachment();
        replyToConversation.Attachments.Add(plAttachment);
        //2
        List<CardImage> cardImages2 = new List<CardImage>();
        cardImages2.Add(new CardImage(url: "https://upload.wikimedia.org/wikipedia/en/thumb/9/9b/FANUC_6-axis_welding_robots.jpg/330px-FANUC_6-axis_welding_robots.jpg"));
        List<CardAction> cardButtons2 = new List<CardAction>();
        CardAction plButton2 = new CardAction()
        {
            Value = "https://en.wikipedia.org/wiki/Robot",
            Type = "openUrl",
            Title = "WikiPedia Page"
        };
        cardButtons2.Add(plButton);
        HeroCard plCard2 = new HeroCard()
        {
            Title = "I'm a hero card",
            Subtitle = "Robot Wikipedia Page",
            Images = cardImages2,
            Buttons = cardButtons2
        };
        Attachment plAttachment2 = plCard2.ToAttachment();
        replyToConversation.AttachmentLayout = AttachmentLayoutTypes.Carousel;
        replyToConversation.Attachments.Add(plAttachment2);
        await context.PostAsync(replyToConversation);
    }

最佳答案

这不是你的错。根据 Channel Inspector ,Telegram 中的轮播具有向下渲染的外观。

关于c# - Telegram 有办法用 Bot Framework 显示轮播吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42486168/

相关文章:

php - 如何通过 Telegram 机器人发送自定义表情符号?

c# - 将文件下载到 Azure 函数应用程序进行操作

c# - C#中超出基本类型的数字

node.js - Azure Bot - 通过 REST API 进行通信

node.js - 如果用户响应无效值,则 Azure Botframework : How to re-prompt the Prompt. 文本

azure - 处理 directline Tokens 及其 "expires_in"

bots - 如何将机器人添加到 Telegram 群组?

api - 如何在 Telegram 中获取电话号码的user_id

c# - 使用来自其他类 C# 的字符串

c# - 这是在 C# 中无需空检查的情况下触发/调用事件的更好方法吗?