B
B
bitkoljas2021-08-05 17:15:42
Python
bitkoljas, 2021-08-05 17:15:42

How to run multiple copies of telegram bot on Aiogram?

The question is the following, I have a Telegram bot script written in Python using the Aiogram library. As soon as I start the second copy of the bot, the following error appears in the console:

aiogram.utils.exceptions.TerminatedByOtherGetUpdates: Terminated by other getupdates request; make sure that only one bot instance is running


And the text of the messages is displayed in one window, then in another, but I need both windows to read the sent messages without problems and conflicts without interfering with each other.

The essence of the bot is as follows: The script runs on several computers at the same time (both on one and on a hundred) and constantly monitors the messages of the bot. As soon as a message with the name of a certain computer arrives in the bot, the copy of the bot installed on this computer responds to the request, and the remaining copies ignore this message. But due to the fact that when you run 2 or more instances of the code, an error occurs, I cannot implement it.

Bot interaction code:
import aiogram

__connect_key__ = 'token'
__admin_id__ = 'id'
TelegramSession = aiogram.Dispatcher(aiogram.Bot(token=__connect_key__))

@TelegramSession.message_handler()
async def Messages(message: aiogram.types.Message):
    if message['from']['id'] == __admin_id__:
        Hendler(message.text)

def Hendler(Data):
    print(Data)

if __name__ == '__main__':
    aiogram.executor.start_polling(TelegramSession, skip_updates=False)


Is there a way to fix this using this particular library? Or it would be more convenient to write your own library for interacting with the bot via the API, because in this way you don’t have to face this error, but it’s wildly inconvenient.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-08-05
@bitkoljas

Or it would be more convenient to write your own library for interacting with the bot via the API, because in this way you don’t have to face this error, but it’s wildly inconvenient

The error is generated by telegram, not aiogram. There is only one bot , you do not need to run thousands of copies of it. Change application logic / use client api

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question