Reputation: 1
Good afternoon!
My telegram bot is written in Python and is very simple. It includes thousands of lines of functions of the same type (example below) and ends with a line bot.infinity_polling(True)
@bot.message_handler(commands=['start'])
def com_start(m):
keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True)
keyboard.add(*[types.KeyboardButton(name) for name in ['🇷🇺Русский']])
keyboard.add(*[types.KeyboardButton(name) for name in ['🇬🇧English']])
keyboard.add(*[types.KeyboardButton(name) for name in ['🇩🇪German']])
keyboard.add(*[types.KeyboardButton(name) for name in ['🇹🇷Turkish']])
msg = bot.send_message(m.chat.id, '👋🏼Привет!',
reply_markup=keyboard)
bot.register_next_step_handler(msg, starter)
def starter(m):
if m.text == '🇷🇺Русский':
second(m)
elif m.text == '🇬🇧English':
secondeng(m)
elif m.text == '🇩🇪German':
secondgerm(m)
elif m.text == '🇹🇷Turkish':
secondtur(m)
else:
msg = bot.send_message(m.chat.id, 'Используйте кнопки меню для общения с ботом OTON ⤵️')
com_start(m)
My bot works with gitlab, after each change in the code I commit, push it and Run Pipeline via CI/CD.
The problem is that the GetUpdates method (https://api.telegram.org/bot.../getUpdates) while the bot is running gives {"ok":true,"result":[]} and nothing more. But when I stop the bot and refresh the page - it gives me all that I need:
{"ok":true,"result":[{"update_id":57670007, "message":{"message_id":10586,"from":{"id":435418164,"is_bot":false,"first_name":"Nika","last_name":"Fenina","username":"yanikailinet","language_code":"ru"},"chat":{"id":435418164,"first_name":"Nika","last_name":"Fenina","username":"yanikailinet","type":"private"},"date":1590065990,"text":"hello"}}
Can I solve this problem somehow? I need to get the information I need while the bot is running.
PS: no webhooks connected
Upvotes: 0
Views: 1863
Reputation: 31
You cannot make simultaneous getUpdates requests. It shows this error.
Conflict: terminated by other getUpdates request; make sure that only one bot instance is running
You can save the information of ["result"] inside the code only in some file.
Upvotes: 0