2017-01-03 47 views

回答

0

当您拨打SendTextMessageAsync时,您将传递指定“自定义回复键盘”的IReplyMarkup对象。我不太了解Telegram Bot API,但这看起来与您链接的GitHub问题所提及的功能相同。

似乎有several implementations listed in the API documentation。我怀疑要么InlineKeyboardMarkupReplyKeyboardMarkup是你在找什么。

+0

我在寻找ReplyKeyboardMarkup –

0

要创建自定义键盘,您必须发送短信并通过IReplyMarkup。所选选项作为可在OnMessage事件中处理的消息发送。当您将ReplyKeyboardHide设置为回复标记时,您可以隐藏自定义键盘。

下面是一个例子:

private const string FirstOptionText = "First option"; 
private const string SecondOptionText = "Second option"; 

private async void BotClientOnMessage(object sender, MessageEventArgs e) 
{ 
    switch (e.Message.Text) 
    { 
     case FirstOptionText: 
      await BotClient.SendTextMessageAsync(e.Message.Chat.Id, "You chose the first option", replyMarkup:new ReplyKeyboardHide()); 
      break; 
     case SecondOptionText: 
      await BotClient.SendTextMessageAsync(e.Message.Chat.Id, "You chose the second option", replyMarkup:new ReplyKeyboardHide()); 
      break; 

     default: 
      await BotClient.SendTextMessageAsync(e.Message.Chat.Id, "Hi, select an option!", 
       replyMarkup: new ReplyKeyboardMarkup(new[] 
       { 
        new KeyboardButton(FirstOptionText), 
        new KeyboardButton(SecondOptionText), 
       })); 
      break; 
    } 
} 

这里是一个自定义键盘聊天:
enter image description here

下面是聊天,我点击第一个按钮:
enter image description here

我希望这有帮助!