Skip to content

Forwarding of messages between Telegram Bot API and MQTT broker

Notifications You must be signed in to change notification settings

nizovtsevnv/telegram-mqtt-bridge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Telegram MQTT bridge
telegram-mqtt-bridge

Forwarding of messages between Telegram Bot API and MQTT broker.

Key FeaturesHow To UseSupportLicense

Key Features

  • Connecting to Telegram Bot API by token authentication
  • Connecting to MQTT broker without authentication
  • Forwarding any messages from Telegram Bot API to MQTT in the same JSON format as Telegram Update object
  • Requesting any Telegram Bot API methods with JSON data from the MQTT message
  • Configuring all gateway options via environment variables

How To Use

To clone and run this application, you'll need Git and Rust installed on your computer.

From your command line:

# Clone this repository
$ git clone https://github.com/nizovtsevnv/telegram-mqtt-bridge

# Go into the repository
$ cd telegram-mqtt-bridge

# Install dependencies and run the app
$ RUST_LOG=info \
  TELEGRAM_TOKEN=CHANGE_IT_TO_YOUR_VALUE \
  QUEUE_HOST=localhost \
  QUEUE_PORT=1883 \
  SEND_TO_TELEGRAM=messages-to-telegram \
  SEND_TO_QUEUE=messages-from-telegram \
  cargo run

To set up options use environment variables:

  • (optional) CLIENT_ID - identifier on MQTT broker, default value - "telegram-mqtt-bridge"
  • (optional) QUEUE_HOST - MQTT broker, default value - "localhost"
  • (optional) QUEUE_POLLING_TIMEOUT - polling request timeout, default value - 60 seconds
  • (optional) QUEUE_PORT - MQTT broker port, default value - 1883
  • (optional) RUST_LOG - logging level, default value - "error"
  • (optional) SEND_TO_QUEUE - queue name for messages from Telegram to MQTT, default value - "messages-from-telegram"
  • (optional) SEND_TO_TELEGRAM - queue name for messages from MQTT to Telegram, default value - "messages-to-telegram"
  • (optional) TELEGRAM_POLLING_TIMEOUT - polling request timeout, default value - 60 seconds
  • (required) TELEGRAM_TOKEN - authentication token for Telegram Bot API

You can make static executable with preconfigured Docker Alpine builder image, run in your console:

bin/build-static-executable

Support

Buy Me A Coffee

License

MIT


About

Forwarding of messages between Telegram Bot API and MQTT broker

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published