This translation is older than the original page and might be outdated. See what has changed.
Translations of this page:
- en
- ru
en:websonix:bot
This is an old revision of the document!
Table of Contents
A users notifying script about the measurement status
The Bot sends notifications about measurement errors by e-mail and/or telegram channel. Information about errors is extracted from the measurement protocol. Moreover, users can send any messages from measurement scripts using the following code:
from bot import messangers messangers.send_message("<message text>")
Structure
The Bot consists of the three modules and configuration file.
Modules
The package consists form the following modules:
- protocol_reader - модуль для чтения протоколов измерения;
- messangers - список функций для рассылки, содержит классы для рассылки по почте и telegram, а так же функции send_message, которая отправляет сообщение по всем указанным адресам;
- logwatch - sonix-подобное устройство, которое сканирует рабочий протокол и в случае нахождения ошибок отправляет сообщение функцией send_message.
Configuration file
Конфигурационный файл записывается в формате json, и отвечает за следующие параметры
- mail - e-mail configuration:
- user - user for e-mail authentication;
- password - password for e-mail authentication;
- port - порт почтового сервера, через который будут отправляться почтовые сообщения;
- server - dns имя сервера, через который будет осуществляться почтовая рассылка;
- recipients - список получателей для отправляемого письма.
- telegram - telegram configuration:
- bot-id - id бота для рассылки сообщений;
- channel-id - id канала, на который стоит отправлять сообщения.
Configuration file example:
{ "mail": { "user": "sonix-bot", "password": "your_password", "port": 25, "server": "smtp.nf.jinr.ru", "recipients": [ "somebody@mail_address", "another_if_neccessary@mail_addres" ] }, "telegram": { "bot-id": "your_telegram_bot_id", "channel-id": "telegram channel_id" } }
Bot installation on instrument
Для подключения Bot на спектрометре необходимо установить соответствующий пакет, заполнить параметры в конфигурационном файле для отправки сообщений и настроить загрузку модуля logwatch.py в настройках Sonix+.
en/websonix/bot.1611657066.txt.gz · Last modified: (external edit)