Springbok
springbok is a simple wrapper to send messages with Telegram Bot. Useful to notify when scripts are finished!
Table of contents
Introduction
This module provides a simple way to send messages with Telegram Bot. Is useful to notify you when scripts are finished. You can import it into your code or using the command-line utility. In the command-line utility, springbok reads the message data as a parameter or from stdin.
Installing
You can install or upgrade springbok with:
$ pip install springbok --upgrade
Or you can install from source with:
$ git clone https://github.com/andremmorais/springbok --recursive
$ cd springbok
$ python setup.py install
Getting started
To use Springbok you will need the bot token and the chat_id of the sender.
The token can be generated talking with @BotFather on telegram and the chat_id can checked at https://api.telegram.org/bot(YourBOTToken)/getUpdates/
Springbok reads the configuration from ~/.springbok
From command-line with message data as argv
$ sleep 5 && springbok "sleep finished";
From command-line with message data from stdin
$ echo "this is a test message" | springbok
Importing into your code
from springbok import Springbok
bot = Springbok()
bot.push(msg)
If you dont have the configuration you will need to pass them as arguments:
from springbok import Springbok
bot = Springbok(token, chat_id)
bot.send(msg)
$ springbok
Token: xxxxx
Chat ID: xxxxx
OR you can also do:
$ springbok -t xxxxx -i xxx "this is a test message"
Usage
usage: springbok [-h] [-t TOKEN] [-i CHAT_ID] [-c CONFIG] [-v] [--version] [message [message ...]]
Simple wrapper to send notifications with Telegram Bot
- positional arguments:
- message Message to send
- optional arguments:
-
-h, --help show this help message and exit -t TOKEN, --token TOKEN telegram bot token -i CHAT_ID, --chat_id CHAT_ID sender chat id -c CONFIG, --config CONFIG configuration file instead of /Users/andremorais/.springbok -v, --verbosity increase output verbosity --version show program's version number and exit
References
License
You may copy, distribute and modify the software provided that modifications are described and licensed for free under LGPL-3. Derivatives works (including modifications or anything statically linked to the library) can only be redistributed under LGPL-3, but applications that use the library don't have to be.