Skip to content

dcealopez/f1-alerts-telegram-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

f1-alerts-telegram-bot

F1 Alerts bot for Telegram.

This bot displays alerts for the FIA Formula 1 Championship on Telegram.

The official Formula 1 web API (free) is used alongside the Open Weather Map API to fetch the event information used to display the alerts.

The Ergast API is also used to fetch information about the driver and constructor standings.

All the circuit layout images were taken from the public Wikipedia page for each circuit.

Official Telegram channel: https://t.me/f1alerts

Features

  • Displays full session schedules for many locations across the world.
  • Sends circuit layout photos.
  • Sends reminder alerts for incoming sessions.
  • Shows the weather report of the circuit for incoming sessions.
  • Generates and sends photos for the results of each session.
  • Displays updated driver and constructor standings after each race.

Configuration

The following enviroment variables must be set for the bot to run:

# Telegram bot token
BOT_TOKEN=

# Open Weather Map API Key
OWM_API_KEY=

# F1 static API Key (DO NOT MODIFY)
F1_API_KEY=qPgPPRJyGCIPxFT3el4MF7thXHyJCzAP

# Development mode (0 disabled, 1 enabled)
DEV_MODE=

# Telegram channel ID the bot will send messages to
TELEGRAM_CHANNEL_ID=

# Refresh interval (Cron Time format)
BOT_LOOP_CRON_TIME=*/1 * * * 0,4,5,6

# Time ahead for incoming session alerts (in ms)
ALERT_TIME_AHEAD=900000

# Time ahead for the session schedule alerts (in ms)
SESSION_TIMES_ALERT_TIME_AHEAD=43200000

# Time to wait after the race to display the updated driver/constructors standings messages (in ms)
TIME_STANDINGS_UPDATE_AFTER_RACE=21600000

# LOG4JS Config file
LOG4JS_CONFIG=

Logging

The log4js node module is used for logging. A log4js configuration file is not required for the bot to run but it is recommended.

Here is an example configuration:

{
     "appenders": {
          "console": {
               "type": "console",
               "layout": {
                    "type": "pattern",
                    "pattern": "%[[%d{yyyy-MM-dd hh:mm:ss.SSS}] [%p] %m%]"
               }
          },
          "all": {
               "type": "dateFile",
               "filename": "./logs/bot.log",
               "layout": {
                    "type": "pattern",
                    "pattern": "[%d{yyyy-MM-dd hh:mm:ss.SSS}] [%p] %m"
               },
               "compress": true,
               "alwaysIncludePattern": true,
               "keepFileExt": true
          }
     },
     "categories": {
          "default": { "appenders": ["console", "all"], "level": "all" }
     }
}

Images

Session schedule alert:

Incoming session alert w/ weather report:

Session results alert:

Standings update alert: