c# - 文本c#下方的电报按钮
问题描述
bot中的电报文本下方有按钮我该怎么做?这是我能提供的关于这个的最大信息,因为我不知道它叫什么或什么。 在此处输入图像描述
var new_keyboard = new InlineKeyboardMarkup(
new[]
{
new[]
{
new InlineKeyboardButton("step_1","step1") ,
},
new[]
{
new InlineKeyboardButton("step_2","step2"),
new InlineKeyboardButton("step_3","step3"),
},
new[]
{
new InlineKeyboardButton("step_4","step4"),
}
});
api.EditMessageReplyMarkupAsync(chatid, messageid, replyMarkup: new_keyboard);
解决方案
文本消息下方的按钮称为InlineKeyboardMarkup
,您可以使用方法传递它SendTextMessageAsync
,或者默认为空,如下所示:
private void bot_OnMessage(object sender, MessageEventArgs msg)
{
// Defining InlineKeyboardButtons
List<List<InlineKeybordButton>> buttons = new List<List<InlineKeybordButton>>(/*Two button lines!*/2);
// Defining Rows (As List of buttons)
List<InlineKeybordButton> row1 = new List<InlineKeybordButton>(/*One button in first row!*/1);
List<InlineKeybordButton> row2 = new List<InlineKeybordButton>(/*One button in second row!*/1);
// Adding buttons to the rows:
row1.Add(InlineKeyboardButton.WithUrl("Google", "https://www.google.com/"));
row2.Add(InlineKeyboardButton.WithUrl("Bing", "https://www.bing.com/"));
// Adding rows to the list:
buttons.Add(row1);
buttons.Add(row2);
// HERE:
// Inline Keyboard
InlineKeyboardMarkup keyboard = new InlineKeyboardMarkup(buttons);
bot.SendTextMessageAsync(msg.Chat, "Some text...", replyMarkup: keyborad);
}
推荐阅读
- cmake - 修改缓存变量后重新生成 cmake 文件的正确方法是什么?
- haskell - In Haskell, why is this a valid expression?
- python - TypeError in Recursive Function (Decimal to Binary)
- python - 使用 JsonCpp 通过 pybind11 将数据返回给 python 在 python 调用中产生 Symbol not found 错误
- r - 在ggplot中绘制线条我得到x轴长度错误
- python - 使用 Python 将带分隔符的文本文件读取到 sqlite
- c - Why does sqrt function not work for values taken through user input?
- vim - How to (with good asymptotic complexity) delete all of a specific character from a (very long) line?
- python - django.db.utils.OperationalError:外键不匹配 - “django_admin_log”引用“transcript_userprofile”
- java - Necessity of storing variables in Firebase Database