I am new to telegram bot programming. I want to add two inline buttons, but I just know how to add one:
StringBuilder sb = new StringBuilder();
sb.AppendLine("Some websites:");
InlineKeyboardButton urlButton = new InlineKeyboardButton();
InlineKeyboardMarkup inline = new InlineKeyboardMarkup(urlButton);
urlButton.Text = "Go URL1";
urlButton.Url = "https://www.google.com/";
bot.SendTextMessageAsync(chatId, sb.ToString(), ParseMode.Html, true, false, 0, inline);
How is it possible add one or more buttons?
2
Answers
You can do it by pass
IEnumerable<InlineKeyboardButton>
toInlineKeyboardMarkup
Like ineasted of passInlineKeyboardButton
like this this:And you can control How many buttons in every row By Passing
IEnumerable<IEnumerable<InlineKeyboardButton>>
toInlineKeyboardMarkup
constructor And Every IEnumerable it will be a single row like this:And this Is the result in second time:
More simpler compact syntax: