Search code examples
python-3.xtelegram-bottelethon

How to send message followed by start to a bot by link using telethon?


I want to interact with a bot which takes chat id and message id and replies based on the message of that chat id.

Usually I interact with the bot in a group chat using KeyboardButtonUrl having link (e.g. here is that url behind KeyboardButtonUrl, https://t.me/SomeBot?start=-1001234567890_654321) to the bot with data. I click on the button which directly opens the chat with bot & clicking on Start button, sends the command to the bot (I think bot fetches the message from the passed data having chat id and message id) .

Sending message '-1001234567890_654321' using send_message function doesn't work as expected. How can I achieve this using telethon ?

Also After searching in telethon docs, I could not find any function which returns a particular message after taking message id and chat id. get_messages & iter_messages returns specified no. of last msgs only.


Solution

  • You can use @oleskii's approach, but you can also just send a message like so:

    client.send_message('bot username', '/start params_string')