我想创建一个按钮,当点击按钮用户转到群组电报时。但是不能
使用NetTelegramBotApi; //最后一个版本
class Program
{
private static string Token = "......";
// private static InlineKeyboardMarkup Menu1;
}
public static async Task RunBot()
{
// var keyboardInlineMenu = new InlineKeyboardButton[20][];
.....
.....
....
....
if (text == "/start")
{
// keyboardInlineMenu = new InlineKeyboardButton () {
InlineKeyboardButton[][] buttons = new InlineKeyboardButton[2][];
buttons[0][0] = new InlineKeyboardButton(){Text = " Go to group ", Url = "https://api.telegram.org/......" CallbackData = "Some Callback Data"};
InlineKeyboardMarkup inlineKeyboardMarkup = new InlineKeyboardMarkup() { InlineKeyboard = buttons };
错误(在行按钮[0] [0]中)
对象引用未设置为对象的实例。
答案 0 :(得分:2)
var newMsg = new SendMessage(update.Message.Chat.Id, "msg")
{
ReplyMarkup = new InlineKeyboardMarkup()
{
InlineKeyboard = new[]
{
new[] { new InlineKeyboardButton{Text="A",Url = "http://www.A.com/"}, new InlineKeyboardButton(){Text="B",Url = "http://www.B.com/"} }
}
}
};
await bot.MakeRequestAsync(newMsg);
continue;