Skip to content

0xAF/openwebrx-telegram-bot

Repository files navigation

openwebrx-telegram-bot

Telegram bot reporting OpenWebRX MQTT events to @YourChannel or in private message.

Overview

openwebrx-telegram-bot listens to MQTT events from an OpenWebRX server and sends notifications to a specified Telegram chat. It provides real-time updates about client connections, disconnections, chat messages, receiver profile changes, etc.

ChangeLog

See ChangeLog for more info.

Features

  • The bot will reply to some Commands
  • Includes offline geolocation lookup for client IP addresses. You need maxmind.com free license key. (WARNING: Keep in mind that the first run will take few minutes to cache the GeoIP data)
  • The Bot will reply to your private messages with your Chat ID (so you can use it later in the config)

Commands

  • /help - show help
  • /getid - reply with ChatID of the user, who sent the command
  • /last <mode> [how_many] - reply with last messages from background decoders

Screenshots

reports commands

Requirements

Installation

  1. Clone the repository:

    git clone https://github.com/0xAF/openwebrx-telegram-bot.git
    cd openwebrx-telegram-bot
  2. Install dependencies:

    npm install
  3. Configure environment variables by editing the .env file:

    MQTT_BROKER_URL="mqtt://your-mqtt-broker:1883"
    MQTT_USERNAME=
    MQTT_PASSWORD=
    BOT_TOKEN=your_telegram_bot_token
    BOT_CHAT_ID=your_telegram_chat_id
    MAXMIND_API_KEY=your_maxmind_api_key
    GEODATADIR=/tmp/geoip # absolute path
    #DEBUG=bot:*,-bot:Decoders # if you want to see debug, without the decoders spam
  4. Update GeoIP database:

    ./update-geoip-db.sh
  5. Start the bot:

    npm run start

Docker Installation

You can also run the bot using Docker. This is the easiest way to get started if you don't want to install Node.js and dependencies manually.

  1. Get the docker image by one of the following methods:

    • Pull from Docker hub.

      docker pull slechev/openwebrx/telegram-bot
    • Build it yourself.

      docker build -t openwebrx-telegram-bot .
  2. Create a .env file in the project directory with your configuration (see above for required variables).

  3. Run the container, mounting the directory for GeoIP data and using the .env file:

    • Docker stand alone

      docker run --env-file .env -v /tmp/geoip:/tmp/geoip slechev/openwebrx-telegram-bot
    • Docker compose (use the example file)

      docker compose up -d

This will start the bot inside a container, using your environment variables and the GeoIP database directory.

Usage

The bot will connect to the MQTT broker and start sending notifications to the configured Telegram chat.

Variable Description Required
MQTT_BROKER_URL URL of the MQTT broker Yes
MQTT_TOPIC_BASE MQTT base topic for subscription (default: openwebrx) No
MQTT_USERNAME MQTT broker username No
MQTT_PASSWORD MQTT broker password No
BOT_TOKEN Telegram bot token Yes
BOT_CHAT_ID Telegram chat ID (e.g., @YourChannel or chat numeric ID) Yes
MAXMIND_API_KEY MaxMind GeoIP API key (for DB updates) Yes
GEODATADIR Directory for geolocation data files (Do not change for Docker) Yes
DEBUG Print DEBUG info to the console (use DEBUG=bot:*) No

Configure MQTT in OpenWebRX

  • Open OpenWebRX Settings page.
  • Go to "Spotting and reporting".
  • Find "MQTT settings" section.
  • Fill the required data.
  • Set the "MQTT topic" to "openwebrx/YourReceiverShortName"

MQTT Topics

The bot subscribes to the following MQTT topics from OpenWebRX:

  • openwebrx/+/CLIENT — for client connection, disconnection, and chat messages
  • openwebrx/+/RX — for receiver profile changes

This is due to support multiple OpenWebRx receivers in one MQTT broker. You should set the "MQTT topic" in OpenWebRx to "openwebrx/ReceiverShortName"

Setup Telegram Bot

  • Create new Bot with @BotFather. See instructions.
  • Get the Token and set it in your .env file.
  • (Optionaly) Create a Channel and add the Bot to the channel (with admin role).

License

MIT License. See LICENSE for details.

About

Telegram bot to report OpenWebRX MQTT events

Resources

License

Stars

Watchers

Forks

Packages

No packages published