How to make that when you click on the text it was copied pytelegrambotapi

DanDyFun picture DanDyFun · Jan 13, 2020 · Viewed 7.1k times · Source

I am writing a telegram to the bot. I ran into such a problem. I need the bot to send a message (text) when clicked on which it was copied (as a token from @BotFather)

Answer

0stone0 picture 0stone0 · Jan 13, 2020

If I understand you correctly, you wish to send a message, that if the user pressed, the text is automaticlly copied to the user's clipboard, just like the botfather sends the API token?

enter image description here

This is done by the MarkDown parse_mode; Send a message with &parse_mode=MarkDown and wrap the 'pressable' text in backticks: ' ` '

Hi. `Press me!`!
https://api.telegram.org/bot<token>/sendMessage?chat_id=<id>&text=Hi! `Press me!`&parse_mode=MarkDown

enter image description here

EDIT: Bases on your comment you're looking for a python-telegram-bot solution. From there documentation;

bot.send_message(chat_id=chat_id, 
                 text="*bold* _italic_ `fixed width font` [link](http://google.com).", 
                 parse_mode=telegram.ParseMode.MARKDOWN)