[Python] Pyhon Telegram Bot Multiple Bots

Discussão em 'Python' iniciado por Stack, Março 18, 2025.

  1. Stack

    Stack Membro Participativo

    I have multiple bots that utilize Python Telegram Bot module. Each bot has code like:

    from telegram.ext import Updater, CommandHandler

    def start(update, context):
    update.message.reply_text("Command List:\n/start - Display this message")

    def main():
    updater = Updater(token='XXXXXXX:XXXXXXX-XXXXXXXXXXX', use_context=True)
    updater.dispatcher.add_handler(CommandHandler('start', start)) # One example of a bot command
    # ... Several CommandHandler and ConversationHandler functions ...
    updater.start_polling()
    updater.idle()

    if __name__ == '__main__':
    main()


    I found this documentation for running multiple asyncio frameworks but I could not find a specific example that creates multiple instances of python telegram bot. The bots I have run on completely separate channels and have different set of commands/functions/tokens. How would I have one script for multiple bots?

    Continue reading...

Compartilhe esta Página