Telegram Bot API 9.0.0-beta2 Inline button exception
Hi, i trying the new beta relase for interact with inline buttons but I have some problems:
var iButton = new InlineKeyboardButton();
iButton.Text = "ok";
var iButtons = new InlineKeyboardButton[][]
{ new InlineKeyboardButton[] { iButton }};
var keyboardMarkup = new InlineKeyboardMarkup()
{
InlineKeyboard = iButtons
};
var t = await Bot.SendTextMessage(update.Message.Chat.Id,
"response", replyMarkup: keyboardMarkup);
Exception: {"[Error : 400 : Bad Request: Can't parse inline keyboard button: Text buttons are unallowed in the inline keyboard]"}
If I don't submit the text I have this exception: {"[Error : 400 : Bad Request: Can't parse inline keyboard button: Can't find field "text"]"}
Hi,
you need to specify CallbackData, Url, or SwitchInlineQuery. Didn't interpreted the docs correct.
I'll upload a new beta, with some shorthands
Now you can create single now Keyboards:
var keyboard = new InlineKeyboardMarkup(new InlineKeyboardButton[]
{
"A",
"B"
}
);
or multi row keyboards
var keyboard = new InlineKeyboardMarkup(new []
{
new InlineKeyboardButton[]
{
"A",
"B"
},
new InlineKeyboardButton[]
{
"C",
"D"
}
}
);
or with URLs
var keyboard = new InlineKeyboardMarkup(new []
{
new InlineKeyboardButton[]
{
"A",
"B"
},
new InlineKeyboardButton[]
{
new InlineKeyboardButton
{
Text = "C",
Url = "https://www.nuget.org/packages/Telegram.Bot/"
},
"D"
}
}
);
Hello Sir,
new InlineKeyboardButton { Text = "C", Url = "https://www.nuget.org/packages/Telegram.Bot/" }
This gives error "InlineKeyboardButton" does not contains constructor that takes 0 arguments... I want two url buttons in a row...
@omegalogs4
new InlineKeyboardButton ("C")
{
Url = "https://www.nuget.org/packages/Telegram.Bot/"
}