Mqtg Bot Save

MQTT Client Telegram Bot

Project README

mqtg-bot

Build Status Go Report Card Version License

Gopher Bot

Articles

Introduction

mqtg-bot is an easy-to-configure for your needs MQTT client Telegram bot. Without programming knowledge you can configure the bot to send various commands (turn on the light, open the garage door, etc.) or request any information (the temperature in the house, the state of the heating system, etc.) or receive frames from security camera. In general the functionality of this solution is very rich.

Edit buttons menu

Temp and Humidity

Take a picture

Features

  • Connecting to MQTT broker
    • tcp / ssl / ws / wss
  • Supported databases
    • Postgres
    • SQLite
  • Subscribing to a topic:
    • Selectable QoS/Retained
    • Text/Image data types
    • Pre/post value displaying text
    • Storing data into DB
    • Parse data by JsonPath expressions
    • Data storage management
    • Publish action on receiving
    • Voice data type
  • Publishing to a topic:
    • Selectable QoS/Retained
    • Text/Image data types
    • Voice data type
  • Customized users buttons menu:
    • Folders
    • Single-value buttons
    • Toggle buttons
    • Multi-value buttons
    • Print last subscription value
    • Draw charts
  • Your great idea (create a proposal in issues)

Usage

You can run the bot on your Raspberry Pi home server or free Heroku dyno.

Clone this repository:

git clone https://github.com/xDWart/mqtg-bot

Message @BotFather /newbot command to create a bot and get his HTTP API access token.

Environment variables

  • TELEGRAM_BOT_TOKEN - bot HTTP API access token, required
  • DATABASE_URL - Postgres connection string in the following format: postgres://user:password@host:port/db
  • SQLITE_PATH - path to SQLite database
  • MQTT_CLIENT_ID - Client ID to be used. Required for VerneMQ.

Notes:

  1. Only TELEGRAM_BOT_TOKEN env is required
  2. If DATABASE_URL env is omitted, or a Postgres connection error occurred, SQLite will be used
  3. If SQLITE_PATH env is omitted, mqtg.db will be used by default as a SQLite database
  4. You can create the .env file in the root of the project and insert your key/value environment variable pairs in the following format of KEY=VALUE

Local running

You can run mqtg-bot with environment variables:

TELEGRAM_BOT_TOKEN=... go run main.go

or if you've already created the .env file:

go run main.go

Running in Docker container

docker run -e TELEGRAM_BOT_TOKEN=... -e DATABASE_URL=... --network=host owart/mqtg-bot

Heroku running

You will need Heroku CLI

# login into Heroku
heroku login

# create a new app
heroku create *YOUR_APP_NAME*

# add your new app into git remotes
heroku git:remote -a *YOUR_APP_NAME*

# add TELEGRAM_BOT_TOKEN environment
heroku config:set TELEGRAM_BOT_TOKEN=*BOT_ACCESS_TOKEN*

# set version of Go
heroku config:set GOVERSION=go1.15

# attach Postgres add-on
heroku addons:create heroku-postgresql:hobby-dev

# push master branch to Heroku
git push heroku master

# scale up your app
heroku ps:scale worker=1

Then just message /start to your bot and follow the instructions to configure it.

Contribution

Licence

  • mqtg-bot is licensed under the MIT License.
  • See LICENSE for the full license text.
  • Copyright (c) Anatoliy Bezgubenko
Open Source Agenda is not affiliated with "Mqtg Bot" Project. README Source: xDWart/mqtg-bot

Open Source Agenda Badge

Open Source Agenda Rating