I am trying to deploy this telegram bot, but the deploy always fails (although on the first minutes after I receive the build successful log, it works perfectly). However, minutes later the deploy fails and I keep getting this error log:
telebot.apihelper.ApiTelegramException: A request to the Telegram API was unsuccessful.
Error code: 409. Description: Conflict: terminated by other getUpdates request;
make sure that only one bot instance is running
Here is the “bot.py” script I coded. Suppressed some non important parts of the code. Also, all “src.” modules were created by me for better code organization. There are no telebot methods called by those modules.
#generic code supressed below, means no telebot method is being called. One can think as a simple print(“Hello World”) instead.
import pandas as pd
from datetime import datetime, date
import src.visualization.visualize as vz
import src.auxiliary.auxiliary as aux
import src.data.wrangling as w
import src.data.database as db
import os
import telebot
API = os.getenv("API_KEY")
bot = telebot.TeleBot(API)
@bot.message_handler(commands=["IBOVESPA", "SP500", "NASDAQ"])
def responder(mensagem):
# generic code and calculations suppressed
if condition:
# telebot method used
bot.send_photo(
mensagem.chat.id,
photo = photo
)
else:
# more generic code suppressed
# telebot method used
bot.send_message(
mensagem.chat.id,
aux.create_answer(assets)
)
# telebot method used
bot.send_photo(
mensagem.chat.id,
photo = photo
)
def verificar(mensagem):
return True
def calculating_msg(mensagem, date):
# telebot method used
bot.send_message(
mensagem.chat.id,
“generic answer”
)
@bot.message_handler(func=verificar)
def responder(mensagem):
text= (
“standard reply to any message”
)
# telebot method used
bot.reply_to(mensagem, text)
# telebot method used
bot.polling()
Already revoked an old api_key on telegram and used a fresh-generated one and nothing changes.
Also, it works perfectly running on local. Only receive this warning:
\src\visualization\visualize.py:34: UserWarning: Starting a Matplotlib GUI outside of the main thread will likely fail.
fig = plt.figure(figsize=(15, 8))
WARNING: QApplication was not created in the main() thread.