2016-05-31 45 views
2
var connector = new ConnectorClient(); 
List<ChannelAccount> participants = new List<ChannelAccount>(); 
var tBot = new ChannelAccount 
{ 
    ChannelId = "telegram", Address = "9digit", IsBot = true, Id = "salodkid_bot", Name = "salodkid_bot" 
}; 
participants.Add(tBot); 
var tUser = new ChannelAccount 
{ 
    ChannelId = "telegram", Address = "9digit", IsBot = false, Id = "dsalodki", Name = "dsalodki" 
}; 
participants.Add(tUser); 
Message message = new Message 
{ 
    From = tBot, 
    To = tUser, 
    Participants = participants.ToArray(), 
    Text = "Hey, what's up everyone?", 
    Language = "en" 
}; 
var obj = connector.Messages.SendMessage(message); 

未處理的異常:Microsoft.Rest.HttpOperationException:殭屍......不匹配:...到...錯誤試圖在電報發送消息博特框架

怎麼了?

回答

1

的Message.From.Address字段需要包含機器人ID,像這樣:

var tBot = new ChannelAccount 
{ 
    ChannelId = "telegram", Address = "salodkid_bot", IsBot = true, Id = "salodkid_bot", Name = "salodkid_bot" 
};