1

我正在使用Microsoft BotFramework开发Bots Project ,因为我正在使用它来显示一些视频文件。在这里我面临的问题是,当我在本地 Bot Frame work Emulator 中运行我的项目时,它每次都能正确获取数据,并且我正在将我的 Bot 配置到 Skype 频道,它第一次正常工作,当我第二次使用它时有时没有获取数据,有时它获取的数据就像只有一个视频文件一样,只不过是第一个视频文件。是否有任何适当的解决方案可以每次获取完整数据?为此,我在我的方法中编写了以下代码行

Activity replyToConversation = message.CreateReply("Welcome to **My Bot**." + "(Hi)");
        replyToConversation.Recipient = message.From;
        replyToConversation.Type = "message";
        replyToConversation.Attachments = new List<Attachment>();
        Dictionary<string, string> cardContentList = new Dictionary<string, string>();
        cardContentList.Add("Jason Bourne", "");
        cardContentList.Add("The Land", "");
        cardContentList.Add("Yoga Hosers", "");
        foreach (KeyValuePair<string, string> cardContent in cardContentList)
        {
            if (cardContent.Key == "Jason Bourne")
            {
                replyToConversation.Attachments.Add(new Attachment()
                {
                    ContentUrl = "https://ht39ea-bn1306.files.1drv.com/y3mz35iB6o_EJVzJvmSQz9_jNz5Cmpk33LgbGJQjpoZvQaBXrABBDvHrOS5gdHvqh_MIlJoFBIujrSkhkCGRnApldRbmT6W61NTEyOulUGUZtge9hRyKKvh9BHT-VYV_opRLSMnHt7g3b3IaiTNKcjZqQ/Jason%20Bourne%20Official%20Trailer%20%231%20(2016",
                    Name = "Jason Bourne"
                                      });
            }
            else if (cardContent.Key == "The Land")
            {
                replyToConversation.Attachments.Add(new Attachment()
                {
                    ContentUrl = "https://ht39ea-bn1306.files.1drv.com/y3mGspCfSmGDdvQjKK_3UcUIdnZRsAC2jRgHesmL61sIV_zc9F9UQQIWkyHE5E4t6r4T56aWKDQSfN-qduP2VJbiH0rYZ4Ce5DLI2U1DKx-4Tv4UB4OL2Egtk_-BWAow0fC4wf7HCC2ypyQ2dIXrs1hsw/The%20Land%20Official%20Trailer%201%20(2016",

                    ContentType = "video/mp4",
                    Name = "The Land"
                });
            }
            else if (cardContent.Key == "Yoga Hosers")
            {
                replyToConversation.Attachments.Add(new Attachment()
                {
                    ContentUrl = "https://ht39ea-bn1306.files.1drv.com/y3mThBzywEPjMFSh2rdNldHPW1oxtzVTXyrhLrJOp_ACh2YPLQcuw5W-MaSB_5DBJluNXJpvwWBcoWKcQO6Ijx7dWcj2MqHA2uFvvbH6h7mPKsiBhDuC8j5I4_qi-ZsdMuM2G6ztoUtAsdRV0pla-aOGQ/Yoga%20Hosers%20TRAILER%20(2016",

                    ContentType = "video/mp4",
                    Name = "Yoga Hosers"
                });
            }
        }
        replyToConversation.AttachmentLayout = AttachmentLayoutTypes.List;
        await context.PostAsync(replyToConversation);
4

1 回答 1

0

两个问题。首先,“Jason Bourne”项目缺少 ContentType 字段,因此帖子被拒绝。其次,提供的链接似乎无效或不公开。如果我添加 ContentType 字段并换出它可以找到的链接。

 Activity replyToConversation = message.CreateReply("Welcome to **My Bot**." + "(Hi)");
        replyToConversation.Recipient = message.From;
        replyToConversation.Type = "message";
        replyToConversation.Attachments = new List<Attachment>();
        Dictionary<string, string> cardContentList = new Dictionary<string, string>();
        cardContentList.Add("Jason Bourne", "");
        cardContentList.Add("The Land", "");
        cardContentList.Add("Yoga Hosers", "");
        foreach (KeyValuePair<string, string> cardContent in cardContentList)
        {
            if (cardContent.Key == "Jason Bourne")
            {
                replyToConversation.Attachments.Add(new Attachment()
                {
                    ContentUrl = "http://www.sample-videos.com/video/mp4/240/big_buck_bunny_240p_1mb.mp4",
                    ContentType = "video/mp4",  // NEW LINE
                    Name = "Jason Bourne"
                });
            }
            else if (cardContent.Key == "The Land")
            {
                replyToConversation.Attachments.Add(new Attachment()
                {
                    ContentUrl = "http://www.sample-videos.com/video/mp4/240/big_buck_bunny_240p_1mb.mp4",

                    ContentType = "video/mp4",
                    Name = "The Land"
                });
            }
            else if (cardContent.Key == "Yoga Hosers")
            {
                replyToConversation.Attachments.Add(new Attachment()
                {
                    ContentUrl = "http://www.sample-videos.com/video/mp4/240/big_buck_bunny_240p_1mb.mp4",

                    ContentType = "video/mp4",
                    Name = "Yoga Hosers"
                });
            }
        }
        replyToConversation.AttachmentLayout = AttachmentLayoutTypes.List;
于 2016-08-04T20:19:36.710 回答