Skip to content

ruben-rodriguez/portainer-telegram-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

portainer-telegram-bot

Build Status

Simple Telegram Bot to manage Docker through Portainer API

Built thanks to the following libraries:

  • Telegraf - Telegram Bot framework for Nodejs.
  • request-promise - The simplified HTTP request client 'request' with Promise support. Powered by Bluebird.
  • Winston - A logger for just about everything.
  • Mocha - The fun, simple, flexible JavaScript test framework.
  • Chai - Assertion library for Node.
  • Nock - HTTP server mocking and expectations library for Node.

Supports the following commands:

  • /help - Prints this list
  • /hello - Say hello!
  • /status - Prints Portainer instance status
  • /get_containers - Prints list of containers and status
  • /start_container - Displays inline keyboard with containers to start if any
  • /stop_container - Displays inline keyboard with containers to stop if any

Available ENV variables to configure application:

Portainer:

  • PORTAINER_HOST = Hostname/IP used by Portainer instance. Default value is 'testhost'
  • PORTAINER_PORT = Port number used by Portainer instance. Default value is '9000'
  • PORTAINER_USER = Username used to log in Portainer instance. Default value is 'admin'
  • PORTAINER_PASSWORD = Password of Portainer user configured. Default value is 'adminpassword'
  • PORTAINER_ENDPOINT = Endpoint ID to manage. Default value is '1'

Telegram:

  • BOT_TOKEN = Telegram Bot token provided by @BotFather
  • TELEGRAM_USERS = List of Telegram users authorized to use the application. Default value is ''

Running Mocha test suite (locally)

Clone this repository:

$: git clone https://github.com/ruben-rodriguez/portainer-telegram-bot

Install dependencies:

$: npm install

Run test cases (no need to set any ENV variable):

$: npm test

Runing on local machine

Clone this repository:

$: git clone https://github.com/ruben-rodriguez/portainer-telegram-bot

Install dependencies:

$: npm install

Run (Don't forget to set ENV variables appropriately):

$: npm start

Runing on Docker container

Clone this repository:

$: git clone https://github.com/ruben-rodriguez/portainer-telegram-bot

Leverage docker-build.sh tool. Follows example usage:

$: sudo ./scripts/docker-build.sh "-e PORTAINER_HOST=127.0.0.1 -e BOT_TOKEN=xxxxxxxxx:qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq -e TELEGRAM_USERS=TelegramUser,TelegramUser2"

Note: sudo is required to execute Docker commands used by the script. Reading of the script before executing is encouraged!

About

Telegram Bot to manage Docker through Portainer API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published