8000 GitHub - jellydn/sky-alert: Real-time flight monitoring Telegram bot. Track flights, get instant alerts on delays, gate changes, boarding, and more. Β· GitHub
[go: up one dir, main page]

Skip to content
jellydnPublic

About

Real-time flight monitoring Telegram bot. Track flights, get instant alerts on delays, gate changes, boarding, and more.

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Repository files navigation

Welcome to SkyAlert πŸ‘‹

Version License: MIT Twitter: jellydn

Real-time flight monitoring Telegram bot. Track flights, get instant alerts on delays, gate changes, boarding, and more.

SkyAlert Logo

Features

  • Track flights by flight number, natural language, or route (e.g., DAD to SIN today)
  • Real-time alerts β€” check-in open, delays, gate changes, boarding, departure, landing, cancellation
  • Adaptive polling β€” every 15 min (far), 5 min (near), 1 min (imminent)
  • Multi-user β€” multiple users can track the same flight with deduplicated API calls
  • Auto-cleanup β€” expired flights are deactivated and removed automatically
  • Live refresh fallback β€” FlightStats-first enrichment, then FlightAware as secondary fallback when data is still low-signal

Tech Stack

  • TypeScript + grammY (Telegram Bot framework)
  • SQLite (via better-sqlite3 or Drizzle)
  • Aviationstack API for flight data

Install

# Install dependencies
bun install

# Configure environment
cp .env.example .env
# Set BOT_TOKEN and AVIATIONSTACK_API_KEY in .env

Usage

# Run the bot
bun run start

Deployment

Ready to deploy your bot? Check out the Hosting Guide for detailed instructions on deploying to:

  • Fly.io (recommended) β€” with persistent SQLite volume
  • Render β€” simple deployment with disk storage
  • Railway β€” easy setup with volume support

The guide covers environment variables, database persistence, and troubleshooting.

Develop

# Run in development mode
bun run dev

# Type-check
bun run typecheck

# Lint
bun run lint

Justfile shortcuts

just dev
just db-generate
just db-migrate
just db-studio

Note: drizzle-kit SQLite commands rely on better-sqlite3 at dev time for DB connectivity.

image image

Environment Variables

Variable Description
BOT_TOKEN Telegram bot token from @BotFather
AVIATIONSTACK_API_KEY API key from aviationstack.com

Bot Commands

Command Description
/start Welcome message
/track AA123 2026-03-15 Track a flight
/flights List all tracked flights
/status AA123 View current flight status + timeline
/remove AA123 Stop tracking a flight
/help Show available commands

The bot also understands natural language:

  • Track my flight GA851 tomorrow
  • DAD to SIN today

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚         Telegram Bot            β”‚
β”‚  (grammY – long polling)        β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚     Message Parser / Router     β”‚
β”‚  (commands + natural language)  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Flight   β”‚  Background Worker   β”‚
β”‚ Service  β”‚  (adaptive polling)  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚         SQLite Database         β”‚
β”‚  flights | tracked_flights |    β”‚
β”‚       status_changes            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
          β”‚
          β–Ό
   Aviationstack API
          β”‚
          β–Ό (fallback when needed)
 FlightStats parser + FlightAware parser

Status Refresh, Timeout, and Fallback Rules

Refresh timing

  • /status refreshes flight data when either condition is true:
  • Data is stale (>= 15 minutes since last poll)
  • Data is low-signal (scheduled/empty status and no delay)
  • Polling worker interval by time-to-departure:
  • > 3h: every 15 minutes
  • <= 3h: every 5 minutes
  • <= 1h: every 1 minute

Caching

  • Aviationstack response cache TTL: 15 minutes
  • Live refresh paths (/status, polling worker) bypass cache to force fresh provider data

Selection timeout

  • Multi-result flight selection (route or ambiguous number) expires after 5 minutes
  • If expired, user must search/select again

Fallback behavior

  • Primary source is Aviationstack
  • Fallback is triggered only when Aviationstack is low-signal:
  • Status is scheduled or empty, and delay is missing/non-positive
  • Fallback order:
    1. FlightStats (status, delay, estimated departure/arrival, terminal, gate)
    1. FlightAware only if status/delay are still low-signal after FlightStats
  • /status display prefers live fallback estimated times over derived scheduled + delay
  • /status also shows arrival terminal/gate when available from fallback data
  • FlightAware fallback tries multiple identifiers (ICAO, IATA, user input), e.g. TGW315 then TR315

Known limitations

  • If both providers return no delay signal, bot will remain on scheduled/on-time data
  • FlightAware fallback is HTML/bootstrap parsing, not an official FlightAware API

Author

πŸ‘€ Huynh Duc Dung

Show your support

Give a ⭐️ if this project helped you!

ko-fi paypal buymeacoffee

License

MIT Β© Huynh Duc Dung

About

Real-time flight monitoring Telegram bot. Track flights, get instant alerts on delays, gate changes, boarding, and more.

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0