Forums

Assistance needed for persistent errors in my Telegram Bot

Good morning!

Please excuse my English, as it is not my native language. I am using the free plan on PythonAnywhere (PA) to host a small bot.py (Bot) that interacts with the Telegram (TG) API to display cards from the Shadow Era (SE) game.

Context: - The images of the cards are hosted on the SE website. - The bot and the database are hosted on PA. - Tool that helps me: GPT.

Problem encountered: - high CPU Usage. - telegram.error.BadRequest: Query is too old - Knowledge of Python: None. - General programming knowledge: None.

Bot's description: User types @nameofthebot followed by a search term. The bot receives this input, queries the database for matching cards, and retrieves their image URLs, which it then sends back to the Telegram API. History: At the beginning, Bot was searching a json database, and now an SQLite database. The SQLite database is built with keywords attached to card IDs to help the bot avoid searching the entire JSON file. CPU usage is (still) a problem, but less. During various tests locally and with the bot hosted on PA, I encounter different functionality issues, one of which is recurrent: telegram.error.BadRequest: Query is too old and response timeout expired or query id is invalid.

Bot uses Long Polling because I thought the response time would be faster, and I wanted to integrate a simpler way to call it later, in the SE Official Discussion chat room.

Observation & needs: It has been several days now that this error has been recurring and preventing Bot from functioning properly, especially since the database switched to SQLite. My knowledge is completely lacking, and I don't know how to find a solution to this problem, nor do I have the necessary tools to get a clear overview of what I might need. That's why I'm turning to you for help, or please redirect me to a place where I can seek assistance.

Thank you for considering my request!

There's a link at the top of the main Forums page to codementor that you can use to get help from someone who can tutor you.

I see. Thank you.

Have a nice day!

You may also ask your questions on more general forums.