我正在给机器人写电报。我遇到了这样的问题。我需要机器人在点击复制它的消息(文本)时发送消息(文本)(作为来自@Bot神父的令牌)。
发布于 2020-01-13 10:38:20
如果我正确地理解了您,您希望发送一条信息,当用户按下它时,文本会自动复制到用户的剪贴板上,就像BotFather发送API令牌一样?
这是由MarkDown parse_mode
完成的;
用&parse_mode=MarkDown
发送一条消息,并将“可按压”的文本用倒计时(`
)包装:
Hi. `Press me!`!
https://api.telegram.org/bot<token>/sendMessage?chat_id=<id>&text=Hi! `Press me!`&parse_mode=MarkDown
编辑:基于OP的评论,您正在寻找python-电报-bot解决方案。
从那里文档;
bot.send_message(
chat_id=chat_id,
text="*bold* _italic_ `fixed width font` [link](http://google.com).",
parse_mode=telegram.ParseMode.MARKDOWN
)
发布于 2021-01-29 16:41:59
您可以简单地通过以下方式编辑文本--写`‘,然后写文本,然后再写那3个字符。宾果!
发布于 2022-08-25 13:36:13
这个解决方案适用于我的Telegram Android客户端以及windows的Telegram Desktop客户端。
bot = telebot.TeleBot(bot_token) #where bot_token is your unique identifier
text = "`" + text + "`" #now make sure the text has the backticks (leading and ending).
然后确保将解析模式设置为标记(我使用的是V2)
bot.send_message(bot_chat_id, text, parse_mode='MarkdownV2') #chat_id is another unique identifier
我给自己发了一个信息来证明:
只要点击一下消息,它就会被复制到剪贴板上!
https://stackoverflow.com/questions/59713920
复制相似问题