Compare commits

...

3 Commits

32 changed files with 5901 additions and 225 deletions

View File

@ -1,12 +1,14 @@
{ {
"name": "svoboda/negotiator", "name": "svoboda/svoboder",
"description": "Chat-robot negotiator of the Svoboda organization", "description": "Svoboda Telegram chat-robot",
"homepage": "https://git.svoboda.works/svoboda/negotiator", "homepage": "https://git.svoboda.works/svoboda/svoboder",
"type": "chat-robot", "type": "chat-robot",
"keywords": [ "keywords": [
"svoboda", "svoboda",
"telegram", "telegram",
"minimal" "minimal",
"baza",
"anarchism"
], ],
"readme": "README.md", "readme": "README.md",
"license": "WTFPL", "license": "WTFPL",
@ -19,26 +21,25 @@
} }
], ],
"support": { "support": {
"wiki": "https://git.svoboda.works/svoboda/negotiator/wiki", "wiki": "https://git.svoboda.works/svoboda/svoboder/wiki",
"issues": "https://git.svoboda.works/svoboda/negotiator/issues" "issues": "https://git.svoboda.works/svoboda/svoboder/issues"
}, },
"require": { "require": {
"php": "^8.4", "php": "^8.4",
"mirzaev/minimal": "^3.4.0", "mirzaev/minimal": "^3.4.0",
"mirzaev/baza": "^3.1.0",
"svoboda/time": "^1.0",
"badfarm/zanzara": "^0.9.1", "badfarm/zanzara": "^0.9.1",
"react/filesystem": "^0.1.2" "react/filesystem": "^0.1.2"
}, },
"require-dev": {
"phpunit/phpunit": "~9.5"
},
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"svoboda\\negotiator\\": "svoboda/negotiator/system" "svoboda\\svoboder\\": "svoboda/svoboder/system"
} }
}, },
"autoload-dev": { "autoload-dev": {
"psr-4": { "psr-4": {
"svoboda\\negotiator\\tests\\": "svoboda/negotiator/tests" "svoboda\\svoboder\\tests\\": "svoboda/svoboder/tests"
} }
}, },
"scripts": { "scripts": {

0
examples/demonstration_1_0_0.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 288 KiB

After

Width:  |  Height:  |  Size: 288 KiB

View File

@ -1,53 +0,0 @@
server {
listen 80;
listen [::]:80;
server_name negotiator.svoboda.works;
# 301 302
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
listen 443 quic;
listen [::]:443 ssl;
listen [::]:443 quic;
server_name negotiator.svoboda.works;
http2 on;
http3 on;
quic_gso on;
quic_retry on;
add_header Alt-Svc 'h3=":$server_port"; ma=86400';
add_header x-quic 'h3';
root /var/www/negotiator/svoboda/negotiator/system/public;
index index.php;
keepalive_timeout 60;
include snippets/ssl-params.conf;
include snippets/ssl-svoboda.conf;
include snippets/php8_4.conf;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|mp3|ogg|ogv|webm|htc|woff2|woff)$ {
expires 1M;
access_log off;
add_header Cache-Control "max-age=2629746, public";
}
location ~* \.(?:css|js|mjs|min)$ {
expires 1y;
access_log off;
add_header Cache-Control "max-age=31556952, public";
}
}

View File

@ -5,8 +5,8 @@ Wants=network.target
After=syslog.target network-online.target After=syslog.target network-online.target
[Service] [Service]
ExecStart=sudo -u www-data /usr/bin/php /var/www/project/svoboda/negotiator/system/public/telegram.php ExecStart=sudo -u www-data /usr/bin/php /var/www/project/svoboda/svoboder/system/public/telegram.php
PIDFile=/var/run/php/negotiator-telegram.pid PIDFile=/var/run/php/svoboder-telegram.pid
RemainAfterExit=no RemainAfterExit=no
RuntimeMaxSec=3600s RuntimeMaxSec=3600s
Restart=always Restart=always

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
if [ -d author/project ]; then if [ -d author/project ]; then
mv author/project author/negotiator mv author/project author/svoboder
fi fi
if [ -d author ]; then if [ -d author ]; then

View File

@ -1,21 +0,0 @@
<?php
declare(strict_types=1);
namespace svoboda\negotiator\models\enumerations;
/**
* Session
*
* Types of session verification
*
* @package svoboda\negotiator\models\enumerations
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author svoboda <mail@domain.zone>
*/
enum session
{
case hash_only;
case hash_else_address;
}

View File

@ -1,48 +0,0 @@
<?php
declare(strict_types=1);
namespace svoboda\negotiator\models;
// Framework for Telegram
use Zanzara\Zanzara,
Zanzara\Context as context,
Zanzara\Telegram\Type\Input\InputFile,
Zanzara\Telegram\Type\File\Document as telegram_document,
Zanzara\Middleware\MiddlewareNode as Node,
Zanzara\Telegram\Type\User as user;
// Built-in libraries
use exception;
/**
* Telegram
*
* @package svoboda\negotiator\models
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author svoboda <mail@domain.zone>
*/
final class telegram extends core
{
/**
* Society
*
* Responce for the command: "/society"
*
* @param context $ctx
*
* @return void
*/
public static function society(context $ctx): void
{
$ctx->sendPhoto(
new InputFile(STORAGE . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'mushroom.jpg'),
[
'caption' => 'why so shroomious',
'disable_notification' => true
]
);
}
}

View File

@ -1,61 +0,0 @@
<?php
declare(strict_types=1);
namespace svoboda\negotiator;
// Files of the project
use svoboda\negotiator\models\telegram;
// Framework for PHP
use mirzaev\minimal\core;
// Framework for Telegram
use Zanzara\Zanzara,
Zanzara\Context,
Zanzara\Config;
// Enabling debugging
/* ini_set('error_reporting', E_ALL);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1); */
// Initializing path to the public directory
define('INDEX', __DIR__);
// Initializing path to the project root directory
define('ROOT', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR);
// Initializing path to the directory of settings
define('SETTINGS', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'settings');
// Initializing path to the storage
define('STORAGE', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'storage');
// Initiailizing telegram key
define('TELEGRAM_KEY', require(SETTINGS . DIRECTORY_SEPARATOR . 'telegram.php'));
// Initializing dependencies
require ROOT . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
var_dump(TELEGRAM_KEY);
// Initializing core
$core = new core(namespace: __NAMESPACE__);
$config = new Config();
$config->setParseMode(Config::PARSE_MODE_MARKDOWN);
$config->useReactFileSystem(true);
$bot = new Zanzara(TELEGRAM_KEY, $config);
$bot->onUpdate(function (Context $ctx): void {
var_dump('biba');
});
/* $bot->onCommand('start', fn($ctx) => telegram::start($ctx)); */
$bot->onCommand('society', fn($ctx) => telegram::society($ctx));
// Starting chat-robot
$bot->run();

View File

@ -2,10 +2,10 @@
declare(strict_types=1); declare(strict_types=1);
namespace svoboda\negotiator\controllers; namespace svoboda\svoboder\controllers;
// Files of the project // Files of the project
use svoboda\negotiator\models\core as models; use svoboda\svoboder\models\core as models;
// Framework for PHP // Framework for PHP
use mirzaev\minimal\core as minimal, use mirzaev\minimal\core as minimal,
@ -16,7 +16,7 @@ use mirzaev\minimal\core as minimal,
/** /**
* Controllers core * Controllers core
* *
* @package svoboda\negotiator\controllers * @package svoboda\svoboder\controllers
* *
* @param language $language Language * @param language $language Language
* @param response $response Response * @param response $response Response

View File

@ -0,0 +1,189 @@
<?php
// Exit (success)
return [
// System
'svoboda' => 'Svoboda',
'empty' => 'Empty',
// Main menu
'menu_title' => 'Main menu',
'menu_accounts' => 'Accounts',
'menu_members' => 'Members',
'menu_distributions' => 'Distributions',
'menu_button_site' => 'Site',
'menu_button_map' => 'Map',
'menu_button_blog' => 'Blog',
'menu_button_projects' => 'Projects',
'menu_button_members' => 'Members',
'menu_button_distributions' => 'Distributions',
'menu_button_volunteering' => 'Become a volunteer',
'menu_button_message' => 'Send a message',
// Distributions
'distributions_title' => 'Registry of distributions',
'distributions_description' => '*Distribution* is an autonomous cell of Svoboda, representing any type of formation \(for example: commune\), but necessarily inherits the *Vhod* protocol and tied to a location',
'distributions_registered' => 'Registered',
'distributions_confirmed' => 'Confirmed',
'distributions_button_search' => 'Search',
'distributions_button_register' => 'Registrate',
// Language setting
'settings_select_language_title' => 'Select language',
'settings_select_language_description' => 'The selected language will be writed in your account settings',
'settings_language_update_success' => 'Language replaced:',
'settings_language_update_fail' => 'Failed to replace language',
// Repository
'repository_title' => 'Repository',
'repository_text' => <<<TXT
Svoboder is written in [PHP](https://www.php.net/) using [Zanzara](https://github.com/badfarm/zanzara) for Telegram,
my [MINIMAL](https://git.svoboda.works/mirzaev/minimal) framework for PHP and my [Baza](https://git.svoboda.works/mirzaev/baza) database
The code is under the [WTFPL](https://en.wikipedia.org/wiki/WTFPL) license
You can help me with the development, or use my code for free\!
TXT,
'repository_button_code' => 'The code',
'repository_button_issues' => 'Issues',
'repository_button_suggestions' => 'Suggestions',
// Author
'author_title' => 'Author',
'author_text' => <<<TXT
*Arsen Mirzaev Tatyano\-Muradovich*
Programmer, anarchist, vegetarian
TXT,
'author_button_neurojournal' => 'Neurojournal',
'author_button_projects' => 'Projects',
'author_button_twitter' => 'Twitter',
'author_button_bluesky' => 'Bluesky',
'author_button_bastyon' => 'Bastyon',
'author_button_youtube_english' => 'YouTube',
'author_button_youtube_russian' => 'YouTube',
'author_button_message' => 'Send a message',
// Language selection
'select_language_title' => 'Select language',
'select_language_description' => 'The selected language will be used in the current process',
'select_language_button_add' => 'Add a language',
// Distribution selection
'select_distributions_title' => 'Select distribution',
'select_distributions_description' => 'The selected distribution will be used in the current process',
'select_distribution_button_registrate' => 'Registrate a distribution',
// Distribution registration
'distribution_registration_started' => 'Process of the distribution registration started',
'distribution_registration_not_started' => 'Process of the distribution registration has not started',
'distribution_search_ended' => 'Process of the distribution registration ended',
'distribution_registration_continiued' => 'Process of the distribution registration found and continiued',
'distribution_registration_generation' => 'The distribution record generation',
'distribution_registration_created_distribution' => 'Created the distribution record in the database',
'distribution_registration_created_localization' => 'Created the distribution localization record in the database',
'distribution_registration_canceled' => 'Process of the distribution registration canceled',
'distribution_registration_completed' => 'Process of the distribution registration completed',
'distribution_registration_not_created_distribution' => 'Failed to create the distribution record in the database',
'distribution_registration_not_created_localization' => 'Failed to create the distribution localization record in the database',
'distribution_registration_button_language' => 'Language',
'distribution_registration_select_language_title' => 'Choose language',
'distribution_registration_select_language_description' => "The selected language will create a localization for users with the same language\n\nYou can create 1 localization for each language",
'distribution_registration_language_update_success' => 'Language replaced:',
'distribution_registration_language_update_fail' => 'Failed to replace language',
'distribution_registration_button_name' => 'Name',
'distribution_registration_name_request' => 'Enter name',
'distribution_registration_name_request_not_acceptable' => 'Failed to process the name',
'distribution_registration_name_request_too_short' => 'Name length must be \>\= 3 and \<\= 32',
'distribution_registration_name_request_too_long' => 'Name length must be \>\= 3 and \<\= 32',
'distribution_registration_name_request_spaces' => "No more than 2 spaces are allowed",
'distribution_registration_name_request_restricted_characters_title' => "Restricted any characters except letters",
'distribution_registration_name_request_restricted_characters_description' => "Remove these characters:",
'distribution_registration_name_update_success' => 'Name replaced:',
'distribution_registration_name_update_fail' => 'Failed to replace name',
'distribution_registration_button_location' => 'Location',
'distribution_registration_button_location_send' => 'Send location',
'distribution_registration_location_send_title' => 'Send location',
'distribution_registration_location_send_description' => "You now have a button on your main keyboard\nWhen you click on it, you can select a location on the map\n\n*Send latitude and longitude in the format:* 50\.969043, 9\.797588",
'distribution_registration_location_send_not_acceptable' => 'Failed to process the location',
'distribution_registration_location_send_latitude_too_small' => 'Latitude must be \>\= 0 and \<\=90',
'distribution_registration_location_send_latitude_too_big' => 'Latitude must be \>\= 0 and \<\=90',
'distribution_registration_location_send_longitude_too_small' => 'Longitude must be \>\= 0 and \<\=180',
'distribution_registration_location_send_longitude_too_big' => 'Longitude must be \>\= 0 and \<\=180',
'distribution_registration_location_update_success' => 'Location replaced:',
'distribution_registration_location_update_fail' => 'Failed to replace location',
'distribution_registration_button_confirm' => 'Confirm',
'distribution_registration_button_cancel' => 'Cancel',
// Distribution localization
'distribution_localization_started' => 'Registration of the distribution process started',
'distribution_localization_continiued' => 'Registration of the distribution process found and continiued',
'distribution_localization_created' => 'Created the distribution localization record in the database',
'distribution_localization_not_created' => 'Failed to create the distribution localization record in the database',
'distribution_localization_select_language_title' => 'Choose language',
'distribution_localization_select_language_description' => "The selected language will create a localization for users with the same language\n\nYou can create 1 localization for each language",
// Distribution search
'distribution_search_started' => 'Process of the distribution search started',
'distribution_search_not_started' => 'Process of the distribution search has not started',
'distribution_search_not_localized' => 'Failed to initialize the distribution localization',
'distribution_search_not_named' => 'No name',
'distribution_search_continiued' => 'Process of the distribution search found and continiued',
'distribution_search_empty' => 'No distributions found',
'distribution_search_title' => 'Distribution search',
'distribution_search_members' => 'Members',
'distribution_search_location' => 'Location',
'distribution_search_page_next_exists' => 'There are more distributions in the registry',
'distribution_search_page_next_not_exists' => 'There are no more distributions in the registry',
'distribution_search_button_text' => 'Text',
'distribution_search_text_request_title' => 'Enter search text',
'distribution_search_text_request_description' => 'Search will be conducted by names using the Levenshtein function',
'distribution_search_text_request_not_acceptable' => 'Failed to process the search text',
'distribution_search_text_request_too_short' => 'Search text length must be \>\= 3 and \<\= 64',
'distribution_search_text_request_too_long' => 'Search text length must be \>\= 3 and \<\= 64',
'distribution_search_text_request_restricted_characters_title' => "Restricted any characters except letters",
'distribution_search_text_request_restricted_characters_description' => "Remove these characters:",
'distribution_search_text_update_success' => 'Search text replaced:',
'distribution_search_text_update_fail' => 'Failed to replace search text',
'distribution_search_button_location' => 'Location',
'distribution_search_button_location_send' => 'Send location',
'distribution_search_location_send_title' => 'Send location',
'distribution_search_location_send_description' => "You now have a button on your main keyboard\nWhen you click on it, you can select a location on the map\n\n*Send latitude and longitude in the format:* 50\.969043, 9\.797588",
'distribution_search_location_send_not_acceptable' => 'Failed to process the location',
'distribution_search_location_send_latitude_too_small' => 'Latitude must be \>\= 0 and \<\=90',
'distribution_search_location_send_latitude_too_big' => 'Latitude must be \>\= 0 and \<\=90',
'distribution_search_location_send_longitude_too_small' => 'Longitude must be \>\= 0 and \<\=180',
'distribution_search_location_send_longitude_too_big' => 'Longitude must be \>\= 0 and \<\=180',
'distribution_search_location_update_success' => 'Location replaced:',
'distribution_search_location_update_fail' => 'Failed to replace location',
'distribution_search_button_distance' => 'Distance',
'distribution_search_distance_request_title' => 'Enter distance',
'distribution_search_distance_request_description' => 'Search will be performed within a radius of this value using the Vincenty formula',
'distribution_search_distance_request_not_acceptable' => 'Failed to process the distance',
'distribution_search_distance_request_too_short_km' => 'Distance value must be \>\= 0 and \<\= 600',
'distribution_search_distance_request_too_long_km' => 'Distance value must be \>\= 0 and \<\= 600',
'distribution_search_distance_request_restricted_characters_title' => "Restricted any characters except digitals",
'distribution_search_distance_request_restricted_characters_description' => "Delete these characters:",
'distribution_search_distance_update_success' => 'Distance replaced:',
'distribution_search_distance_update_fail' => 'Failed to replace distance',
'distribution_search_button_confirmed' => 'Confirmed',
'distribution_search_button_confirmed_all' => 'All',
'distribution_search_confirmed_update_success' => 'Filter by status replaced:',
'distribution_search_confirmed_update_fail' => 'Failed to replace filter by status',
'distribution_search_button_start' => 'Start the search',
'distribution_search_button_end' => 'End the search',
'distribution_search_button_page_next' => 'Next page',
'distribution_search_button_map' => 'Map',
'distribution_search_button_members' => 'Members',
'distribution_search_button_message' => 'Send a message',
'distribution_search_km' => 'km',
'distribution_search_mi' => 'ml',
// Authorization
'not_authorized_system' => 'You do not have access to the system',
'not_authorized_contact' => 'You do not have access to contact with the organisation',
'not_authorized_request' => 'You do not have access to requesting to the organisation',
'not_authorized_settings' => 'You do not have access to the settings',
'not_authorized_system_settings' => 'You do not have access to the system settings',
// Other
'why_so_shroomious' => 'why so shroomious',
];

View File

@ -0,0 +1,189 @@
<?php
// Exit (success)
return [
// Система
'svoboda' => 'Свобода',
'empty' => 'Пусто',
// Главное меню
'menu_title' => 'Главное меню',
'menu_accounts' => 'Аккаунты',
'menu_members' => 'Участники',
'menu_distributions' => 'Дистрибутивы',
'menu_button_site' => 'Сайт',
'menu_button_map' => 'Карта',
'menu_button_blog' => 'Блог',
'menu_button_projects' => 'Проекты',
'menu_button_members' => 'Участники',
'menu_button_distributions' => 'Дистрибутивы',
'menu_button_volunteering' => 'Стать волонтёром',
'menu_button_message' => 'Отправить сообщение',
// Дистрибутивы
'distributions_title' => 'Реестр дистрибутивов',
'distributions_description' => '*Дистрибутив* \- это автономная ячейка Свободы, являющаяся любым видом формирования \(например: коммуна\), но обязательно наследующая *Vhod* протокол, участвующая в глобальных процессах организации и привязанная к местоположению',
'distributions_registered' => 'Зарегистрировано',
'distributions_confirmed' => 'Подтверждено',
'distributions_button_search' => 'Поиск',
'distributions_button_register' => 'Зарегистрировать',
// Настройки языка
'settings_select_language_title' => 'Выбери язык',
'settings_select_language_description' => 'Выбранный язык будет записан в настройки аккаунта',
'settings_language_update_success' => 'Язык заменён:',
'settings_language_update_fail' => 'Не удалось заменить язык',
// Репозиторий
'repository_title' => 'Репозиторий',
'repository_text' => <<<TXT
Svoboder написан на [PHP](https://www.php.net/) используя [Zanzara](https://github.com/badfarm/zanzara) для Telegram,
мой [MINIMAL](https://git.svoboda.works/mirzaev/minimal) фреймворк для PHP и моя база данных [Baza](https://git.svoboda.works/mirzaev/baza)
Код находится под лицензией [WTFPL](https://en.wikipedia.org/wiki/WTFPL)
Помогай с разработкой или используй мой код бесплатно\!
TXT,
'repository_button_code' => 'Код',
'repository_button_issues' => 'Проблемы',
'repository_button_suggestions' => 'Предложения',
// Автор
'author_title' => 'Автор',
'author_text' => <<<TXT
*Арсен Мирзаев Татьяно\-Мурадович*
Программист, анархист, вегетарианец
TXT,
'author_button_neurojournal' => 'Нейрожурнал',
'author_button_projects' => 'Проекты',
'author_button_twitter' => 'Twitter',
'author_button_bluesky' => 'Bluesky',
'author_button_bastyon' => 'Bastyon',
'author_button_youtube_english' => 'YouTube',
'author_button_youtube_russian' => 'YouTube',
'author_button_message' => 'Отправить сообщение',
// Выбор языка
'select_language_title' => 'Выбери язык',
'select_language_description' => 'Выбранный язык будет использован в текущем процессе',
'select_language_button_add' => 'Добавить язык',
// Выбор дистрибутива
'select_distributions_title' => 'Выбери дистрибутив',
'select_distributions_description' => 'Выбранный дистрибутив будет использован в текущем процесса',
'select_distribution_button_registrate' => 'Зарегистрировать дистрибутив',
// Регистрация дистрибутива
'distribution_registration_started' => 'Процесс регистрации дистрибутива запущен',
'distribution_registration_not_started' => 'Процесс регистрации дистрибутива не запущен',
'distribution_registration_continiued' => 'Процесс регистрации дистрибутива найден и продолжен',
'distribution_registration_generation' => 'Генерация записи дистрибутива',
'distribution_registration_created_distribution' => 'Создана запись дистрибутива в базе данных',
'distribution_registration_created_localization' => 'Создана запись локализации дистрибутива в базе данных',
'distribution_registration_canceled' => 'Процесс регистрации дистрибутива отменён',
'distribution_registration_completed' => 'Процесс регистрации дистрибутива завершен',
'distribution_registration_not_created_distribution' => 'Не удалось создать запись дистрибутива в базе данных',
'distribution_registration_not_created_localization' => 'Не удалось создать запись локализации дистрибутива в базе данных',
'distribution_registration_button_language' => 'Язык',
'distribution_registration_select_language_title' => 'Выбери язык',
'distribution_registration_select_language_description' => "Выбранный язык позволит создать локализацию для пользователей с таким же языком\n\nТы можешь создать 1 локализацию для каждого языка",
'distribution_registration_language_update_success' => 'Язык заменён:',
'distribution_registration_language_update_fail' => 'Не удалось заменить язык',
'distribution_registration_button_name' => 'Название',
'distribution_registration_name_request' => 'Введи название',
'distribution_registration_name_request_not_acceptable' => 'Не удалось обработать название',
'distribution_registration_name_request_too_short' => 'Длина имени должна быть \>\= 3 и \<\= 32',
'distribution_registration_name_request_too_long' => 'Длина имени должна быть \>\= 3 и \<\= 32',
'distribution_registration_name_request_spaces' => "Разрешено использовать не более чем 2 пробела",
'distribution_registration_name_request_restricted_characters_title' => "Запрещены любые символы кроме букв",
'distribution_registration_name_request_restricted_characters_description' => "Удали эти символы:",
'distribution_registration_name_update_success' => 'Название заменено:',
'distribution_registration_name_update_fail' => 'Не удалось заменить название',
'distribution_registration_button_location' => 'Местоположение',
'distribution_registration_button_location_send' => 'Отправить местоположение',
'distribution_registration_location_send_title' => 'Отправь местоположение',
'distribution_registration_location_send_description' => "У тебя появилась кнопка на основной клавиатуре\nПри нажатии на неё можно будет выбрать локацию на карте\n\n*Пришли широту и долготу в формате:* 50\.969043, 9\.797588",
'distribution_registration_location_send_not_acceptable' => 'Не удалось обработать местоположение',
'distribution_registration_location_send_latitude_too_small' => 'Широта должна быть \>\= 0 и \<\=90',
'distribution_registration_location_send_latitude_too_big' => 'Широта должна быть \>\= 0 и \<\=90',
'distribution_registration_location_send_longitude_too_small' => 'Долгота должна быть \>\= 0 и \<\=180',
'distribution_registration_location_send_longitude_too_big' => 'Долгота должна быть \>\= 0 и \<\=180',
'distribution_registration_location_update_success' => 'Местоположение заменено:',
'distribution_registration_location_update_fail' => 'Не удалось заменить местоположение',
'distribution_registration_button_confirm' => 'Подтвердить',
'distribution_registration_button_cancel' => 'Отменить',
// Локализация дистрибутива
'distribution_localization_started' => 'Запущен процесс локализации дистрибутива',
'distribution_localization_continiued' => 'Найден и продолжен процесс локализации дистрибутива',
'distribution_localization_created' => 'Создана запись локализации дистрибутива в базе данных',
'distribution_localization_not_created' => 'Не удалось создать запись локализации дистрибутива в базе данных',
'distribution_localization_select_language_title' => 'Выбери язык',
'distribution_localization_select_language_description' => "Выбранный язык позволит создать локализацию для пользователей с таким же языком\n\nТы можешь создать 1 локализацию для каждого языка",
// Поиск дистрибутива
'distribution_search_started' => 'Процесс поиска дистрибутива запущен',
'distribution_search_not_started' => 'Процесс поиска дистрибутива не запущен',
'distribution_search_ended' => 'Процесс поиска дистрибутива завершён',
'distribution_search_not_localized' => 'Не удалось инициализировать локализацию дистрибутива',
'distribution_search_not_named' => 'Нет названия',
'distribution_search_continiued' => 'Процесс поиска дистрибутива найден и продолжен',
'distribution_search_empty' => 'Не найдены дистрибутивы',
'distribution_search_title' => 'Поиск дистрибутива',
'distribution_search_members' => 'Участники',
'distribution_search_location' => 'Местоположение',
'distribution_search_page_next_exists' => 'В реестре есть ещё дистрибутивы',
'distribution_search_page_next_not_exists' => 'В реестре больше нет дистрибутивов',
'distribution_search_button_text' => 'Текст',
'distribution_search_text_request_title' => 'Введи текст для поиска',
'distribution_search_text_request_description' => 'Поиск будет проводиться по названиям с использованием функции Левенштейна',
'distribution_search_text_request_not_acceptable' => 'Не удалось обработать поисковый текст',
'distribution_search_text_request_too_short' => 'Длина поскового текста должна быть \>\= 3 и \<\= 64',
'distribution_search_text_request_too_long' => 'Длина поискового текста должна быть \>\= 3 и \<\= 64',
'distribution_search_text_request_restricted_characters_title' => "Запрещены любые символы кроме букв",
'distribution_search_text_request_restricted_characters_description' => "Удали эти символы:",
'distribution_search_text_update_success' => 'Поисковый текст заменён:',
'distribution_search_text_update_fail' => 'Не удалось заменить поисковый текст',
'distribution_search_button_location' => 'Местоположение',
'distribution_search_button_location_send' => 'Отправить местоположение',
'distribution_search_location_send_title' => 'Отправь местоположение',
'distribution_search_location_send_description' => "У тебя появилась кнопка на основной клавиатуре\nПри нажатии на неё можно будет выбрать локацию на карте\n\n*Пришли широту и долготу в формате:* 50\.969043, 9\.797588",
'distribution_search_location_send_not_acceptable' => 'Не удалось обработать местоположение',
'distribution_search_location_send_latitude_too_small' => 'Широта должна быть \>\= 0 и \<\=90',
'distribution_search_location_send_latitude_too_big' => 'Широта должна быть \>\= 0 и \<\=90',
'distribution_search_location_send_longitude_too_small' => 'Долгота должна быть \>\= 0 и \<\=180',
'distribution_search_location_send_longitude_too_big' => 'Долгота должна быть \>\= 0 и \<\=180',
'distribution_search_location_update_success' => 'Местоположение заменено:',
'distribution_search_location_update_fail' => 'Не удалось заменить местоположение',
'distribution_search_button_distance' => 'Расстояние',
'distribution_search_distance_request_title' => 'Введи расстояние',
'distribution_search_distance_request_description' => 'Поиск будет производиться в радиусе от этого значения по формуле Винсенти',
'distribution_search_distance_request_not_acceptable' => 'Не удалось обработать расстояние',
'distribution_search_distance_request_too_short_km' => 'Длина расстояния должна быть \>\= 0 и \<\= 600',
'distribution_search_distance_request_too_long_km' => 'Длина расстояния должна быть \>\= 0 и \<\= 600',
'distribution_search_distance_request_restricted_characters_title' => "Запрещены любые символы кроме цифр",
'distribution_search_distance_request_restricted_characters_description' => "Удали эти символы:",
'distribution_search_distance_update_success' => 'Расстояние заменено:',
'distribution_search_distance_update_fail' => 'Не удалось заменить расстояние',
'distribution_search_button_confirmed' => 'Подтверждённые',
'distribution_search_button_confirmed_all' => 'Все',
'distribution_search_confirmed_update_success' => 'Фильтр по статусу заменён:',
'distribution_search_confirmed_update_fail' => 'Не удалось заменить фильтр по статусу',
'distribution_search_button_start' => 'Начать поиск',
'distribution_search_button_end' => 'Завершить поиск',
'distribution_search_button_page_next' => 'Следующая страница',
'distribution_search_button_map' => 'Карта',
'distribution_search_button_members' => 'Участники',
'distribution_search_button_message' => 'Отправить сообщение',
'distribution_search_km' => 'км',
'distribution_search_mi' => 'мл',
// Авторизация
'not_authorized_system' => 'У тебя нет доступа к системе',
'not_authorized_contact' => 'У тебя нет доступа к коммуникации с организацией',
'not_authorized_request' => 'У тебя нет доступа к отправке запросов в организацию',
'not_authorized_settings' => 'У тебя нет доступа к настройкам',
'not_authorized_system_settings' => 'У тебя нет доступа к системным настройкам',
// Прочее
'why_so_shroomious' => 'почему такой грибъёзный',
];

View File

@ -0,0 +1,210 @@
<?php
declare(strict_types=1);
namespace svoboda\svoboder\models;
// Files of the project
use svoboda\svoboder\models\core;
// Svoboda time
use svoboda\time\statement as svoboda;
// Baza database
use mirzaev\baza\database,
mirzaev\baza\column,
mirzaev\baza\record,
mirzaev\baza\enumerations\encoding,
mirzaev\baza\enumerations\type;
// Framework for Telegram
use Zanzara\Telegram\Type\User as telegram;
// Built-in libraries
use Exception as exception,
RuntimeException as exception_runtime;
/**
* Account
*
* @package svoboda\svoboder\models
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
final class account extends core
{
/**
* File
*
* @var string $database Path to the database file
*/
protected string $file = DATABASES . DIRECTORY_SEPARATOR . 'accounts.baza';
/**
* Database
*
* @var database $database The database
*/
public protected(set) database $database;
/**
* Constructor
*
* @return void
*/
public function __construct()
{
// Initializing the database
$this->database = new database()
->encoding(encoding::utf8)
->columns(
new column('identifier', type::integer_unsigned),
new column('identifier_telegram', type::integer),
new column('domain', type::string, ['length' => 32]),
new column('name_first', type::string, ['length' => 64]),
new column('name_second', type::string, ['length' => 64]),
new column('language', type::string, ['length' => 2]),
new column('robot', type::char),
new column('authorized_system', type::char),
new column('authorized_contact', type::char),
new column('authorized_request', type::char),
new column('authorized_settings', type::char),
new column('authorized_system_accounts', type::char),
new column('authorized_system_distributions', type::char),
new column('authorized_system_members', type::char),
/* new column('authorized_system_', type::char), */
new column('authorized_system_settings', type::char),
new column('created', type::integer_unsigned),
new column('updated', type::integer_unsigned)
)
->connect($this->file);
}
/**
* Initialize
*
* Searches for the account record in the database, and if it does not find it, it creates it
*
* @param telegram $telegram The telegram account
*
* @throws exception_runtime if update the account record in the database by the telegram account values
* @throws exception_runtime if failed to find the registered account
* @throws exception_runtime if failed to registrate the account
*
* @return record The account record from the database
*/
public function initialize(telegram $telegram): record
{
// Searching for the account in the database
$account = $this->database->read(filter: fn(record $record) => $record->identifier_telegram === $telegram->getId(), amount: 1)[0] ?? null;
if ($account instanceof record) {
// Found the account record
if (
$account->name_first !== $telegram->getFirstName() ||
$account->name_second !== $telegram->getLastName() ||
$account->domain !== $telegram->getUsername()
) {
// The telegram account was updated
// Updating the account in the database
$updated = $this->database->read(
filter: fn(record $record) => $record->identifier_telegram === $telegram->getId(),
update: function (record &$record) use ($telegram){
// Writing new values into the record
$record->name_first = $telegram->getFirstName();
$record->name_second = $telegram->getLastName();
$record->domain = $telegram->getUsername();
$record->updated = svoboda::timestamp();
},
amount: 1
)[0] ?? null;
if ($updated instanceof record && $updated->values() !== $account->values()) {
// Updated the account in the database
// Exit (success)
return $updated;
} else {
// Not updated the account in the database
// Exit (fail)
throw new exception_runtime('Failed to update the account record in the database by the telegram account values');
}
}
// Exit (success)
return $account;
} else {
// Not found the account record
if ($this->registrate($telegram)) {
// Registered the account
// Searching for the registered account in the database
$account = $this->database->read(filter: fn(record $record) => $record->identifier_telegram === $telegram->getId(), amount: 1)[0] ?? null;
if ($account instanceof record) {
// Found the registered account
// Exit (success)
return $account;
} else {
// Not found the registered account
// Exit (fail)
throw new exception_runtime('Failed to find the registered account');
}
} else {
// Not registered the account
// Exit (fail)
throw new exception_runtime('Failed to registrate the account');
}
}
}
/**
* Registrate
*
* Creates the account record in the database
*
* @param telegram $telegram The telegram account
*
* @return int|false The record identifier, if created
*/
public function registrate(telegram $telegram): int|false
{
// Initializing the identifier
$identifier = $this->database->count() + 1;
// Initializing the record
$record = $this->database->record(
$identifier,
(int) $telegram->getId(),
$telegram->getFirstName(),
$telegram->getLastName(),
$telegram->getUsername(),
$telegram->getLanguageCode(),
(int) $telegram->isBot(),
1,
1,
1,
1,
0,
0,
0,
0,
svoboda::timestamp(),
svoboda::timestamp()
);
// Creating the accound record in the database
$created = $this->database->write($record);
// Exit (success)
return $created ? $identifier : false;
}
}

View File

@ -2,39 +2,31 @@
declare(strict_types=1); declare(strict_types=1);
namespace svoboda\negotiator\models; namespace svoboda\svoboder\models;
// Framework for PHP // Framework for PHP
use mirzaev\minimal\model; use mirzaev\minimal\model;
// Baza database
use mirzaev\baza\database,
mirzaev\baza\column,
mirzaev\baza\enumerations\encoding;
// Built-in libraries // Built-in libraries
use exception; use exception;
/** /**
* Models core * Core
* *
* @package svoboda\negotiator\models * @package svoboda\svoboder\models
* *
* @method void __construct(bool $initialize) Constructor * @method void __construct() Constructor
* *
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License * @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author svoboda <mail@domain.zone> * @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/ */
class core extends model class core extends model
{ {
/**
* Constructor
*
* @param bool $initialize Initialize a model?
*
* @return void
*/
public function __construct(bool $initialize = true)
{
// For the extends system
parent::__construct($initialize);
}
/** /**
* Write * Write
* *

View File

@ -0,0 +1,106 @@
<?php
declare(strict_types=1);
namespace svoboda\svoboder\models;
// Files of the project
use svoboda\svoboder\models\core;
// Svoboda time
use svoboda\time\statement as svoboda;
// Baza database
use mirzaev\baza\database,
mirzaev\baza\column,
mirzaev\baza\record,
mirzaev\baza\enumerations\encoding,
mirzaev\baza\enumerations\type;
// Framework for Telegram
use Zanzara\Telegram\Type\User as telegram;
// Built-in libraries
use Exception as exception,
RuntimeException as exception_runtime;
/**
* Distribution
*
* @package svoboda\svoboder\models
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
final class distribution extends core
{
/**
* File
*
* @var string $database Path to the database file
*/
protected string $file = DATABASES . DIRECTORY_SEPARATOR . 'distributions.baza';
/**
* Database
*
* @var database $database The database
*/
public protected(set) database $database;
/**
* Constructor
*
* @return void
*/
public function __construct()
{
// Initializing the database
$this->database = new database()
->encoding(encoding::ascii)
->columns(
new column('identifier', type::integer_unsigned),
new column('creator', type::integer_unsigned),
new column('accepted', type::char),
new column('latitude', type::float),
new column('longitude', type::float),
new column('created', type::integer_unsigned),
new column('updated', type::integer_unsigned)
)
->connect($this->file);
}
/**
* Create
*
* Creates the distribution record in the database
*
* @param int $creator Identifier of the creator account
* @param float $latitude Latitude
* @param float $longitude Longitude
*
* @return int|false The record identifier, if created
*/
public function create(int $creator, float $latitude = 0, float $longitude = 0): int|false
{
// Initializing the identifier
$identifier = $this->database->count() + 1;
// Initializing the record
$record = $this->database->record(
$identifier,
$creator,
0,
$latitude,
$longitude,
svoboda::timestamp(),
svoboda::timestamp()
);
// Creating the accound record in the database
$created = $this->database->write($record);
// Exit (success)
return $created ? $identifier : false;
}
}

View File

@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
namespace svoboda\svoboder\models\enumerations;
/**
* Entity
*
* Types of entities
*
* @package svoboda\svoboder\models\enumerations
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
enum entity
{
case account;
case distribution;
}

View File

@ -2,18 +2,17 @@
declare(strict_types=1); declare(strict_types=1);
namespace svoboda\negotiator\models\enumerations; namespace svoboda\svoboder\models\enumerations;
/** /**
* Language * Language
* *
* Types of languages by ISO 639-1 standart * Types of languages by ISO 639-1 standart
* *
* @package svoboda\negotiator\models\enumerations * @package svoboda\svoboder\models\enumerations
* *
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License * @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy> * @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
* @author svoboda <mail@domain.zone>
*/ */
enum language enum language
{ {
@ -28,10 +27,6 @@ enum language
* @param language|null $language Language into which to translate * @param language|null $language Language into which to translate
* *
* @return string Translated label of the language * @return string Translated label of the language
*
* @todo
* 1. More languages
* 2. Cases???
*/ */
public function label(?language $language = language::en): string public function label(?language $language = language::en): string
{ {
@ -47,4 +42,20 @@ enum language
} }
}; };
} }
/**
* Flag
*
* Initialize the flag emoji of the language
*
* @return string The flag emoji of the language
*/
public function flag(): string
{
// Exit (success)
return match ($this) {
language::en => '🇺🇸',
language::ru => '🇷🇺'
};
}
} }

View File

@ -0,0 +1,105 @@
<?php
declare(strict_types=1);
namespace svoboda\svoboder\models\localizations;
// Files of the project
use svoboda\svoboder\models\core,
svoboda\svoboder\models\enumerations\language;
// Svoboda time
use svoboda\time\statement as svoboda;
// Baza database
use mirzaev\baza\database,
mirzaev\baza\column,
mirzaev\baza\record,
mirzaev\baza\enumerations\encoding,
mirzaev\baza\enumerations\type;
// Framework for Telegram
use Zanzara\Telegram\Type\User as telegram;
// Built-in libraries
use Exception as exception,
RuntimeException as exception_runtime;
/**
* Distribution
*
* @package svoboda\svoboder\models\localizations
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
final class distribution extends core
{
/**
* File
*
* @var string $database Path to the database file
*/
protected string $file = DATABASES . DIRECTORY_SEPARATOR . 'localizations' . DIRECTORY_SEPARATOR . 'distributions.baza';
/**
* Database
*
* @var database $database The database
*/
public protected(set) database $database;
/**
* Constructor
*
* @return void
*/
public function __construct()
{
// Initializing the database
$this->database = new database()
->encoding(encoding::utf8)
->columns(
new column('identifier', type::integer_unsigned),
new column('distribution', type::integer_unsigned),
new column('language', type::string, ['length' => 2]),
new column('name', type::string, ['length' => 32]),
new column('created', type::integer_unsigned),
new column('updated', type::integer_unsigned)
)
->connect($this->file);
}
/**
* Create
*
* Creates the distribution localization record in the database
*
* @param int $distribution Identifier of the distribution
* @param language $language Language
* @param string $name Name
*
* @return int|false The record identifier, if created
*/
public function create(int $distribution, language $language, string $name): int|false
{
// Initializing the identifier
$identifier = $this->database->count() + 1;
// Initializing the record
$record = $this->database->record(
$identifier,
$distribution,
$language->name,
$name,
svoboda::timestamp(),
svoboda::timestamp()
);
// Creating the accound record in the database
$created = $this->database->write($record);
// Exit (success)
return $created ? $identifier : false;
}
}

View File

@ -0,0 +1,276 @@
<?php
declare(strict_types=1);
namespace svoboda\svoboder\models\telegram\buttons\distribution;
// Files of the project
use svoboda\svoboder\models\core,
svoboda\svoboder\models\account,
svoboda\svoboder\models\distribution,
svoboda\svoboder\models\telegram\selections,
svoboda\svoboder\models\telegram\processes\distribution\registration as process_distribution_registration,
svoboda\svoboder\models\localization\distribution as distribution_localization,
svoboda\svoboder\models\enumerations\language;
// Framework for Telegram
use Zanzara\Context as context,
Zanzara\Telegram\Type\Message as message;
// Baza database
use mirzaev\baza\record;
/**
* Telegram distribution registration buttons
*
* @package svoboda\svoboder\models\telegram\buttons\distribution
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
final class registration extends core
{
/**
* Language
*
* Send the language selection menu
*
* @param context $context Request data from Telegram
*
* @return void
*/
public static function language(context $context)
{
// Initializing the account
$account = $context->get('account');
if ($account instanceof record) {
// Initialized the account
// Initializing language
$language = $context->get('language');
if ($language) {
// Initialized language
// Initializing localization
$localization = $context->get('localization');
if ($localization) {
// Initialized localization
// Reading from the telegram user buffer
$context->getUserDataItem('distribution_registration')
->then(function ($distribution) use ($context, $account, $localization) {
// Readed from the telegram user buffer
if ($distribution) {
// Found started registration process
// Sending the language selection
selections::language(
context: $context,
prefix: 'distribution_registration_select_language_',
title: '🌏 *' . $localization['distribution_registration_select_language_title'] . '*',
description: '🌏 *' . $localization['distribution_registration_select_language_description'] . '*'
);
} else {
// Not found started registration process
// Sending the message
$context->sendMessage('⚠️ *' . $localization['distribution_registration_not_started'] . '*');
}
});
} else {
// Not initialized localization
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize localization*')
->then(function ($message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
} else {
// Not initialized language
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize language*')
->then(function ($message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
} else {
// Not initialized the account
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
->then(function ($message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
}
/**
* Name
*
* Request to enter name
*
* @param context $context Request data from Telegram
*
* @return void
*/
public static function name(context $context)
{
// Initializing the account
$account = $context->get('account');
if ($account instanceof record) {
// Initialized the account
// Initializing localization
$localization = $context->get('localization');
if ($localization) {
// Initialized localization
// Reading from the telegram user buffer
$context->getUserDataItem('distribution_registration')
->then(function ($distribution) use ($context, $account, $localization) {
// Readed from the telegram user buffer
if ($distribution) {
// Found started registration process
// Sending the message
$context->sendMessage('📄 *' . $localization['distribution_registration_name_request'] . '*')
->then(function (message $message) use ($context) {
// Sended the message
// Writing into the distribution registration buffer
$context->nextStep([process_distribution_registration::class, 'name']);
});
} else {
// Not found started registration process
// Sending the message
$context->sendMessage('⚠️ *' . $localization['distribution_registration_not_started'] . '*');
}
});
} else {
// Not initialized localization
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize localization*')
->then(function ($message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
} else {
// Not initialized the account
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
->then(function ($message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
}
/**
* Location
*
* Request to send location
*
* @param context $context Request data from Telegram
*
* @return void
*/
public static function location(context $context)
{
// Initializing the account
$account = $context->get('account');
if ($account instanceof record) {
// Initialized the account
// Initializing localization
$localization = $context->get('localization');
if ($localization) {
// Initialized localization
// Reading from the telegram user buffer
$context->getUserDataItem('distribution_registration')
->then(function ($distribution) use ($context, $account, $localization) {
// Readed from the telegram user buffer
if ($distribution) {
// Found started registration process
// Initializing the message title
$title = '🗺 *' . $localization['distribution_registration_location_send_title'] . '*';
// Initializing the message description
$description = $localization['distribution_registration_location_send_description'];
// Sending the message
$context->sendMessage(
<<<TXT
$title
$description
TXT,
[
'reply_markup' => [
'keyboard' => [
[
[
'text' => '🗺 ' . $localization['distribution_registration_button_location_send'],
'request_location' => true
]
],
],
'disable_notification' => true
]
]
)->then(function (message $message) use ($context) {
// Sended the message
// Writing into the distribution registration buffer
$context->nextStep([process_distribution_registration::class, 'location']);
});
} else {
// Not found started registration process
// Sending the message
$context->sendMessage('⚠️ *' . $localization['distribution_registration_not_started'] . '*');
}
});
} else {
// Not initialized localization
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize localization*')
->then(function ($message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
} else {
// Not initialized the account
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
->then(function ($message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
}
}

View File

@ -0,0 +1,281 @@
<?php
declare(strict_types=1);
namespace svoboda\svoboder\models\telegram\buttons\distribution;
// Files of the project
use svoboda\svoboder\models\core,
svoboda\svoboder\models\account,
svoboda\svoboder\models\distribution,
svoboda\svoboder\models\telegram\selections,
svoboda\svoboder\models\telegram\processes\distribution\search as process_distribution_search,
svoboda\svoboder\models\localization\distribution as distribution_localization,
svoboda\svoboder\models\enumerations\language;
// Framework for Telegram
use Zanzara\Context as context,
Zanzara\Telegram\Type\Message as message;
// Baza database
use mirzaev\baza\record;
/**
* Telegram distribution search buttons
*
* @package svoboda\svoboder\models\telegram\buttons\distribution
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
final class search extends core
{
/**
* Text
*
* Request to enter search text
*
* @param context $context Request data from Telegram
*
* @return void
*/
public static function text(context $context)
{
// Initializing the account
$account = $context->get('account');
if ($account instanceof record) {
// Initialized the account
// Initializing localization
$localization = $context->get('localization');
if ($localization) {
// Initialized localization
// Reading from the telegram user buffer
$context->getUserDataItem('distribution_search')
->then(function ($search) use ($context, $account, $localization) {
// Readed from the telegram user buffer
if ($search) {
// Found started search process
// Initializing title for the message
$title = '📄 *' . $localization['distribution_search_text_request_title'] . '*';
// Initializing description for the message
$description = $localization['distribution_search_text_request_description'];
// Sending the message
$context->sendMessage(<<<TXT
$title
$description
TXT)
->then(function (message $message) use ($context) {
// Sended the message
// Writing into the distribution search buffer
$context->nextStep([process_distribution_search::class, 'text']);
});
} else {
// Not found started search process
// Sending the message
$context->sendMessage('⚠️ *' . $localization['distribution_search_not_started'] . '*');
}
});
} else {
// Not initialized localization
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize localization*')
->then(function ($message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
} else {
// Not initialized the account
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
->then(function ($message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
}
/**
* Location
*
* Request to send location
*
* @param context $context Request data from Telegram
*
* @return void
*/
public static function location(context $context)
{
// Initializing the account
$account = $context->get('account');
if ($account instanceof record) {
// Initialized the account
// Initializing localization
$localization = $context->get('localization');
if ($localization) {
// Initialized localization
// Reading from the telegram user buffer
$context->getUserDataItem('distribution_search')
->then(function ($search) use ($context, $account, $localization) {
// Readed from the telegram user buffer
if ($search) {
// Found started search process
// Initializing the message title
$title = '🗺 *' . $localization['distribution_search_location_send_title'] . '*';
// Initializing the message description
$description = $localization['distribution_search_location_send_description'];
// Sending the message
$context->sendMessage(
<<<TXT
$title
$description
TXT,
[
'reply_markup' => [
'keyboard' => [
[
[
'text' => '🗺 ' . $localization['distribution_search_button_location_send'],
'request_location' => true
]
],
],
'disable_notification' => true
]
]
)->then(function (message $message) use ($context) {
// Sended the message
// Writing into the distribution search buffer
$context->nextStep([process_distribution_search::class, 'location']);
});
} else {
// Not found started search process
// Sending the message
$context->sendMessage('⚠️ *' . $localization['distribution_search_not_started'] . '*');
}
});
} else {
// Not initialized localization
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize localization*')
->then(function ($message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
} else {
// Not initialized the account
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
->then(function ($message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
}
/**
* Distance
*
* Request to send distance
*
* @param context $context Request data from Telegram
*
* @return void
*/
public static function distance(context $context)
{
// Initializing the account
$account = $context->get('account');
if ($account instanceof record) {
// Initialized the account
// Initializing localization
$localization = $context->get('localization');
if ($localization) {
// Initialized localization
// Reading from the telegram user buffer
$context->getUserDataItem('distribution_search')
->then(function ($search) use ($context, $account, $localization) {
// Readed from the telegram user buffer
if ($search) {
// Found started search process
// Initializing the message title
$title = '🔭 *' . $localization['distribution_search_distance_request_title'] . '* \(' . $localization['distribution_search_km'] . '\)';
// Initializing the message description
$description = $localization['distribution_search_distance_request_description'];
// Sending the message
$context->sendMessage(
<<<TXT
$title
$description
TXT
)->then(function (message $message) use ($context) {
// Sended the message
// Writing into the distribution search buffer
$context->nextStep([process_distribution_search::class, 'distance']);
});
} else {
// Not found started search process
// Sending the message
$context->sendMessage('⚠️ *' . $localization['distribution_search_not_started'] . '*');
}
});
} else {
// Not initialized localization
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize localization*')
->then(function ($message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
} else {
// Not initialized the account
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
->then(function ($message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
}
}

View File

@ -0,0 +1,611 @@
<?php
declare(strict_types=1);
namespace svoboda\svoboder\models\telegram;
// Files of the project
use svoboda\svoboder\models\core,
svoboda\svoboder\models\account,
svoboda\svoboder\models\distribution,
svoboda\svoboder\models\telegram\selections,
svoboda\svoboder\models\enumerations\language;
// Framework for Telegram
use Zanzara\Context as context,
Zanzara\Telegram\Type\Message as message,
Zanzara\Telegram\Type\Input\InputFile as file_input;
// Baza database
use mirzaev\baza\record;
/**
* Telegram commands
*
* @package svoboda\svoboder\models\telegram
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
final class commands extends core
{
/**
* Menu
*
* Responce for the commands: "/start", '/menu'
*
* @param context $context Request data from Telegram
*
* @return void
*/
public static function menu(context $context): void
{
// Initializing the account
$account = $context->get('account');
if ($account instanceof record) {
// Initialized the account
// Initializing localization
$localization = $context->get('localization');
if ($localization) {
// Initialized localization
// Initializing the title
$title = '📋 *' . $localization['menu_title'] . '*';
// Initializing accounts
$accounts = '*' . $localization['menu_accounts'] . '* ' . ((new account)->database->count() ?? 0);
// Initializing members
$members = '*' . $localization['menu_members'] . '* ' . 0;
// Initializing distributions
$distributions = '*' . $localization['menu_distributions'] . '* ' . ((new distribution)->database->count() ?? 0);
// Sending the message
$context->sendMessage(
<<<TXT
$title
$accounts
$members
$distributions
TXT,
[
'reply_markup' => [
'inline_keyboard' => [
[
[
'text' => '📺 ' . $localization['menu_button_site'],
'url' => 'https://svoboda.works'
],
[
'text' => '🗺 ' . $localization['menu_button_map'],
'web_app' => [
'url' => 'https://telegram.map.svoboda.works'
]
],
/* [
'text' => '🔥 ' . $localization['menu_button_blog'],
'url' => 'https://t.me/svoboder_bot'
] */
],
[
/* [
'text' => '🏗 ' . $localization['menu_button_projects'],
'callback_data' => 'prjects'
], */
/* [
'text' => '🐣 ' . $localization['menu_button_members'],
'callback_data' => 'message'
], */
[
'text' => '🏘 ' . $localization['menu_button_distributions'],
'callback_data' => 'distributions'
]
],
[
/* [
'text' => '🤟 ' . $localization['menu_button_volunteering'],
'callback_data' => 'volunteering'
], */
[
'text' => '✉️ ' . $localization['menu_button_message'],
'callback_data' => 'message'
]
]
],
'disable_notification' => true,
'remove_keyboard' => true
],
]
)
->then(function (message $message) use ($context) {
// Sended the message
});
} else {
// Not initialized localization
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize localization*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
} else {
// Not initialized the account
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
}
/**
* Message
*
* Responce for the command: "/message"
*
* Start a process for creating message
*
* @param context $context Request data from Telegram
*
* @return void
*/
public static function message(context $context): void
{
// Initializing the account
$account = $context->get('account');
if ($account instanceof record) {
// Initialized the account
// Initializing the title
$title = '';
// Sending the message
$context->sendMessage(<<<TXT
*⚠️ Failed to initialize your Telegram account*
TXT)
->then(function (message $message) use ($context) {
//
});
} else {
// Not initialized the account
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
}
/**
* Distributions
*
* Responce for the command: "/distributions"
*
* Sends the distributions menu
*
* @param context $context Request data from Telegram
*
* @return void
*/
public static function distributions(context $context): void
{
// Initializing the account
$account = $context->get('account');
if ($account instanceof record) {
// Initialized the account
// Initializing language
$language = $context->get('language');
if ($language instanceof language) {
// Initialized language
// Initializing localization
$localization = $context->get('localization');
if ($localization) {
// Initialized localization
// Initializing the message title
$title = '🏘 *' . $localization['distributions_title'] . '*';
// Initializing the message description
$description = $localization['distributions_description'];
// Initializing the distribution model
$model = new distribution;
// Initializing the message "registered" row
$registered = '*' . $localization['distributions_registered'] . ':* ' . $model->database->count();
// Initializing the message "confirmed" row
$confirmed = '*' . $localization['distributions_confirmed'] . ':* ' . count($model->database->read(
filter: fn(record $record) => $record->confirmed,
amount: 1000
));
// Sending the message
$context->sendMessage(
<<<TXT
$title
$registered
$confirmed
$description
TXT,
[
'reply_markup' => [
'inline_keyboard' => [
[
[
'text' => '📋 ' . $localization['distributions_button_register'],
'callback_data' => 'distribution_registration_start'
],
[
'text' => '🔎 ' . $localization['distributions_button_search'],
'callback_data' => 'distribution_search_start'
]
]
],
'disable_notification' => true,
'remove_keyboard' => true
],
]
);
} else {
// Not initialized localization
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize localization*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
} else {
// Not initialized language
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize language*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
} else {
// Not initialized the account
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
}
/**
* Language
*
* Responce for the command: "/language"
*
* Send the language selection menu
*
* @param context $context Request data from Telegram
*
* @return void
*/
public static function language(context $context): void
{
// Initializing the account
$account = $context->get('account');
if ($account instanceof record) {
// Initialized the account
// Initializing language
$language = $context->get('language');
if ($language instanceof language) {
// Initialized language
// Initializing localization
$localization = $context->get('localization');
if ($localization) {
// Initialized localization
// Sending the language selection
selections::language(
context: $context,
prefix: 'settings_language_',
title: '🌏 *' . $localization['settings_select_language_title'] . '*',
description: '🌏 *' . $localization['settings_select_language_description'] . '*'
);
} else {
// Not initialized localization
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize localization*')
->then(function (message $message) use ($context) {
// Sended the message
// Ending the conversation process
$context->endConversation();
});
}
} else {
// Not initialized language
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize language*')
->then(function (message $message) use ($context) {
// Sended the message
// Ending the conversation process
$context->endConversation();
});
}
} else {
// Not initialized the account
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
->then(function (message $message) use ($context) {
// Sended the message
// Ending the conversation process
$context->endConversation();
});
}
}
/**
* Repository
*
* Responce for the command: "/repository"
*
* Sends information about project and menu
*
* @param context $context Request data from Telegram
*
* @return void
*/
public static function repository(context $context): void
{
// Initializing the account
$account = $context->get('account');
if ($account instanceof record) {
// Initialized the account
// Initializing localization
$localization = $context->get('localization');
if ($localization) {
// Initialized localization
// Initializing title of the message
$title = '🏛️ ' . $localization['repository_title'];
// Sending the message
$context->sendMessage($title . "\n\n" . $localization['repository_text'], [
'reply_markup' => [
'inline_keyboard' => [
[
[
'text' => '🏛️ ' . $localization['repository_button_code'],
'url' => 'https://git.mirzaev.sexy/mirzaev/mashtrash'
]
],
[
[
'text' => '⚠️ ' . $localization['repository_button_issues'],
'url' => 'https://git.mirzaev.sexy/mirzaev/mashtrash/issues'
],
[
'text' => '🌱 ' . $localization['repository_button_suggestions'],
'url' => 'https://git.mirzaev.sexy/mirzaev/mashtrash/issues'
]
]
],
'remove_keyboard' => true,
'disable_notification' => true
],
'link_preview_options' => [
'is_disabled' => true
]
]);
} else {
// Not initialized localization
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize localization*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
} else {
// Not initialized the account
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
}
/**
* Author
*
* Responce for the command: "/author"
*
* Sends
*
* @param context $context Request data from Telegram
*
* @return void
*/
public static function author(context $context): void
{
// Initializing the account
$account = $context->get('account');
if ($account instanceof record) {
// Initialized the account
// Initializing localization
$localization = $context->get('localization');
if ($localization) {
// Initialized localization
// Initializing title of the message
$title = '👽 ' . $localization['author_title'];
// Sending the message
$context->sendMessage($title . "\n\n" . $localization['author_text'], [
'reply_markup' => [
'inline_keyboard' => [
[
[
'text' => '📚 ' . $localization['author_button_neurojournal'],
'url' => 'https://mirzaev.sexy'
],
[
'text' => '🤟 ' . $localization['author_button_projects'],
'url' => 'https://git.svoboda.works/mirzaev?tab=activity'
]
],
[
[
'text' => '✖️ ' . $localization['author_button_twitter'],
'url' => 'https://x.com/mirzaev_sexy'
],
[
'text' => '🦋 ' . $localization['author_button_bluesky'],
'url' => 'https://bsky.app/profile/mirzaev.bsky.social'
],
[
'text' => '⛓️ ' . $localization['author_button_bastyon'],
'url' => 'https://bsky.app/profile/mirzaev.bsky.social'
]
],
[
[
'text' => '🇺🇸 ' . $localization['author_button_youtube_english'],
'url' => 'https://www.youtube.com/@MIRZAEV'
],
[
'text' => '🇷🇺 ' . $localization['author_button_youtube_russian'],
'url' => 'https://www.youtube.com/@MIRZAEV'
]
],
[
[
'text' => '✉️ ' . $localization['author_button_message'],
'url' => 'https://t.me/mirzaev_sexy'
]
]
],
'remove_keyboard' => true,
'disable_notification' => true
],
'link_preview_options' => [
'is_disabled' => true
]
]);
} else {
// Not initialized localization
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize localization*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
} else {
// Not initialized the account
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
}
/**
* Society
*
* Responce for the command: "/society"
*
* Sends the "mushroom" image and the localized text "why so shroomious"
*
* @param context $context Request data from Telegram
*
* @return void
*/
public static function society(context $context): void
{
// Initializing the account
$account = $context->get('account');
if ($account instanceof record) {
// Initialized the account
// Initializing localization
$localization = $context->get('localization');
if ($localization) {
// Initialized localization
// Sending the message
$context->sendPhoto(
new file_input(STORAGE . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'mushroom.jpg'),
[
'caption' => $localization['why_so_shroomious'],
'disable_notification' => true
]
);
} else {
// Not initialized localization
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize localization*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
} else {
// Not initialized the account
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
}
}

View File

@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
namespace svoboda\svoboder\models\telegram;
// Files of the project
use svoboda\svoboder\models\core,
svoboda\svoboder\models\account,
svoboda\svoboder\models\distribution as model,
svoboda\svoboder\models\localization\distribution as distribution_localization,
svoboda\svoboder\models\enumerations\language;
// Framework for Telegram
use Zanzara\Context as context,
Zanzara\Telegram\Type\Message as message;
// Baza database
use mirzaev\baza\record;
/**
* Telegram distribution
*
* @package svoboda\svoboder\models\telegram
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
final class distribution extends core {}

View File

@ -0,0 +1,548 @@
<?php
declare(strict_types=1);
namespace svoboda\svoboder\models\telegram;
// Files of the project
use svoboda\svoboder\models\core,
svoboda\svoboder\models\account,
svoboda\svoboder\models\enumerations\language;
// Framework for Telegram
use Zanzara\Context as context,
Zanzara\Telegram\Type\Message as message,
Zanzara\Middleware\MiddlewareNode as node;
// Baza database
use mirzaev\baza\record;
// Built-in libraries
use Error as error;
/**
* Telegram middlewares
*
* @package svoboda\svoboder\models\telegram
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
final class middlewares extends core
{
/**
* Account (middleware)
*
* Initialize or registrate the account and write it to the `account` variable inside the `$context`
*
* @param context $context
* @param node $next
*
* @return void
*/
public static function account(context $context, node $next): void
{
// Is the process stopped?
if ($context->get('stop')) return;
// Initializing the telegram account
$telegram = $context->getEffectiveUser();
// Initializing the account
/* $account = new account()->initialize($telegram); */
$account = (new account())->initialize($telegram);
if ($account instanceof record) {
// Initialized the account
// Writing the account into the context variable
$context->set('account', $account);
// Continuation of the process
$next($context);
} else {
// Not initialized the account
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
}
/**
* Language (middleware)
*
* Implement the account language
*
* @param context $context
* @param node $next
*
* @return void
*/
public static function language(context $context, node $next): void
{
// Is the process stopped?
if ($context->get('stop')) return;
// Initializing the account
$account = $context->get('account');
if ($account instanceof record) {
// Initialized the account
if ($account->language) {
// Initialized the language parameter
try {
// Writing the account language into the context variable
$context->set('language', language::{$account->language});
} catch (error $error) {
// Not initialized the language
// Writing the default language into the context variable
$context->set('language', language::en);
}
} else {
// Not initialized the language parameter
// Writing the default language into the context variable
$context->set('language', language::en);
}
// Continuation of the process
$next($context);
} else {
// Not initialized the account
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
}
/**
* Localization (middleware)
*
* Implement the account language and initialize the localization file
*
* @param context $context
* @param node $next
*
* @return void
*/
public static function localization(context $context, node $next): void
{
// Is the process stopped?
if ($context->get('stop')) return;
// Initializing the account
$account = $context->get('account');
if ($account instanceof record) {
// Initialized the account
// Initializing the language
$language = $context->get('language');
if ($language instanceof language) {
// Initialized the language
// Initializing path to the localization file
$file = LOCALIZATIONS . DIRECTORY_SEPARATOR . strtolower($language->label()) . '.php';
if (file_exists($file) && is_readable($file)) {
// Found the localization file
// Initializing localization
$localization = require($file);
if (is_array($localization)) {
// Initializae localization
// Writing localization into the context variable
$context->set('localization', $localization);
// Continuation of the process
$next($context);
} else {
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize localization*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
} else {
// Not found the localization file
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize the localization file*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
} else {
// Not initialized language
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize language*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
} else {
// Not initialized the account
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
}
/**
* System (middleware)
*
* Check the account for access to the system
*
* @param context $context
* @param node $next
*
* @return void
*/
public static function system(context $context, node $next): void
{
// Is the process stopped?
if ($context->get('stop')) return;
// Initializing the account
$account = $context->get('account');
if ($account instanceof record) {
// Initialized the account
if ($account->authorized_system) {
// Authorized the account to the system
// Continuation of the process
$next($context);
} else {
// Not authorized the account to the system
// Initializing localization
$localization = $context->get('localization');
if ($localization) {
// Initialized localization
// Sending the message
$context->sendMessage('⛔ *' . $localization['not_authorized_system'] . '*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
// Stopping the process
$context->set('stop', true);
} else {
// Not initialized localization
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize localization*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
}
} else {
// Not initialized the account
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
}
/**
* Contact (middleware)
*
* Check the account for access to contact with the organization
*
* @param context $context
* @param node $next
*
* @return void
*/
public static function contact(context $context, node $next): void
{
// Is the process stopped?
if ($context->get('stop')) return;
// Initializing the account
$account = $context->get('account');
if ($account instanceof record) {
// Initialized the account
if ($account->authorized_contact) {
// Authorized the account to contact with the organization
// Continuation of the process
$next($context);
} else {
// Not authorized the account to contact with the organization
// Initializing localization
$localization = $context->get('localization');
if ($localization) {
// Initialized localization
// Sending the message
$context->sendMessage('⛔ *' . $localization['not_authorized_contact'] . '*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
// Stopping the process
$context->set('stop', true);
} else {
// Not initialized localization
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize localization*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
}
} else {
// Not initialized the account
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
}
/**
* Request (middleware)
*
* Check the account for access to request to the organization
*
* @param context $context
* @param node $next
*
* @return void
*/
public static function request(context $context, node $next): void
{
// Is the process stopped?
if ($context->get('stop')) return;
// Initializing the account
$account = $context->get('account');
if ($account instanceof record) {
// Initialized the account
if ($account->authorized_request) {
// Authorized the account to request to the organization
// Continuation of the process
$next($context);
} else {
// Not authorized the account to request to the organization
// Initializing localization
$localization = $context->get('localization');
if ($localization) {
// Initialized localization
// Sending the message
$context->sendMessage('⛔ *' . $localization['not_authorized_request'] . '*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
// Stopping the process
$context->set('stop', true);
} else {
// Not initialized localization
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize localization*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
}
} else {
// Not initialized the account
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
}
/**
* Settings (middleware)
*
* Check the account for access to the settings
*
* @param context $context
* @param node $next
*
* @return void
*/
public static function settings(context $context, node $next): void
{
// Is the process stopped?
if ($context->get('stop')) return;
// Initializing the account
$account = $context->get('account');
if ($account instanceof record) {
// Initialized the account
if ($account->authorized_settings) {
// Authorized the account to the settings
// Continuation of the process
$next($context);
} else {
// Not authorized the account to the settings
// Initializing localization
$localization = $context->get('localization');
if ($localization) {
// Initialized localization
// Sending the message
$context->sendMessage('⛔ *' . $localization['not_authorized_settings'] . '*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
// Stopping the process
$context->set('stop', true);
} else {
// Not initialized localization
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize localization*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
}
} else {
// Not initialized the account
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
}
/**
* System settings (middleware)
*
* Check the account for access to the system settings
*
* @param context $context
* @param node $next
*
* @return void
*/
public static function system_settings(context $context, node $next): void
{
// Is the process stopped?
if ($context->get('stop')) return;
// Initializing the account
$account = $context->get('account');
if ($account instanceof record) {
// Initialized the account
if ($account->authorized_system_settings) {
// Authorized the account to the system settings
// Continuation of the process
$next($context);
} else {
// Not authorized the account to the system settings
// Initializing localization
$localization = $context->get('localization');
if ($localization) {
// Initialized localization
// Sending the message
$context->sendMessage('⛔ *' . $localization['not_authorized_system_settings'] . '*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
// Stopping the process
$context->set('stop', true);
} else {
// Not initialized localization
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize localization*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
}
} else {
// Not initialized the account
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
}
}

View File

@ -0,0 +1,239 @@
<?php
declare(strict_types=1);
namespace svoboda\svoboder\models\telegram\processes\distribution;
// Files of the project
use svoboda\svoboder\models\core,
svoboda\svoboder\models\enumerations\language,
svoboda\svoboder\models\telegram\commands;
// Framework for Telegram
use Zanzara\Context as context,
Zanzara\Telegram\Type\Message as message;
// Baza database
use mirzaev\baza\record;
/**
* Distribution localization process
*
* @package svoboda\svoboder\models\telegram\processes\distribution
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
final class localization extends core
{
/**
* Start
*
* Starting the distribution localization process
*
* @param context $context Request data from Telegram
*
* @return void
*/
public static function start(context $context): void
{
// Initializing the account
$account = $context->get('account');
if ($account instanceof record) {
// Initialized the account
// Initializing language
$language = $context->get('language');
if ($language instanceof language) {
// Initialized language
// Initializing localization
$localization = $context->get('localization');
if ($localization) {
// Initialized localization
// Reading from the telegram user buffer
$context->getUserDataItem('distribution_localization')
->then(function ($distribution_localization) use ($context, $account, $localization) {
// Readed from the telegram user buffer
if ($distribution_localization) {
// Found started localization process
// Sending the message
$context->sendMessage('🌏 *' . $localization['distribution_localization_continiued'] . '*')
->then(function (message $message) use ($context, $localization) {
// Sended the message
// Sending the localization generation menu
static::generation($context);
});
} else {
// Not found started localization process
// Reading from the telegram user buffer
$context->getUserDataItem('distribution_registration')
->then(function ($distribution) use ($context, $account, $localization) {
// Readed from the telegram user buffer
if ($distribution instanceof record) {
// Found started registration process
// Writing to the telegram user buffer
$context->setUserDataItem('distribution_localization', ['distribution' => $distribution])
->then(function () use ($context, $localization) {
// Writed to the telegram user buffer
// Sending the message
$context->sendMessage('🌏 *' . $localization['distribution_localization_started'] . '*')
->then(function (message $message) use ($context, $localization) {
// Sended the message
// Sending the localization generation menu
static::generation($context);
});
});
} else {
// Not found started registration process
// Здесь надо просить выбрать дистрибутив
// Проверять на то, что он creator дистрибутива, иначе посылать
}
});
}
});
} else {
// Not initialized localization
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize localization*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
} else {
// Not initialized language
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize language*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
} else {
// Not initialized the account
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
}
/**
* Generation
*
* Send the generation menu
*
* @param context $context Request data from Telegram
*
* @return void
*/
protected static function generation(context $context): array
{
// Initializing the account
$account = $context->get('account');
if ($account instanceof record) {
// Initialized the account
// Initializing language
$language = $context->get('language');
if ($language) {
// Initialized language
// Initializing localization
$localization = $context->get('localization');
if ($localization) {
// Initialized localization
// Reading from the telegram user buffer
$context->getUserDataItem('distribution_localization')
->then(function ($distribution_localization) use ($context, $account, $language, $localization) {
// Readed from the telegram user buffer
if ($distribution_localization) {
// Found started localization process
// Initializing the buffer of generated keyboard with languages
$keyboard = [
[
[
'text' => (empty($distribution_localization['language']) ? language::{$distribution_localization['language']}->flag() : '🟢') . ' ' . $localization['distribution_localization_button_language'],
'callback_data' => 'distribution_localization_language'
]
],
[
[
'text' => (empty($distribution_localization['name']) ? '🔴 ' : '🟢 ') . $localization['distribution_localization_button_name'],
'callback_data' => 'distribution_localization_name'
]
],
];
// Sending the message
$context->sendMessage(
'🌏 *' . $localization['distribution_localization_generation_menu'] . '*',
[
'reply_markup' => [
'inline_keyboard' => $keyboard
],
'disable_notification' => true
]
);
}
});
} else {
// Not initialized localization
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize localization*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
} else {
// Not initialized language
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize language*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
} else {
// Not initialized the account
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
// Exit (success)
return [];
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,140 @@
<?php
declare(strict_types=1);
namespace svoboda\svoboder\models\telegram;
// Files of the project
use svoboda\svoboder\models\core,
svoboda\svoboder\models\enumerations\language;
// Framework for Telegram
use Zanzara\Context as context,
Zanzara\Telegram\Type\Message as message;
// Baza database
use mirzaev\baza\record;
/**
* Telegram selections
*
* @package svoboda\svoboder\models\telegram
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
final class selections extends core
{
/**
* Language
*
* The language choose menu
*
* @param context $context Request data from Telegram
* @param string $prefix Prefix for 'callback_data' (`$prefix . $language->name`)
* @param string $title Title of the message
* @param string $description Description of the message
*
* @return void
*/
public static function language(context $context, string $prefix, string $title, string $description): void
{
// Initializing the account
$account = $context->get('account');
if ($account instanceof record) {
// Initialized the account
// Initializing language
$language = $context->get('language');
if ($language) {
// Initialized language
// Initializing localization
$localization = $context->get('localization');
if ($localization) {
// Initialized localization
// Declaring the buffer of generated keyboard with languages
$keyboard = [];
// Initializing the iterator of rows
$row = 0;
// Initializing buffer of languages
$languages = language::cases();
// Deleting the actual language from buffer of languages
unset($languages[array_search($language, $languages, strict: true)]);
// Sorting buffer of languages by the actual language
$languages = [$language, ...$languages];
foreach ($languages as $language) {
// Iterating over languages
// Initializing the row
$keyboard[$row] ??= [];
// Writing the language choose button into the buffer of generated keyboard with languages
$keyboard[$row][] = [
'text' => ($language->flag() ? $language->flag() . ' ' : '') . $language->label($language),
'callback_data' => $prefix . $language->name
];
// When reaching 4 buttons in a row, move to the next row
if (count($keyboard[$row]) === 4) ++$row;
}
// Writing the button for helping lozalizing
$keyboard[++$row] = [
[
'text' => '🗂 ' . $localization['select_language_button_add'],
'url' => 'https://git.svoboda.works/svoboda/svoboder/src/branch/stable/svoboda/svoboder/system/localizations'
]
];
// Sending the message
$context->sendMessage(
$title ?? '🌏 *' . $localization['select_language_title'] . "*\n" . ($description ?? $localization['select_language_description']),
[
'reply_markup' => [
'inline_keyboard' => $keyboard,
'disable_notification' => true
],
]
);
} else {
// Not initialized localization
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize localization*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
} else {
// Not initialized language
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize language*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
} else {
// Not initialized the account
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
}
}

View File

@ -0,0 +1,156 @@
<?php
declare(strict_types=1);
namespace svoboda\svoboder\models\telegram;
// Files of the project
use svoboda\svoboder\models\core,
svoboda\svoboder\models\account,
svoboda\svoboder\models\enumerations\language,
svoboda\svoboder\models\telegram\middlewares;
// Framework for Telegram
use Zanzara\Zanzara,
Zanzara\Context as context,
Zanzara\Telegram\Type\Message as message,
Zanzara\Middleware\MiddlewareNode as node;
// Baza database
use mirzaev\baza\record;
// Built-in libraries
use Error as error;
/**
* Telegram settings
*
* @package svoboda\svoboder\models\telegram
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
final class settings extends core
{
/**
* Language
*
* Write language into the account record
*
* @param context $context Request data from Telegram
* @param language $language The language
*
* @return void
*/
public static function language(context $context, language $language): void
{
// Initializing the account
$account = $context->get('account');
if ($account instanceof record) {
// Initialized the account
// Initializing localization
$localization = $context->get('localization');
if ($localization) {
// Initialized localization
// Initializing the account model
$model = new account();
// Updating the account in the database
$updated = $model->database->read(
filter: fn(record $record) => $record->identifier === $account->identifier,
update: function (record &$record) use ($language) {
// Writing new language value into the record
$record->language = $language->name;
},
amount: 1
)[0] ?? null;
if ($updated instanceof record) {
// Updated the account in the database
// Writing the updated account into the context variable
$context->set('account', $updated);
middlewares::language($context, new node(function (context $context) use ($account, $updated) {
// Updated language
middlewares::localization($context, new node(function (context $context) use ($account, $updated) {
// Updated localization
// Initializing localization
$localization = $context->get('localization');
if ($localization) {
// Initialized localization
try {
// Initializing the old language
$old = language::{$account->language};
// Initializing the new language
$new = language::{$updated->language};
// Sending the message
$context->sendMessage('✅ *' . $localization['settings_language_update_success'] . '* ' . ($old->flag() ? $old->flag() . ' ' : '') . $old->label($new) . ' → *' . ($new->flag() ? $new->flag() . ' ' : '') . $new->label($new) . '*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
} catch (error $error) {
// Failed to send the message about language update
// Sending the message
$context->sendMessage('❎ *' . $localization['settings_language_update_fail'])
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
} else {
// Not initialized localization
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize localization*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
}));
}));
} else {
// Not updated the account in the database
// Sending the message
$context->sendMessage('❎ *' . $localization['settings_language_update_fail'])
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
} else {
// Not initialized localization
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize localization*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
} else {
// Not initialized the account
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
}
}

View File

@ -0,0 +1,66 @@
<?php
declare(strict_types=1);
namespace svoboda\svoboder\models\traits;
/**
* Coordinates
*
* Storage of data in the document from ArangoDB
*
* @method int|float distance(float $from_latitude, float $from_longitude, float $to_latitude, float $to_longitude, int $planet)
*
* @package svoboda\svoboder\models\traits
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
trait coordinates
{
/**
* Distance
*
* Calculate the distance between coordinates using the Vincenty formula
*
* @see https://en.wikipedia.org/wiki/Great-circle_distance
*
* @param float $from_latitude From latitude
* @param float $from_longitude From longitude
* @param float $to_latitude To latitude
* @param float $to_longitude To longitude
* @param int $planet Radius of the planet
*
* @return int|float Calculated distance between coordinates (meters)
*/
public static function distance(
float $from_latitude,
float $from_longitude,
float $to_latitude,
float $to_longitude,
int $planet = 6371000
): int|float {
// Initializing the from coordinates
$from = [
'latitude' => deg2rad($from_latitude),
'longitude' => deg2rad($from_longitude)
];
// Initializing the to coordinates
$to = [
'latitude' => deg2rad($to_latitude),
'longitude' => deg2rad($to_longitude)
];
// Calculating longitude delta
$delta = $to['longitude'] - $from['longitude'];
// Calculating (wtf)
$biba = pow(cos($to['latitude']) * sin($delta), 2) + pow(cos($from['latitude']) * sin($to['latitude']) - sin($from['latitude']) * cos($to['latitude']) * cos($delta), 2);
$boba = sin($from['latitude']) * sin($to['latitude']) + cos($from['latitude']) * cos($to['latitude']) * cos($delta);
$angle = atan2(sqrt($biba), $boba);
// Exit (success)
return $angle * $planet;
}
}

View File

@ -0,0 +1,167 @@
<?php
declare(strict_types=1);
namespace svoboda\svoboder;
// Files of the project
use svoboda\svoboder\models\distribution,
svoboda\svoboder\models\localization\distribution as distribution_localization,
svoboda\svoboder\models\telegram\middlewares,
svoboda\svoboder\models\telegram\commands,
svoboda\svoboder\models\telegram\buttons,
svoboda\svoboder\models\telegram\selections,
svoboda\svoboder\models\telegram\settings,
svoboda\svoboder\models\enumerations\language,
svoboda\svoboder\models\telegram\processes\distribution\registration as process_distribution_registration,
svoboda\svoboder\models\telegram\processes\distribution\search as process_distribution_search,
svoboda\svoboder\models\telegram\buttons\distribution\registration as button_distribution_registration,
svoboda\svoboder\models\telegram\buttons\distribution\search as button_distribution_search,
svoboda\svoboder\models\telegram\processes\distribution\localization as process_distribution_localization;
// Framework for Telegram
use Zanzara\Zanzara as zanzara,
Zanzara\Context as context,
Zanzara\Config as config;
// Baza database
use mirzaev\baza\record;
// Enabling debugging
/* ini_set('error_reporting', E_ALL);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1); */
// Initializing path to the public directory
define('INDEX', __DIR__);
// Initializing path to the root directory
define('ROOT', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR);
// Initializing path to the settings directory
define('SETTINGS', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'settings');
// Initializing path to the storage directory
define('STORAGE', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'storage');
// Initializing path to the databases directory
define('DATABASES', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'databases');
// Initializing path to the localizations directory
define('LOCALIZATIONS', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'localizations');
// Initiailizing telegram key
define('TELEGRAM_KEY', require(SETTINGS . DIRECTORY_SEPARATOR . 'telegram.php'));
// Initializing dependencies
require ROOT . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
// Initializing the configuration
$config = new config();
$config->setParseMode(config::PARSE_MODE_MARKDOWN);
$config->useReactFileSystem(true);
// Initializing the robot
$robot = new Zanzara(TELEGRAM_KEY, $config);
// Initializing the updates listener
$robot->onUpdate(function (Context $context): void {});
// Initializing the robot middlewares
$robot->middleware([middlewares::class, 'account']);
$robot->middleware([middlewares::class, 'language']);
$robot->middleware([middlewares::class, 'localization']);
$robot->middleware([middlewares::class, 'system']);
// Initializing the robot commands handlers
$robot->onCommand('start', [commands::class, 'menu']);
$robot->onCommand('menu', [commands::class, 'menu']);
/* $robot->onCommand('request', [telegram::class, 'request_start'])->middleware([telegram::class, 'request']); */
/* $robot->onCommand('svoboda', [commands::class, 'svoboda']);
$robot->onCommand('members', [commands::class, 'members']); */
$robot->onCommand('language', [commands::class, 'language'])->middleware([middlewares::class, 'settings']);
$robot->onCommand('society', [commands::class, 'society']);
$robot->onCommand('repository', [commands::class, 'repository']);
/* $robot->onCommand('projects', [commands::class, 'projects']); */
$robot->onCommand('author', [commands::class, 'author']);
// Initializing the robot distrubitions menu handlers
$robot->onCommand('distributions', [commands::class, 'distributions']);
$robot->onCbQueryData(['distributions'], [commands::class, 'distributions']); // Remake to buttons?
// Initializing the robot distributions search button handlers
$robot->onCbQueryData(['distribution_search_start'], [process_distribution_search::class, 'start']);
$robot->onCbQueryData(['distribution_search_text'], [button_distribution_search::class, 'text']);
/* $robot->onCbQueryData(['distribution_search_next'], [process_distribution_search::class, 'text']); */
$robot->onCbQueryData(['distribution_search_end'], [process_distribution_search::class, 'end']);
$robot->onCbQueryData(['distribution_search_confirmed'], [process_distribution_search::class, 'confirmed']);
$robot->onCbQueryData(['distribution_search_location'], [button_distribution_search::class, 'location']);
$robot->onCbQueryData(['distribution_search_distance'], [button_distribution_search::class, 'distance']);
// Initializing the robot distribution search location send button handler
$robot->onCbQueryData(['distribution_search_location'], [button_distribution_search::class, 'location']);
// Initializing the robot distributions registration buttons handlers
$robot->onCbQueryData(['distribution_registration_start'], [process_distribution_registration::class, 'start']);
$robot->onCbQueryData(['distribution_registration_cancel'], [process_distribution_registration::class, 'cancel']);
$robot->onCbQueryData(['distribution_registration_end'], [process_distribution_registration::class, 'end']);
// Initializing the robot distribution localization language select button handler
$robot->onCbQueryData(['distribution_registration_language'], [button_distribution_registration::class, 'language']);
// Initializing the robot distribution registration language buttons handlers
foreach (language::cases() as $language) {
// Iterating over languages
// Initializing language buttons
$robot->onCbQueryData(['distribution_registration_select_language_' . $language->name], fn(context $context) => process_distribution_registration::language($context, $language));
};
// Initializing the robot distribution registration localization name enter button handler
$robot->onCbQueryData(['distribution_registration_name'], [button_distribution_registration::class, 'name']);
// Initializing the robot distribution registration location send button handler
$robot->onCbQueryData(['distribution_registration_location'], [button_distribution_registration::class, 'location']);
// Initializing the robot distributions localization buttons handlers
/* $robot->onCbQueryData(['distribution_localization_start'], [process_distribution_localization::class, 'start']); */
/* $robot->onCbQueryData(['distribution_localization_language'], [distribution_localization::class, 'language']);
$robot->onCbQueryData(['distribution_localization_name'], [distribution_localization::class, 'name']); */
/* // Initializing the robot distribution localization language select button handler
$robot->onCbQueryData(
['distribution_localization_language'],
fn(context $context) => selections::language(
context: $context,
prefix: 'distribution_localization_language_',
title: '🌏 *' . $localization['distribution_localization_select_language_title'] . '*',
description: '🌏 *' . $localization['distribution_localization_select_language_description'] . '*'
)
);
// Initializing the robot distribution localization language buttons handlers
foreach (language::cases() as $language) {
// Iterating over languages
// Initializing language buttons
$robot->onCbQueryData(['distribution_localization_language_' . $language->name], fn(context $context) => settings::language($context, $language));
}; */
// Initializing the robot distributions menu buttons handlers
/* $robot->onCbQueryData(['distributions_search_start'], [process_distribution_search::class, 'start']); */
// Initializing the robot settings language buttons handlers
foreach (language::cases() as $language) {
// Iterating over languages
// Initializing language buttons
$robot->onCbQueryData(['settings_language_' . $language->name], fn(context $context) => settings::language($context, $language));
};
// Initializing the robot protected commands handlers
/* $robot->onCommand('system_settings', [commands::class, 'system_settings'])->middleware([middlewares::class, 'system_settings']); */
// Starting chat-robot
$robot->run();

View File

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 46 KiB