我有以下代码,只要用户连接到bot,就会发送消息:
else if (message.Type == ActivityTypes.ConversationUpdate)
{
// Handle conversation state changes, like members being added and removed
// Use Activity.MembersAdded and Activity.MembersRemoved and Activity.Action for info
// Not available in all channels
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("Welcome to the ChatBot! Say a 'Hello'");
client.Conversations.ReplyToActivity(reply);
}
}
}
}
此代码在模拟器上正常工作。但是当谈到Skype和Facebook时,消息会显示两次。 我做错了什么?