1

Update readmes about runtime environment

This commit is contained in:
eleksir
2022-01-29 18:07:03 +03:00
parent e552ecbf00
commit c9e664b4e5
2 changed files with 71 additions and 93 deletions

View File

@@ -2,35 +2,31 @@
## Disclaimer ## Disclaimer
This version - 3 (something) - considered stable. It means that further This version - 3 (something) - considered stable. It means that further development of new features kind of frosen.
development of new features kind of frosen. Most effort will be targeted to Most effort will be targeted to future 4-th version development. If you have some ideas or fixes to this version
future 4-th version development. If you have some ideas or fixes to this version
feel free PR them, they will be merged as soon as being reviewed. feel free PR them, they will be merged as soon as being reviewed.
## About ## About
It is based on Perl modules [Telegram::Bot][1] and [Hailo][2] as conversation It is based on Perl modules [Telegram::Bot][1] and [Hailo][2] as conversation generator.
generator.
I have to fork [Telegram::Bot][1] and update it according to features appeared I have to fork [Telegram::Bot][1] and update it according to features appeared in [Telegram Bot API v5][3]. Also,
in [Telegram Bot API v5][3]. Also, I decide to rename it to avoid collision in I decide to rename it to avoid collision in the future, now it is Teapot::Bot and is bundled with bot. When lib becomes
the future, now it is Teapot::Bot and is bundled with bot. When lib becomes
mature enough, maybe I release it separately. mature enough, maybe I release it separately.
Bot config located in **data/config.json**, sample config provided as Bot config located in **data/config.json**, sample config provided as **data/sample_config.json**.
**data/sample_config.json**.
Bot can be run via **bin/aleesa-telegram-bot** and acts as daemon (double fork() Bot can be run via **bin/aleesa-telegram-bot** and acts as daemon (double fork() and detaches stdio).
and detaches stdio).
## Installation ## Installation
In order to run this application, you need to "bootstrap" it - download and build Application have been tested on alpine linux x86_64 3.12, with perl-5.32.1 builtin.
all required dependencies and libraries.
You'll need perl-5.18 or newer, "Development Tools" or similar group of In order to run this application, you need to "bootstrap" it - download and build all required dependencies and
packages, perl, perl-devel, perl-local-lib, perl-app-cpanm, sqlite-devel, libraries.
zlib-devel, openssl-devel, libdb4-devel (Berkeley DB devel), make.
You'll need perl-5.18 or newer, "Development Tools" or similar group of packages, perl, perl-devel, perl-local-lib,
perl-app-cpanm, sqlite-devel, zlib-devel, openssl-devel, libdb4-devel (Berkeley DB devel), make.
After installing required dependencies it is possible to run: After installing required dependencies it is possible to run:
@@ -44,56 +40,49 @@ and all libraries should be downloaded, built, tested and installed.
## Running ## Running
This bot does not [ultilize][4] webhooks, so in order to run it only well This bot does not [ultilize][4] webhooks, so in order to run it only well internet connection is required, no
internet connection is required, no public-available ip address is needed. public-available ip address is needed.
### Additional Settings to be performed in order to run bot as it designed ### Additional Settings to be performed in order to run bot as it designed
There are some "plugins" that requires registration on third party services There are some "plugins" that requires registration on third party services and API keys and secrets in order to work.
and API keys and secrets in order to work.
#### OpenWeatherMap #### OpenWeatherMap
You should [register][5], [login][6] and [create][7] api key. Free plan have You should [register][5], [login][6] and [create][7] api key. Free plan have all required features to run this "plugin".
all required features to run this "plugin".
Once key is created you should put it in **config.json** under openweathermap Once key is created you should put it in **config.json** under openweathermap section as appid. Thats it.
section as appid. Thats it.
It is still impossible to disable this plugin, but "I'm working on it". It is still impossible to disable this plugin, but "I'm working on it".
#### Imgur #### Imgur
This plugin "just exists" and is actually used nowhere around the code. This plugin "just exists" and is actually used nowhere around the code. Anyway, to make use of it besides registering
Anyway, to make use of it besides registering appropriate handler in code, you appropriate handler in code, you should sign in imgur and get access token.
should sign in imgur and get access token.
Actually at this time this "plugin" can be stub-ed with default config values. Actually at this time this "plugin" can be stub-ed with default config values.
Anyway, to fetch access token you should [login][8] and perform [registration][9] Anyway, to fetch access token you should [login][8] and perform [registration][9] of your app. Then you should
of your app. Then you should authorize your app according to [this][10] manual. Or authorize your app according to [this][10] manual. Or [this][11] one.
[this][11] one.
#### Flickr #### Flickr
This "plugin" is really used to implement random picture link retrival plugins. This "plugin" is really used to implement random picture link retrival plugins.
There is helper script in **bin/flickr_init.pl** that helps to get all required keys There is helper script in **bin/flickr_init.pl** that helps to get all required keys and secrets from flickr api.
and secrets from flickr api.
Before using it bot must be bootstrapped via **`bootstrap.sh`**. Before using it bot must be bootstrapped via **`bootstrap.sh`**.
[Login][11] and create an [app][12] in your flickr account. Then *logout* flickr account. [Login][11] and create an [app][12] in your flickr account. Then *logout* flickr account. (It is required in order to
(It is required in order to properly get "verifier" parameter later). properly get "verifier" parameter later).
Put your [app key and secret][13] to **config.json**. Ensure that "verifier" parameter Put your [app key and secret][13] to **config.json**. Ensure that "verifier" parameter in Flickr-related part of config
in Flickr-related part of config either absent or commented out. either absent or commented out.
Run **bin/flickr_init.pl** first time and follow on screen instructions - copy and Run **bin/flickr_init.pl** first time and follow on screen instructions - copy and paste given link to browser login to
paste given link to browser login to flickr account and you'll be redirected to flickr account and you'll be redirected to example.com. Check address bar in browser to get so-called "verifier", put
example.com. Check address bar in browser to get so-called "verifier", put it in it in **config.json**. Then run **bin/flickr_init.pl** again to store API access token in db under data/image directory
**config.json**. Then run **bin/flickr_init.pl** again to store API access token in db (in default config). You're done.
under data/image directory (in default config). You're done.
[1]: https://metacpan.org/pod/Telegram::Bot [1]: https://metacpan.org/pod/Telegram::Bot
[2]: https://metacpan.org/pod/Hailo [2]: https://metacpan.org/pod/Hailo

View File

@@ -2,40 +2,35 @@
## Дисклеймер ## Дисклеймер
Эта версия бота за номером 3 (с мелочью) стабильная. Сие означает, что Эта версия бота за номером 3 (с мелочью) стабильная. Сие означает, что дальнейшего развития функций в этой версии не
дальнейшего развития функций в этой версии не предполагается. Конечно, возможны предполагается. Конечно, возможны исключения, но основной план - переключиться на 4-ю версию, куда планируется
исключения, но основной план - переключиться на 4-ю версию, куда планируется
перенести большинство функций 3-й версии. перенести большинство функций 3-й версии.
Если у кого-то возникнут идеи относительно этой версии бота ставьте PR, я только Если у кого-то возникнут идеи относительно этой версии бота - ставьте PR, я только рад. Т.к. несмотря на то, что
рад. Т.к. несмотря на то, что развитие этой версии слегка заморожено, развитие этой версии "слегка" заморожено, поддерживать её планируется как минимум до выхода в свет 4-й версии бота.
поддерживать её планируется до выхода в свет 4-й версии бота.
## Что это такое ## Что это такое
Это бот, основанный на перловых модулях [Telegram::Bot][1] для работы в Это бот, основанный на перловых модулях [Telegram::Bot][1] для работы в мессенджере Telegram и [Hailo][2] для генерации
мессенджере Telegram и [Hailo][2] для генерации "умной" беседы. "умной" беседы.
Для корректной работы, пришлось форкнуть [Telegram::Bot][1], чтобы обновить Для корректной работы, пришлось форкнуть [Telegram::Bot][1], чтобы обновить интерфейс API до [Telegram Bot API v5][3].
интерфейс API до [Telegram Bot API v5][3]. Для избежания неоднозначностей, модуль Для избежания неоднозначностей, модуль пришлось переименовать и теперь он идёт в составе бота. Возможно, когда модуль
пришлось переименовать и теперь он идёт в составе бота. Возможно, когда модуль отлежится и будет похож на стабильный, он стнет самостоятельным и поселится на metacpan.org
отлежится и будет похож на стабильный, он стнет самостоятельным и поселится на
metacpan.org
Конфиг бота должен лежать в **data/config.json**. Пример конфига расположен в Конфиг бота должен лежать в **data/config.json**. Пример конфига расположен в **data/sample_config.json**.
**data/sample_config.json**.
Бота можно запустить через **bin/aleesa-telegram-bot** и он взлетит, как юниксовый Бота можно запустить через **bin/aleesa-telegram-bot** и он взлетит, как юниксовый демон (сделает двойной fork() и
демон (сделает двойной fork() и отцепится от stdio). отцепится от stdio).
## Установка ## Установка
Чтобы запустить приложение, его надо "забурстрапить" - загрузить и собрать все Приложение тестировалось на alpine linux x86_64 3.12, со встроенным perl-5.32.1.
необходимые зависимости.
Понадобится perl-5.18, а желательно новее, "Development Tools" или подобная Чтобы запустить приложение, его надо "забурстрапить" - загрузить и собрать все необходимые зависимости.
группа пакетов , perl, perl-devel, perl-local-lib, perl-app-cpanm, sqlite-devel,
zlib-devel, openssl-devel, libdb4-devel (Berkeley DB devel), make. Понадобится perl-5.18, а желательно новее, "Development Tools" или подобная группа пакетов , perl, perl-devel,
perl-local-lib, perl-app-cpanm, sqlite-devel, zlib-devel, openssl-devel, libdb4-devel (Berkeley DB devel), make.
После установки этих пакетов, можно будет запустить: После установки этих пакетов, можно будет запустить:
@@ -49,56 +44,50 @@ bash bootstrap.sh
## Запуск и работа ## Запуск и работа
Бот не использует [вебхуки][4], поэтому ничего дополнительного, кроме хорошего Бот не использует [вебхуки][4], поэтому ничего дополнительного, кроме хорошего подключения к интернету ему не нужно.
подключения к интернету ему не нужно.
### Дополнительные настройки ### Дополнительные настройки
Некоторые "плагины" требуют регистрации в сторонних сервисах (API keys, secrets Некоторые "плагины" требуют регистрации в сторонних сервисах (API keys, secrets итд), чтобы бот не сыпал ошибками в
итд), чтобы бот не сыпал ошибками в логи (возможно, в дальнейшем возможно будет логи (возможно, в дальнейшем возможно будет отключить эти плагины).
отключить эти плагины).
#### OpenWeatherMap #### OpenWeatherMap
Для работы погодного плагина, надо [заргистрироваться][5], [залогиниться][6] и Для работы погодного плагина, надо [заргистрироваться][5], [залогиниться][6] и [создать][7] api key. Free plan
[создать][7] api key. Free plan предлагает всё необхдимое для работы "плагина". предлагает всё необхдимое для работы "плагина".
Когда api key будет создан, его нужно вписать в **config.json** "секцию" Когда api key будет создан, его нужно вписать в **config.json** "секцию" openweathermap в качестве appid. На этом всё.
openweathermap в качестве appid. На этом всё.
#### Imgur #### Imgur
Этот плагин "просто есть" и его на самом деле ничто и никто не использует. И в Этот плагин "просто есть" и его на самом деле ничто и никто не использует. И в этой связи все настройки плагина можно
этой связи все настройки плагина можно оставить "как есть" в примере конфига. оставить "как есть" в примере конфига.
Тем не менее, если есть большое желание, то можно [залогиниться][8] и Тем не менее, если есть большое желание, то можно [залогиниться][8] и [зарегистрировать][9] бота как приложение, а
[зарегистрировать][9] бота как приложение, а потом разрешить приложению потом разрешить приложению пользоваться API-шкой, как описано в [этом][10] или [этом][11] мануале.
пользоваться API-шкой, как описано в [этом][10] или [этом][11] мануале.
#### Flickr #### Flickr
Этот "плагин" действительно используется для добычи ссылок на картинки в разных Этот "плагин" действительно используется для добычи ссылок на картинки в разных "картиночных" командах бота.
"картиночных" командах бота.
Есть скрипт, который поможет с регистрацией приложения в api Flickr - Есть скрипт, который поможет с регистрацией приложения в api Flickr - **bin/flickr_init.pl**, он достанет все нужные
**bin/flickr_init.pl**, он достанет все нужные ключи и секреты к ним. ключи и секреты к ним.
До запуска этого скрипта, бот должен быть забутстраплен через **`bootstrap.sh`**. До запуска этого скрипта, бот должен быть забутстраплен через **`bootstrap.sh`**.
[Залогиньтесь][11] и создайте [app][12] in своём Flicker-овском аккаунте. Далее, [Залогиньтесь][11] и создайте [app][12] in своём Flicker-овском аккаунте. Далее, *разлогиньтесь*, это нужно, чтобы
*разлогиньтесь*, это нужно, чтобы потом проще было достать параметр verifier. потом проще было достать параметр verifier.
Запишите [app key и secret][13] в **config.json**. Удостоверьтесь, что параметр Запишите [app key и secret][13] в **config.json**. Удостоверьтесь, что параметр "verifier" в конфиге либо закоменчен,
"verifier" в конфиге либо закоменчен, либо отсутствует. либо отсутствует.
Запустите **bin/flickr_init.pl** и следуте предлагаемым инструкциям - в итоге Запустите **bin/flickr_init.pl** и следуте предлагаемым инструкциям - в итоге будет дана ссылка, которую надо
будет дана ссылка, которую надо скопипастить в браузер. По ссылке предложат скопипастить в браузер. По ссылке предложат залогиниться, далее надо будет разрешить приложению просматривать профиль
залогиниться, далее надо будет разрешить приложению просматривать профиль и, и, через один-два редиректа, вы попадёте на example.com. Из адресной строки браузера надо скопировать параметр
через один-два редиректа, вы попадёте на example.com. Из адресной строки браузера "verifier" и вписать его в **config.json**.
надо скопировать параметр "verifier" и вписать его в **config.json**.
Чтобы сохранить в бд плагина API access token для нормальной работы "плагина", Чтобы сохранить в бд плагина API access token для нормальной работы "плагина", второй раз запустите
второй раз запустите **bin/flickr_init.pl**. На этом всё. **bin/flickr_init.pl**. На этом всё.
[1]: https://metacpan.org/pod/Telegram::Bot [1]: https://metacpan.org/pod/Telegram::Bot
[2]: https://metacpan.org/pod/Hailo [2]: https://metacpan.org/pod/Hailo