我两次收到相同的消息 [英] I got the same message twice

查看:79
本文介绍了我两次收到相同的消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果新用户开始对话,我使用此代码发送不同的消息:

I used this code to send a different message if a new user start conversation :

IConversationUpdateActivity update = message;
            var client = new ConnectorClient(new Uri(message.ServiceUrl), new MicrosoftAppCredentials());
            if (update.MembersAdded != null && update.MembersAdded.Any())
            {
                foreach (var newMember in update.MembersAdded)
                {
                    if (newMember.Id != message.Recipient.Id)
                    {
                        var reply = message.CreateReply();
                        reply.Text = $"Welcome {newMember.Name}! You are a new member! If you want to see help menu , type : help";
                        client.Conversations.ReplyToActivityAsync(reply);
                    }
                }
            }

我的问题是,当用户单击facebook时:开始使用,此消息出现两次.

My problem is that when a user click in facebook : Get started this message comes twice.

你能帮我吗?

推荐答案

Facebook将该对话本身包含在成员列表中:

Facebook includes the conversation itself in the list of members:

因此,您需要将if语句更改为此:

So you need to change the if statement to this:

if (newMember.Id != message.Recipient.Id && newMember.Id != message.Conversation.Id)
{ 
   // send welcome message

这篇关于我两次收到相同的消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆