D
D
Dmitri2020-04-26 18:00:37
Python
Dmitri, 2020-04-26 18:00:37

Python two bots in one script?

bot1 = telebot.TeleBot("token of the first one) bot2
= telebot.TeleBot("Token of the second one") How

to run two bots at once in one script? swap, the first one will work, but the second one will not. I would like to run both at once

Answer the question

In order to leave comments, you need to log in

3 answer(s)
0
0ralo, 2020-04-26
@dmitriy337

Polling is essentially an endless process, so the script may not reach the second line. Try to kick one bot from the main thread:

import threading

"""
code
"""
threading.Thread(bot2.polling).start()
bot1.polling()

A
alekssamos, 2020-04-26
@alekssamos

If only to apply command line arguments and separately run bot.py 1& and bot.py 2&

T
Timur Pokrovsky, 2020-04-26
@Makaroshka007

and in a separate thread?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question