如何创建 InlineKeyboardMarkup 这个例子? [英] How to create InlineKeyboardMarkup this example?

查看:47
本文介绍了如何创建 InlineKeyboardMarkup 这个例子?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个按钮,当单击按钮时,用户会转到组电报.但不能

I want to create a Button that when Click on button user go to the group telegram. but cann`t

使用 NetTelegramBotApi;//最后一个版本

using NetTelegramBotApi; // last verion

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])

Error (in line buttons[0][0] )

未将对象引用设置为对象的实例.

Object reference not set to an instance of an object.

推荐答案

 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;

这篇关于如何创建 InlineKeyboardMarkup 这个例子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆