associatesger.blogg.se

Telegram bot start
Telegram bot start










telegram bot start

Once the bot is ready for deployment it is time to enable the Webhook: doing so Telegram will push the updates to the registered webhook endpoint and your service gets busy only when there are new incoming messages. def main(): updater = Updater('myTelegramToken') dp = updater.dispatcher # define command handler dp.add_handler(CommandHandler( "help ", help_command_handler)) # define message handler dp.add_handler(MessageHandler(Filters.text, main_handler)) updater. (no tunneling software like ngrok is required). The pull mechanism is where the bot (your code) is checking regularly for new available messages on the server.Įveryone agrees this is not an ideal approach (unnecessary waste of resources, messages are discarded after 24 hours), but it is convenient when developing locally. Telegram Bot can work with a Pull or with a Push mechanism (see further Webhooks).












Telegram bot start