我是电报机器人的新手,我想为我的bot创建自定义键盘,为此目的编写以下代码:
var rkm = new ReplyKeyboardMarkup();
rkm.Keyboard =
new KeyboardButton[][]
{
new KeyboardButton[]
{
new KeyboardButton("1-1"),
new KeyboardButton("1-2")
},
new KeyboardButton[]
{
new KeyboardButton("2")
},
new KeyboardButton[]
{
new KeyboardButton("3-1"),
new KeyboardButton("3-2"),
new KeyboardButton("3-3")
}
};
WebRequest req = WebRequest.Create("https://api.telegram.org/bot" + "282189232:AAGdsdsdsdVOrsxy2rzU75QUAnWL_F2vo" + "/sendMessage?chat_id=" + chat_id + "&text=" + message + "&reply_markup=" + rkm);
req.UseDefaultCredentials = true;
var result = req.GetResponse();
req.Abort();
但是当我在这行中运行这段代码时:
var result = req.GetResponse();
获取此错误:
远程服务器返回一个错误:(400)坏请求。
我怎样才能解决这个问题?
发布于 2017-02-26 11:31:13
正如建议的那样,使用MrRoundRobin库。下面是你要怎么做的:
var keyboard = new ReplyKeyboardMarkup(new [] {
new [] // 1st row
{
new KeyboardButton("1"),
new KeyboardButton("2"),
},
new [] // 2nd row
{
new KeyboardButton("3"),
new KeyboardButton("4"),
}
});
await Bot.SendTextMessageAsync(message.Chat.Id, "Choose", replyMarkup: keyboard);;
https://stackoverflow.com/questions/41957750
复制相似问题