-
Notifications
You must be signed in to change notification settings - Fork 0
Home
GolBot is a Telegram bot that provides real-time information about football matches, standings, and top scorers from major European leagues such as LaLiga, Premier League, Serie A, Bundesliga, and the Champions League. It uses a football API (private token required) to fetch up-to-date data and presents it in a simple, user-friendly format.
-
Main libraries:
-
requests: For making HTTP requests to the external API. -
telebot(PyTelegramBotAPI): For interacting with Telegram and handling messages/commands. -
datetimeandpytz: For managing dates and timezones (configured to Europe/Madrid).
-
-
Key variables:
-
API_KEY: Token to authenticate with the football API. -
BASE_URL: Base URL of the football API. -
bot: TeleBot instance initialized with the Telegram bot token. -
tz: Timezone set to "Europe/Madrid".
-
-
COMPETICIONESdictionary: Defines supported leagues with their API codes, display names, and representative emojis.
-
/startSends a welcome message and explains how to use the available commands. -
/partidos <league> <today|matchday>Shows matches from the specified league for today or the upcoming matchday. Example:/partidos laliga today -
/clasificacion <league>Shows the current standings table of the chosen league. -
/maximos <league>Shows the top scorers of the specified league.
-
Requests all matches of the competition from the API.
-
Filters matches based on mode:
-
"hoy"(today): matches scheduled for the current day. -
"jornada"(matchday): matches in the next pending (unfinished) matchday.
-
-
Returns formatted text ready to send via Telegram.
-
Takes a match JSON object and returns a user-friendly text including:
- Local date and time (Europe/Madrid timezone).
- Home and away teams.
- Match status and final score if finished.
- Fetches the league standings from the API.
- Builds a ranked list with position (using emojis), team name, and points.
- Retrieves top scorers for the league from the API.
- Lists the top 5 scorers with player name and goals scored.
- Validates user command input to ensure required parameters are provided.
- Checks if the league exists in the
COMPETICIONESdictionary. - Handles API errors when responses have non-200 status codes.
- Sends clear user messages in case of errors or unavailable data (e.g., "No matches today", "Invalid league").
To run the bot:
- Insert your Telegram bot token into the
telebot.TeleBot()call (already included in the code). - Insert your football API token into
API_KEY. - Set the API base URL in
BASE_URL. - Run the Python script.
The bot will remain active, listening and responding to commands with
bot.polling(none_stop=True).