Telegram bot extension for EVA ICS LM PLC
Requires EVA ICS 3.3 or newer.
-
install tebot module
-
put telegram.py to /opt/eva/xc/extensions/
-
put sample configuration file telegram.yml to /opt/eva/etc/
-
modify sample configuration
-
load extension:
eva lm ext load tbot telegram -y
Start chat with your bot and follow the instructions.
-
if macros is started as "/macro some args", args are added to macro arguments.
-
current chat_id is passed into macro kwargs and may be used later.
When loaded, e.g. as tbot, extension provides functions:
- tbot_send
- tbot_send_photo
- tbot_send_video
- tbot_send_audio
- tbot_send_document
Function arguments are the same as for https://pypi.org/project/tebot/, refer to module documentation for more info, except first argument should be either API key ID or list of API key IDs. If "*" is specified, broadcast message is sent.
Send a message only to user who called macro
# chat_id variable is available in macro, as it was sent in kwargs
tbot_send(None, 'this is a reply', chat_id=chat_id)
Send broadcast message to all
tbot_send('*', 'this is a test')
Send image to users with API key IDs "operator" and "operator2":
with open('image.jpg', 'rb') as fh:
tbot_send(['operator', 'operator2'], media=fh.read())
After log in, use /getcommands command, go to Telegram BotFather, enter /setcommands and paste it as-is.
To exclude command from the inline keyboard, put dot before macro in "inline-keyboard" section of the configuration.
-
using master key is not recommended
-
write dedicated macros
-
if possible - use dedicated instance of LM PLC