Skip to content

Use a bot

In order to use a Bot in your code create a TelegramBot object. <your_token> represents the API token generated by the BotFather and <your_chat_id> is your unique identifier that you can find through the @chatid_echo_bot.

from bob_telegram_tools.bot import TelegramBot

token = '<your_token>'
user_id = int('<your_chat_id>')
bot = TelegramBot(token, user_id)

Warning

You have to start a coversation with your bot before it is able to send you a message!

Once you have created your Bot you can send a message and update it without send a notification through the returned reference.

sent_message = bot.send_text('Hello TelegramBot!')
bot.update_text(sent_message,'Updated hello TelegramBot!')