如何使用 C# 使键盘按钮消息文本与其在 Telegram bot API 中的标题不同 [英] How to make Keyboard Button message text different from its caption in Telegram bot API using C#

查看:38
本文介绍了如何使用 C# 使键盘按钮消息文本与其在 Telegram bot API 中的标题不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要我的机器人打印与其标题不同的消息(由电报客户端在键盘按钮元素上显示).

I need my bot to print a different message than its caption (which shows by telegram client on keyboard button element).

我的自定义按钮有这样的文字:我在哪里?",当我点击它时,它也会在屏幕上打印我在哪里?".我希望按钮打印 "/location".(与它的 text 字段不同)

My custom button has this text: "Where am I?" and when I click on it, it prints on the screen "Where am I?" also. I want the button to print "/location".(something different from its text field)

我怎样才能实现它?我正在使用 C#Telegram Bot API

How can I achieve it? I'm using C# and Telegram Bot API

我想要的:

  • 当用户点击此按钮时,电报客户端发送带有 /age [作为他输入的消息] 的消息,但 NOT 发送 show my age(即按钮 text 字段)
  • When the user clicks this button, telegram client send a messages with /age [as his typed message] but NOT send show my age (which is that button text field )

所以:我想要一个带有 text 的按钮.当用户单击按钮时,我希望发送的消息与 text 不同.

So: I want a button with a text . when the user clicks the button I want the message sent to be different from that text.

推荐答案

位置有一个布尔值字段,您是否将其设置为 true?https://core.telegram.org/bots/api#keyboardbutton

There is a boolean field for location, did you set it to true? https://core.telegram.org/bots/api#keyboardbutton

更新:当您向用户发送回复时,您也在发送 ReplyKeyboardMarkup.ReplyKeyboardMarkup 有一个名为keyboard 的字段,它是KeyboardButton Array 的Array.在每个 KeyboardButton 上,您都有一个用于位置的 bool,如果您希望该按钮发送位置,则需要将其设置为 true

Update: hen you are sending a reply to the user, you are also sending a ReplyKeyboardMarkup. ReplyKeyboardMarkup has a field called keyboard which is Array of Array of KeyboardButton. on each KeyboardButton you have a bool for location that you need to set to true if you want that button to send the location

更新 2

不可能有与您的文本不同的消息.文本-​​字符串->按钮的文本.如果未使用任何可选字段,则按下按钮时,它将作为消息发送给机器人

it is not possible to have a message different than your text. text- String->Text of the button. If none of the optional fields are used, it will be sent to the bot as a message when the button is pressed

这篇关于如何使用 C# 使键盘按钮消息文本与其在 Telegram bot API 中的标题不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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