Coder Social home page Coder Social logo

dcealopez / f1-alerts-telegram-bot Goto Github PK

View Code? Open in Web Editor NEW
9.0 1.0 6.0 1.65 MB

F1 Alerts bot for Telegram

License: GNU General Public License v3.0

JavaScript 100.00%
telegram bot formula one formula1 alerts notifications ergast ergast-api ergast-drivers-api f1

f1-alerts-telegram-bot's Introduction

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:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.