User Tools

Site Tools


This translation is older than the original page and might be outdated. See what has changed.
Translations of this page:

en:websonix:bot

This is an old revision of the document!


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, и отвечает за следующие параметры

  1. mail - e-mail configuration:
    1. user - user for e-mail authentication;
    2. password - password for e-mail authentication;
    3. port - порт почтового сервера, через который будут отправляться почтовые сообщения;
    4. server - dns имя сервера, через который будет осуществляться почтовая рассылка;
    5. recipients - список получателей для отправляемого письма.
  2. telegram - telegram configuration:
    1. bot-id - id бота для рассылки сообщений;
    2. channel-id - id канала, на который стоит отправлять сообщения.

Configuration file example:

  1. {
  2. "mail": {
  3. "user": "sonix-bot",
  4. "password": "your_password",
  5. "port": 25,
  6. "server": "smtp.nf.jinr.ru",
  7. "recipients": [
  8. "somebody@mail_address",
  9. "another_if_neccessary@mail_addres"
  10. ]
  11. },
  12. "telegram": {
  13. "bot-id": "your_telegram_bot_id",
  14. "channel-id": "telegram channel_id"
  15. }
  16. }

Bot installation on instrument

Для подключения Bot на спектрометре необходимо установить соответствующий пакет, заполнить параметры в конфигурационном файле для отправки сообщений и настроить загрузку модуля logwatch.py в настройках Sonix+.

en/websonix/bot.1611657066.txt.gz · Last modified: (external edit)