如何使用InlineKeyboardButton电报编写inlineKeyboard?

时间:2016-06-26 12:57:41

标签: telegram-bot

我正在尝试为电报机器人编写内联键盘。我阅读了文档,但我什么也得不到。

InlineKeyboardButton WeightMenu = new InlineKeyboardButton("2 Kilograms", "2");

我写了这个,但我不知道如何将它发送给用户?

为什么电报文件中没有任何代码片段? 有代码示例的源代码吗?

2 个答案:

答案 0 :(得分:1)

直到现在我得到这个: 但钢铁我不知道如何将其发送给用户?

using Telegram.Bot.Types;
 InlineKeyboardButton inlineKey1 = new InlineKeyboardButton("inlineKey1");
                        InlineKeyboardButton inlineKey2 = new InlineKeyboardButton("inlineKey2");
                        InlineKeyboardButton inlineKey3 = new InlineKeyboardButton("inlineKey3");
                        InlineKeyboardButton[] inlineKeyraw = { inlineKey1, inlineKey2, inlineKey3 };
                        InlineKeyboardMarkup inlineKeyboards = new InlineKeyboardMarkup(inlineKeyraw)
                        {

                        };

答案 1 :(得分:0)

您可以使用此代码将内联键盘发送给用户:

var inlineKeyboardMarkup = new InlineKeyboardMarkup
{
    InlineKeyboard = new []
    {
        new [] { new InlineKeyboardButton { Text = "Inline Keyboard button", CallbackData = "demo", Url = ""} }
    }
};
var newmsg = new SendMessage(update.Message.Chat.Id, "<b>check my new inline keyboard</b>")
{
    ReplyMarkup = inlineKeyboardMarkup,
    ParseMode = SendMessage.ParseModeEnum.HTML,DisableNotification = false,DisableWebPagePreview = false
};
WriteMessageToConsole(update.Message.Chat.Id, "_check my new inline keyboard_");
bot.MakeRequestAsync(newmsg).Wait();