diff --git a/composer.json b/composer.json index fb3dde5..7575284 100755 --- a/composer.json +++ b/composer.json @@ -1,12 +1,14 @@ { - "name": "svoboda/negotiator", - "description": "Svoboda Telegram chat-robot negotiator", - "homepage": "https://git.svoboda.works/svoboda/negotiator", + "name": "svoboda/svoboder", + "description": "Svoboda Telegram chat-robot", + "homepage": "https://git.svoboda.works/svoboda/svoboder", "type": "chat-robot", "keywords": [ "svoboda", "telegram", - "minimal" + "minimal", + "baza", + "anarchism" ], "readme": "README.md", "license": "WTFPL", @@ -19,28 +21,25 @@ } ], "support": { - "wiki": "https://git.svoboda.works/svoboda/negotiator/wiki", - "issues": "https://git.svoboda.works/svoboda/negotiator/issues" + "wiki": "https://git.svoboda.works/svoboda/svoboder/wiki", + "issues": "https://git.svoboda.works/svoboda/svoboder/issues" }, "require": { "php": "^8.4", "mirzaev/minimal": "^3.4.0", - "badfarm/zanzara": "^0.9.1", - "react/filesystem": "^0.1.2", "mirzaev/baza": "^3.1.0", - "svoboda/time": "^1.0" - }, - "require-dev": { - "phpunit/phpunit": "~9.5" + "svoboda/time": "^1.0", + "badfarm/zanzara": "^0.9.1", + "react/filesystem": "^0.1.2" }, "autoload": { "psr-4": { - "svoboda\\negotiator\\": "svoboda/negotiator/system" + "svoboda\\svoboder\\": "svoboda/svoboder/system" } }, "autoload-dev": { "psr-4": { - "svoboda\\negotiator\\tests\\": "svoboda/negotiator/tests" + "svoboda\\svoboder\\tests\\": "svoboda/svoboder/tests" } }, "scripts": { diff --git a/examples/nginx/negotiator.svoboda.conf b/examples/nginx/negotiator.svoboda.conf deleted file mode 100755 index a3ce334..0000000 --- a/examples/nginx/negotiator.svoboda.conf +++ /dev/null @@ -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"; - } -} - diff --git a/examples/systemd/negotiator-telegram.service b/examples/systemd/svoboder-telegram.service similarity index 79% rename from examples/systemd/negotiator-telegram.service rename to examples/systemd/svoboder-telegram.service index 58c6919..11fb061 100755 --- a/examples/systemd/negotiator-telegram.service +++ b/examples/systemd/svoboder-telegram.service @@ -5,8 +5,8 @@ Wants=network.target After=syslog.target network-online.target [Service] -ExecStart=sudo -u www-data /usr/bin/php /var/www/project/svoboda/negotiator/system/public/telegram.php -PIDFile=/var/run/php/negotiator-telegram.pid +ExecStart=sudo -u www-data /usr/bin/php /var/www/project/svoboda/svoboder/system/public/telegram.php +PIDFile=/var/run/php/svoboder-telegram.pid RemainAfterExit=no RuntimeMaxSec=3600s Restart=always diff --git a/install.sh b/install.sh index 2e42fb1..e839053 100755 --- a/install.sh +++ b/install.sh @@ -1,7 +1,7 @@ #!/bin/bash if [ -d author/project ]; then - mv author/project author/negotiator + mv author/project author/svoboder fi if [ -d author ]; then diff --git a/svoboda/negotiator/system/models/telegram/processes/distribution/search.php b/svoboda/negotiator/system/models/telegram/processes/distribution/search.php deleted file mode 100755 index 5f8daa1..0000000 --- a/svoboda/negotiator/system/models/telegram/processes/distribution/search.php +++ /dev/null @@ -1,148 +0,0 @@ - - */ -final class search extends core -{ - /** - * Registry - * - * Registrate the distribution - * - * @param context $context Request data from Telegram - * - * @return void - */ - public static function registry(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 - - // Declaring the buffer of generated keyboard with languages - $keyboard = []; - - // Initializing the iterator of rows - $row = 0; - - // Initializing the distribution model - $model = new distribution; - - // Initializing the distribution localization model - $model_localization = new distribution_localization; - - foreach ($model->database->read(amount: PHP_INT_MAX) as $distribution) { - // Iterating over distributions - - // Initializing the distribution localized values - $localized = $model_localization->database->read(filter: fn($record) => $record->identifier === $distribution->identifier && $record->language === $language->name, amount: 1)[0] ?? null; - - // Initializing the row - $keyboard[$row] ??= []; - - // Writing the language choose button into the buffer of generated keyboard with languages - $keyboard[$row][] = [ - 'text' => $localized->name, - 'callback_data' => 'distributions_open_' . $distribution->identifier - ]; - - // When reaching 4 buttons in a row, move to the next row - if (count($keyboard[$row]) === 3) ++$row; - } - - // Writing the button for helping lozalizing - $keyboard[++$row] = [ - [ - 'text' => '🗂 ' . $localization['settings_language_add'], - 'url' => 'https://git.svoboda.works/svoboda/negotiator/src/branch/stable/svoboda/negotiator/system/localizations' - ] - ]; - - // Sending the message - $context->sendMessage( - '🌏 *' . $localization['settings_language_title'] . '*', - [ - 'reply_markup' => [ - 'inline_keyboard' => $keyboard - ], - 'disable_notification' => true - ] - ); - } 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(); - }); - } - } -} diff --git a/svoboda/negotiator/system/controllers/core.php b/svoboda/svoboder/system/controllers/core.php similarity index 92% rename from svoboda/negotiator/system/controllers/core.php rename to svoboda/svoboder/system/controllers/core.php index 80aeb9e..e293c51 100755 --- a/svoboda/negotiator/system/controllers/core.php +++ b/svoboda/svoboder/system/controllers/core.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace svoboda\negotiator\controllers; +namespace svoboda\svoboder\controllers; // Files of the project -use svoboda\negotiator\models\core as models; +use svoboda\svoboder\models\core as models; // Framework for PHP use mirzaev\minimal\core as minimal, @@ -16,7 +16,7 @@ use mirzaev\minimal\core as minimal, /** * Controllers core * - * @package svoboda\negotiator\controllers + * @package svoboda\svoboder\controllers * * @param language $language Language * @param response $response Response diff --git a/svoboda/negotiator/system/localizations/english.php b/svoboda/svoboder/system/localizations/english.php similarity index 50% rename from svoboda/negotiator/system/localizations/english.php rename to svoboda/svoboder/system/localizations/english.php index 664dbbd..694cdce 100644 --- a/svoboda/negotiator/system/localizations/english.php +++ b/svoboda/svoboder/system/localizations/english.php @@ -6,6 +6,62 @@ return [ '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' => << 'The code', + 'repository_button_issues' => 'Issues', + 'repository_button_suggestions' => 'Suggestions', + + // Author + 'author_title' => 'Author', + 'author_text' => << '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', @@ -16,22 +72,10 @@ return [ 'select_distributions_description' => 'The selected distribution will be used in the current process', 'select_distribution_button_registrate' => 'Registrate a distribution', - // 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', - - // 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_button_search' => 'Search', - 'distributions_button_register' => 'Registrate', - // 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', @@ -77,6 +121,62 @@ return [ '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', diff --git a/svoboda/negotiator/system/localizations/russian.php b/svoboda/svoboder/system/localizations/russian.php similarity index 50% rename from svoboda/negotiator/system/localizations/russian.php rename to svoboda/svoboder/system/localizations/russian.php index ace8066..c7b4364 100644 --- a/svoboda/negotiator/system/localizations/russian.php +++ b/svoboda/svoboder/system/localizations/russian.php @@ -6,6 +6,62 @@ 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' => << 'Код', + 'repository_button_issues' => 'Проблемы', + 'repository_button_suggestions' => 'Предложения', + + // Автор + 'author_title' => 'Автор', + 'author_text' => << 'Нейрожурнал', + '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' => 'Выбранный язык будет использован в текущем процессе', @@ -16,19 +72,6 @@ return [ 'select_distributions_description' => 'Выбранный дистрибутив будет использован в текущем процесса', 'select_distribution_button_registrate' => 'Зарегистрировать дистрибутив', - // Настройки - 'settings_select_language_title' => 'Выбери язык', - 'settings_select_language_description' => 'Выбранный язык будет записан в настройки аккаунта', - 'settings_language_update_success' => 'Язык заменён:', - 'settings_language_update_fail' => 'Не удалось заменить язык', - - // Дистрибутивы - 'distributions_title' => 'Реестр дистрибутивов', - 'distributions_description' => '*Дистрибутив* \- это автономная ячейка Свободы, являющаяся любым видом формирования \(например: коммуна\), но обязательно наследующая *Vhod* протокол, участвующая в глобальных процессах организации и привязанная к местоположению', - 'distributions_registered' => 'Зарегистрировано', - 'distributions_button_search' => 'Поиск', - 'distributions_button_register' => 'Зарегистрировать', - // Регистрация дистрибутива 'distribution_registration_started' => 'Процесс регистрации дистрибутива запущен', 'distribution_registration_not_started' => 'Процесс регистрации дистрибутива не запущен', @@ -46,13 +89,13 @@ return [ 'distribution_registration_language_update_success' => 'Язык заменён:', 'distribution_registration_language_update_fail' => 'Не удалось заменить язык', 'distribution_registration_button_name' => 'Название', - 'distribution_registration_name_request' => 'Введите название', + '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_request_restricted_characters_description' => "Удали эти символы:", 'distribution_registration_name_update_success' => 'Название заменено:', 'distribution_registration_name_update_fail' => 'Не удалось заменить название', 'distribution_registration_button_location' => 'Местоположение', @@ -77,6 +120,63 @@ return [ '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' => 'У тебя нет доступа к коммуникации с организацией', diff --git a/svoboda/negotiator/system/models/account.php b/svoboda/svoboder/system/models/account.php similarity index 93% rename from svoboda/negotiator/system/models/account.php rename to svoboda/svoboder/system/models/account.php index 9fc1697..e0707da 100755 --- a/svoboda/negotiator/system/models/account.php +++ b/svoboda/svoboder/system/models/account.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace svoboda\negotiator\models; +namespace svoboda\svoboder\models; // Files of the project -use svoboda\negotiator\models\core; +use svoboda\svoboder\models\core; // Svoboda time use svoboda\time\statement as svoboda; @@ -27,7 +27,7 @@ use Exception as exception, /** * Account * - * @package svoboda\negotiator\models + * @package svoboda\svoboder\models * * @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License * @author Arsen Mirzaev Tatyano-Muradovich @@ -70,6 +70,10 @@ final class account extends core 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) @@ -190,6 +194,9 @@ final class account extends core 1, 1, 0, + 0, + 0, + 0, svoboda::timestamp(), svoboda::timestamp() ); diff --git a/svoboda/negotiator/system/models/core.php b/svoboda/svoboder/system/models/core.php similarity index 96% rename from svoboda/negotiator/system/models/core.php rename to svoboda/svoboder/system/models/core.php index e3edd0b..e6fca44 100755 --- a/svoboda/negotiator/system/models/core.php +++ b/svoboda/svoboder/system/models/core.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace svoboda\negotiator\models; +namespace svoboda\svoboder\models; // Framework for PHP use mirzaev\minimal\model; @@ -18,7 +18,7 @@ use exception; /** * Core * - * @package svoboda\negotiator\models + * @package svoboda\svoboder\models * * @method void __construct() Constructor * diff --git a/svoboda/negotiator/system/models/distribution.php b/svoboda/svoboder/system/models/distribution.php similarity index 93% rename from svoboda/negotiator/system/models/distribution.php rename to svoboda/svoboder/system/models/distribution.php index 7a4fdf7..94e8c6a 100755 --- a/svoboda/negotiator/system/models/distribution.php +++ b/svoboda/svoboder/system/models/distribution.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace svoboda\negotiator\models; +namespace svoboda\svoboder\models; // Files of the project -use svoboda\negotiator\models\core; +use svoboda\svoboder\models\core; // Svoboda time use svoboda\time\statement as svoboda; @@ -27,7 +27,7 @@ use Exception as exception, /** * Distribution * - * @package svoboda\negotiator\models + * @package svoboda\svoboder\models * * @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License * @author Arsen Mirzaev Tatyano-Muradovich @@ -61,6 +61,7 @@ final class distribution extends core ->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), @@ -89,6 +90,7 @@ final class distribution extends core $record = $this->database->record( $identifier, $creator, + 0, $latitude, $longitude, svoboda::timestamp(), diff --git a/svoboda/negotiator/system/models/enumerations/entity.php b/svoboda/svoboder/system/models/enumerations/entity.php similarity index 73% rename from svoboda/negotiator/system/models/enumerations/entity.php rename to svoboda/svoboder/system/models/enumerations/entity.php index 9a31a2f..488c7e0 100755 --- a/svoboda/negotiator/system/models/enumerations/entity.php +++ b/svoboda/svoboder/system/models/enumerations/entity.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace svoboda\negotiator\models\enumerations; +namespace svoboda\svoboder\models\enumerations; /** * Entity * * Types of entities * - * @package svoboda\negotiator\models\enumerations + * @package svoboda\svoboder\models\enumerations * * @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License * @author Arsen Mirzaev Tatyano-Muradovich diff --git a/svoboda/negotiator/system/models/enumerations/language.php b/svoboda/svoboder/system/models/enumerations/language.php similarity index 91% rename from svoboda/negotiator/system/models/enumerations/language.php rename to svoboda/svoboder/system/models/enumerations/language.php index 4b99890..e356964 100755 --- a/svoboda/negotiator/system/models/enumerations/language.php +++ b/svoboda/svoboder/system/models/enumerations/language.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace svoboda\negotiator\models\enumerations; +namespace svoboda\svoboder\models\enumerations; /** * Language * * 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 * @author Arsen Mirzaev Tatyano-Muradovich diff --git a/svoboda/negotiator/system/models/localizations/distribution.php b/svoboda/svoboder/system/models/localizations/distribution.php similarity index 92% rename from svoboda/negotiator/system/models/localizations/distribution.php rename to svoboda/svoboder/system/models/localizations/distribution.php index b021802..9098cc2 100755 --- a/svoboda/negotiator/system/models/localizations/distribution.php +++ b/svoboda/svoboder/system/models/localizations/distribution.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace svoboda\negotiator\models\localizations; +namespace svoboda\svoboder\models\localizations; // Files of the project -use svoboda\negotiator\models\core, - svoboda\negotiator\models\enumerations\language; +use svoboda\svoboder\models\core, + svoboda\svoboder\models\enumerations\language; // Svoboda time use svoboda\time\statement as svoboda; @@ -28,7 +28,7 @@ use Exception as exception, /** * Distribution * - * @package svoboda\negotiator\models + * @package svoboda\svoboder\models\localizations * * @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License * @author Arsen Mirzaev Tatyano-Muradovich diff --git a/svoboda/negotiator/system/models/telegram/buttons/distribution/registration.php b/svoboda/svoboder/system/models/telegram/buttons/distribution/registration.php similarity index 87% rename from svoboda/negotiator/system/models/telegram/buttons/distribution/registration.php rename to svoboda/svoboder/system/models/telegram/buttons/distribution/registration.php index d1cceb3..f0779c8 100755 --- a/svoboda/negotiator/system/models/telegram/buttons/distribution/registration.php +++ b/svoboda/svoboder/system/models/telegram/buttons/distribution/registration.php @@ -2,16 +2,16 @@ declare(strict_types=1); -namespace svoboda\negotiator\models\telegram\buttons\distribution; +namespace svoboda\svoboder\models\telegram\buttons\distribution; // Files of the project -use svoboda\negotiator\models\core, - svoboda\negotiator\models\account, - svoboda\negotiator\models\distribution, - svoboda\negotiator\models\telegram\selections, - svoboda\negotiator\models\telegram\processes\distribution\registration as process_distribution_registration, - svoboda\negotiator\models\localization\distribution as distribution_localization, - svoboda\negotiator\models\enumerations\language; +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, @@ -23,7 +23,7 @@ use mirzaev\baza\record; /** * Telegram distribution registration buttons * - * @package svoboda\negotiator\models\telegram\buttons\distribution + * @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 @@ -75,7 +75,7 @@ final class registration extends core description: '🌏 *' . $localization['distribution_registration_select_language_description'] . '*' ); } else { - // Not found started registretion process + // Not found started registration process // Sending the message $context->sendMessage('⚠️ *' . $localization['distribution_registration_not_started'] . '*'); @@ -153,7 +153,7 @@ final class registration extends core $context->nextStep([process_distribution_registration::class, 'name']); }); } else { - // Not found started registretion process + // Not found started registration process // Sending the message $context->sendMessage('⚠️ *' . $localization['distribution_registration_not_started'] . '*'); @@ -221,10 +221,10 @@ final class registration extends core // Sending the message $context->sendMessage( << [ 'keyboard' => [ @@ -239,15 +239,14 @@ final class registration extends core ] ] - ) - ->then(function (message $message) use ($context) { - // Sended the message + )->then(function (message $message) use ($context) { + // Sended the message - // Writing into the distribution registration buffer - $context->nextStep([process_distribution_registration::class, 'location']); - }); + // Writing into the distribution registration buffer + $context->nextStep([process_distribution_registration::class, 'location']); + }); } else { - // Not found started registretion process + // Not found started registration process // Sending the message $context->sendMessage('⚠️ *' . $localization['distribution_registration_not_started'] . '*'); diff --git a/svoboda/svoboder/system/models/telegram/buttons/distribution/search.php b/svoboda/svoboder/system/models/telegram/buttons/distribution/search.php new file mode 100755 index 0000000..f3f2d11 --- /dev/null +++ b/svoboda/svoboder/system/models/telegram/buttons/distribution/search.php @@ -0,0 +1,281 @@ + + */ +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(<<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( + << [ + '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( + <<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(); + }); + } + } +} diff --git a/svoboda/negotiator/system/models/telegram/commands.php b/svoboda/svoboder/system/models/telegram/commands.php similarity index 53% rename from svoboda/negotiator/system/models/telegram/commands.php rename to svoboda/svoboder/system/models/telegram/commands.php index b637e11..3cd8e76 100755 --- a/svoboda/negotiator/system/models/telegram/commands.php +++ b/svoboda/svoboder/system/models/telegram/commands.php @@ -2,13 +2,14 @@ declare(strict_types=1); -namespace svoboda\negotiator\models\telegram; +namespace svoboda\svoboder\models\telegram; // Files of the project -use svoboda\negotiator\models\core, - svoboda\negotiator\models\distribution, - svoboda\negotiator\models\telegram\selections, - svoboda\negotiator\models\enumerations\language; +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, @@ -21,7 +22,7 @@ use mirzaev\baza\record; /** * Telegram commands * - * @package svoboda\negotiator\models\telegram + * @package svoboda\svoboder\models\telegram * * @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License * @author Arsen Mirzaev Tatyano-Muradovich @@ -52,14 +53,77 @@ final class commands extends core // Initialized localization // Initializing the title - $title = '*' . $localization['svoboda'] . '*'; + $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(<<sendMessage( + << [ + '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 @@ -167,12 +231,19 @@ final class commands extends core // 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( <<sendMessage('⚠️ *Failed to initialize localization*') ->then(function (message $message) use ($context) { + // Sended the message + // Ending the conversation process $context->endConversation(); }); @@ -280,6 +353,190 @@ final class commands extends core // 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(); diff --git a/svoboda/negotiator/system/models/telegram/distribution.php b/svoboda/svoboder/system/models/telegram/distribution.php similarity index 55% rename from svoboda/negotiator/system/models/telegram/distribution.php rename to svoboda/svoboder/system/models/telegram/distribution.php index eee607e..7155483 100755 --- a/svoboda/negotiator/system/models/telegram/distribution.php +++ b/svoboda/svoboder/system/models/telegram/distribution.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace svoboda\negotiator\models\telegram; +namespace svoboda\svoboder\models\telegram; // Files of the project -use svoboda\negotiator\models\core, - svoboda\negotiator\models\account, - svoboda\negotiator\models\distribution as model, - svoboda\negotiator\models\localization\distribution as distribution_localization, - svoboda\negotiator\models\enumerations\language; +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, @@ -21,7 +21,7 @@ use mirzaev\baza\record; /** * Telegram distribution * - * @package svoboda\negotiator\models\telegram + * @package svoboda\svoboder\models\telegram * * @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License * @author Arsen Mirzaev Tatyano-Muradovich diff --git a/svoboda/negotiator/system/models/telegram/middlewares.php b/svoboda/svoboder/system/models/telegram/middlewares.php similarity index 98% rename from svoboda/negotiator/system/models/telegram/middlewares.php rename to svoboda/svoboder/system/models/telegram/middlewares.php index 38b38b1..ac1295a 100755 --- a/svoboda/negotiator/system/models/telegram/middlewares.php +++ b/svoboda/svoboder/system/models/telegram/middlewares.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace svoboda\negotiator\models\telegram; +namespace svoboda\svoboder\models\telegram; // Files of the project -use svoboda\negotiator\models\core, - svoboda\negotiator\models\account, - svoboda\negotiator\models\enumerations\language; +use svoboda\svoboder\models\core, + svoboda\svoboder\models\account, + svoboda\svoboder\models\enumerations\language; // Framework for Telegram use Zanzara\Context as context, @@ -23,7 +23,7 @@ use Error as error; /** * Telegram middlewares * - * @package svoboda\negotiator\models\telegram + * @package svoboda\svoboder\models\telegram * * @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License * @author Arsen Mirzaev Tatyano-Muradovich diff --git a/svoboda/negotiator/system/models/telegram/processes/distribution/localization.php b/svoboda/svoboder/system/models/telegram/processes/distribution/localization.php similarity index 96% rename from svoboda/negotiator/system/models/telegram/processes/distribution/localization.php rename to svoboda/svoboder/system/models/telegram/processes/distribution/localization.php index 6eb6caf..891104c 100755 --- a/svoboda/negotiator/system/models/telegram/processes/distribution/localization.php +++ b/svoboda/svoboder/system/models/telegram/processes/distribution/localization.php @@ -2,11 +2,12 @@ declare(strict_types=1); -namespace svoboda\negotiator\models\telegram\processes\distribution; +namespace svoboda\svoboder\models\telegram\processes\distribution; // Files of the project -use svoboda\negotiator\models\core, - svoboda\negotiator\models\enumerations\language; +use svoboda\svoboder\models\core, + svoboda\svoboder\models\enumerations\language, + svoboda\svoboder\models\telegram\commands; // Framework for Telegram use Zanzara\Context as context, @@ -18,7 +19,7 @@ use mirzaev\baza\record; /** * Distribution localization process * - * @package svoboda\negotiator\models\telegram\processes\distribution + * @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 diff --git a/svoboda/negotiator/system/models/telegram/processes/distribution/registration.php b/svoboda/svoboder/system/models/telegram/processes/distribution/registration.php similarity index 92% rename from svoboda/negotiator/system/models/telegram/processes/distribution/registration.php rename to svoboda/svoboder/system/models/telegram/processes/distribution/registration.php index d827bc0..dd66948 100755 --- a/svoboda/negotiator/system/models/telegram/processes/distribution/registration.php +++ b/svoboda/svoboder/system/models/telegram/processes/distribution/registration.php @@ -2,16 +2,16 @@ declare(strict_types=1); -namespace svoboda\negotiator\models\telegram\processes\distribution; +namespace svoboda\svoboder\models\telegram\processes\distribution; // Files of the project -use svoboda\negotiator\models\core, - svoboda\negotiator\models\distribution, - svoboda\negotiator\models\localizations\distribution as distribution_localization, - svoboda\negotiator\models\enumerations\language, - svoboda\negotiator\models\telegram\commands, - svoboda\negotiator\models\telegram\processes\distribution\localization, - svoboda\negotiator\models\telegram\buttons\distribution\registration as button_distribution_registration; +use svoboda\svoboder\models\core, + svoboda\svoboder\models\distribution, + svoboda\svoboder\models\localizations\distribution as distribution_localization, + svoboda\svoboder\models\enumerations\language, + svoboda\svoboder\models\telegram\commands, + svoboda\svoboder\models\telegram\processes\distribution\localization, + svoboda\svoboder\models\telegram\buttons\distribution\registration as button_distribution_registration; // Framework for Telegram use Zanzara\Context as context, @@ -26,7 +26,7 @@ use Error as error; /** * Distribution registration process * - * @package svoboda\negotiator\models\telegram\processes\distribution + * @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 @@ -157,67 +157,49 @@ final class registration extends core if ($account instanceof record) { // Initialized the account - // Initializing language - $language = $context->get('language'); + // Initializing localization + $localization = $context->get('localization'); - if ($language instanceof language) { - // Initialized language + if ($localization) { + // Initialized localization - // Initializing localization - $localization = $context->get('localization'); + // Reading from the telegram user buffer + $context->getUserDataItem('distribution_registration') + ->then(function ($distribution) use ($context, $localization) { + // Readed from the telegram user buffer - if ($localization) { - // Initialized localization + if ($distribution) { + // Found started registration process - // Reading from the telegram user buffer - $context->getUserDataItem('distribution_registration') - ->then(function ($distribution) use ($context, $account, $language, $localization) { - // Readed from the telegram user buffer + // Deleting in the telegram user buffer + $context->deleteUserDataItem('distribution_registration') + ->then(function () use ($context, $localization) { + // Deleted in the telegram user buffer - if ($distribution) { - // Found started registration process + // Sending the message + $context->sendMessage('🗑 *' . $localization['distribution_registration_canceled'] . '*') + ->then(function (message $message) use ($context) { + // Sended the message - // Deleting in the telegram user buffer - $context->deleteUserDataItem('distribution_registration') - ->then(function () use ($context, $account, $language, $localization) { - // Deleted in the telegram user buffer + // Ending the conversation process + $context->endConversation(); - // Sending the message - $context->sendMessage('🗑 *' . $localization['distribution_registration_canceled'] . '*') - ->then(function (message $message) use ($context) { - // Sended the message + // Sending the distributions menu + commands::distributions($context); + }); + }); + } else { + // Not found started registretion process - // Ending the conversation process - $context->endConversation(); - - // Sending the distributions menu - commands::distributions($context); - }); - }); - } else { - // Not found started registretion 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 $message) use ($context) { - // Sended the message - - // Ending the conversation process - $context->endConversation(); - }); - } + // Sending the message + $context->sendMessage('⚠️ *' . $localization['distribution_registration_not_started'] . '*'); + } + }); } else { - // Not initialized language + // Not initialized localization // Sending the message - $context->sendMessage('⚠️ *Failed to initialize language*') + $context->sendMessage('⚠️ *Failed to initialize localization*') ->then(function (message $message) use ($context) { // Sended the message @@ -487,6 +469,7 @@ final class registration extends core // Ending the conversation process $context->endConversation() ->then(function () use ($context, $localization, $keyboard) { + // Deinitialized the conversation process // Sending the message $context->sendMessage( @@ -972,7 +955,7 @@ final class registration extends core // Ending the conversation process $context->endConversation(); - // Requesting to enter name again + // Requesting to enter locaztion again button_distribution_registration::location($context); }); } @@ -987,7 +970,7 @@ final class registration extends core // Ending the conversation process $context->endConversation(); - // Requesting to enter name again + // Requesting to enter locaztion again button_distribution_registration::location($context); }); } @@ -1002,7 +985,7 @@ final class registration extends core // Ending the conversation process $context->endConversation(); - // Requesting to enter name again + // Requesting to enter locaztion again button_distribution_registration::location($context); }); } @@ -1017,7 +1000,7 @@ final class registration extends core // Ending the conversation process $context->endConversation(); - // Requesting to enter name again + // Requesting to enter locaztion again button_distribution_registration::location($context); }); } diff --git a/svoboda/svoboder/system/models/telegram/processes/distribution/search.php b/svoboda/svoboder/system/models/telegram/processes/distribution/search.php new file mode 100755 index 0000000..598af5f --- /dev/null +++ b/svoboda/svoboder/system/models/telegram/processes/distribution/search.php @@ -0,0 +1,1457 @@ + + */ +final class search extends core +{ + use coordinates { + coordinates::distance as vincenty; + } + + /** + * Start + * + * Starting the distribution search 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_search') + ->then(function ($distribution) use ($context, $account, $language, $localization) { + // Readed from the telegram user buffer + + if ($distribution) { + // Found started search process + + // Sending the message + $context->sendMessage('🗂 *' . $localization['distribution_search_continiued'] . '*') + ->then(function (message $message) use ($context, $account, $language, $localization) { + // Sended the message + + // Sending the list of found distributions and menu + static::search($context); + }); + } else { + // Not found started search process + + // Initializing the distribution search buffer + $search = [ + 'text' => null, + 'location' => [ + 'latitude' => null, + 'longitude' => null, + 'distance' => 300 + ], + 'page' => 0, + 'confirmed' => true + ]; + + // Writing to the telegram user buffer + $context->setUserDataItem('distribution_search', $search) + ->then(function () use ($context, $account, $localization) { + // Writed to the telegram user buffer + + // Sending the message + $context->sendMessage('🗂 *' . $localization['distribution_search_started'] . '*') + ->then(function (message $message) use ($context, $account, $localization) { + // Sended the message + + // Sending the list of found distributions and menu + static::search($context); + }); + }); + } + }); + } 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(); + }); + } + } + + /** + * End + * + * Ending the distribution search process + * + * @param context $context Request data from Telegram + * + * @return void + */ + public static function end(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 + + // Reading from the telegram user buffer + $context->getUserDataItem('distribution_search') + ->then(function ($search) use ($context, $localization) { + // Readed from the telegram user buffer + + if ($search) { + // Found started search process + + // Deleting from the telegram user buffer + $context->deleteUserDataItem('distribution_search', $search) + ->then(function () use ($context, $search, $localization) { + // Deleted from the telegram user buffer + + // Sending the message + $context->sendMessage('🗂 *' . $localization['distribution_search_ended'] . '*') + ->then(function (message $message) use ($context) { + // Sended the message + + // Ending the conversation process + $context->endConversation(); + + // Sending the distributions menu + commands::distributions($context); + }); + }); + } 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 $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(); + }); + } + } + + /** + * Search + * + * Sends the list of found distributions and menu with parameters: text + * + * @param context $context Request data from Telegram + * + * @return void + */ + protected static function search(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) { + // Initialized language + + // 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, $language, $localization) { + // Readed from the telegram user buffer + + if ($search) { + // Found started search process + + // Initializing the buffer of generated keyboard with languages + $keyboard = [ + [ + [ + 'text' => empty($search['text']) ? '🔴 ' . $localization['distribution_search_button_text'] : '🟢 ' . $localization['distribution_search_button_text'] . ': ' . $search['text'], + 'callback_data' => 'distribution_search_text' + ] + ], + [ + [ + 'text' => $search['confirmed'] ? '🪽 ' . $localization['distribution_search_button_confirmed'] : '🏘 ' . $localization['distribution_search_button_confirmed_all'], + 'callback_data' => 'distribution_search_confirmed' + ] + ], + [ + [ + 'text' => empty($search['location']['latitude']) || empty($search['location']['longitude']) ? '🔴 ' . $localization['distribution_search_button_location'] : '🟢 ' . $localization['distribution_search_button_location'] . ': ' . $search['location']['latitude'] . ', ' . $search['location']['longitude'], + 'callback_data' => 'distribution_search_location' + ] + ], + [ + [ + 'text' => empty($search['location']['distance']) ? '🔴 ' . $localization['distribution_search_button_distance'] : '🟢 ' . $localization['distribution_search_button_distance'] . ': ' . $search['location']['distance'] . ' ' . $localization['distribution_search_km'], + 'callback_data' => 'distribution_search_distance' + ] + ] + ]; + + // Ending the conversation process + $context->endConversation() + ->then(function () use ($context, $language, $localization, $search, $keyboard) { + // Deinitialized the conversation process + + // Initializing the distribution model + $model = new distribution; + + // Initializing amount of readed distributions per page + $page = 3; + + if ( + empty($search['text']) && + empty($search['location']['latitude']) && + empty($search['location']['longitude']) && + $search['confirmed'] === false + ) { + // Each search parameter is empty + + // Search for distributions + $distributions = $model->database->read( + amount: $page + 1, + offset: $search['page'] < 1 ? 0 : $page * $search['page'] + ); + } else { + // The search buffer has at least one parameter + + // Search for distributions + $distributions = $model->database->read( + filter: function (record $record) use ($search) { + // Initializing the matched buffer + $matched = false; + + if ($search['confirmed']) { + // Requested only confirmed + + if ($record->confirmed === 1) { + // The distribution is confirmed + + // Reinitializing the matched buffer + $matched = true; + } else { + // The distribution is not confirmed + + // Exit (success) + return false; + } + } + + if (!empty($search['text'])) { + // Requested search by text + + // Initializing the distribution localization model + $model = new distribution_localization; + + // Initializing localizations + $localizations = $model->database->read( + filter: fn(record $_record) => $_record->distribution === $record->identifier, + amount: 100 + ); + + foreach ($localizations as $localization) { + // Iterating over localizations + + if (levenshtein($localization->name, $search['text']) <= 4) { + // Names matched by Levenshtein function + + // Reinitializing the matched buffer + $matched = true; + + // Exit (success) + break; + } else { + // Names not matched by Levenshtein function + + // Exit (success) + return false; + } + } + } + + if ( + !empty($search['location']['latitude']) && + !empty($search['location']['longitude']) && + !empty($search['location']['distance']) + ) { + // Requested search by location + + if ( + static::vincenty( + $search['location']['latitude'], + $search['location']['longitude'], + $record->latitude, + $record->longitude + ) <= $search['location']['distance'] * 1000 + ) { + // Matched by distance to distribution + + // Reinitializing the matched buffer + $matched = true; + } else { + // Not matched by distance to distribution + + // Exit (success) + return false; + } + } + + // Exit (success) + return $matched; + }, + amount: $page + 1, + offset: $search['page'] < 1 ? 0 : $page * $search['page'] + ); + } + + // Initializing the next page existence status + $next = count($distributions) > $page; + + // Deleting the additional readed distribution + unset($distributions[$page]); + + // Initializing the title + $title = '🔎 *' . $localization['distribution_search_title'] . '*'; + + // Sending the message + $context->sendMessage( + << [ + 'inline_keyboard' => $keyboard, + 'disable_notification' => true, + 'remove_keyboard' => true + ], + ] + )->then(function (message $message) use ($context, $language, $localization, $search, $page, $next, $distributions) { + // Sended the message + + if (count($distributions) > 0) { + // Initialized distributions + + // Initializing the distributions localization model + $model = new distribution_localization; + + foreach ($distributions as $distribution) { + // Iterating over found distributions + + // Declaring the buffer of localized values + $values = null; + + // Initializing localizations + $localizations = $model->database->read( + filter: function (record $record) use ($distribution) { + // Exit (success) + return $record->distribution === $distribution->identifier; + }, + amount: 300 + ); + + if (count($localizations) > 0) { + // Initialized the distributions localizations + + foreach ($localizations as $record) { + // Iterating over localizations + + if ($record->language === $language->name) { + // Found localization by the account language + + // Initializing localization by the account language + $values = $record; + + // Exit (success) + break; + } + } + + if (is_null($values)) { + // Not initialized localization by the account language + + foreach ($localizations as $record) { + // Iterating over localizations + + if ($record->language === 'en') { + // Found localization by english language + + // Initializing localization by english language + $values = $record; + + // Exit (success) + break; + } + } + + if (is_null($values)) { + // Not initialized localization by english language + + // Initializing the account model + $model = new account; + + // Initializing the distribution creator account + $creator = $model->database->read( + filter: function (record $record) use ($distribution) { + // Exit (success) + return $record->identifier === $distribution->creator; + }, + amount: 1 + )[0] ?? null; + + if ($creator instanceof record) { + // Initialized the distribution creator account + + foreach ($localizations as $record) { + // Iterating over localizations + + if ($record->language === $creator->language) { + // Found localization by the distribution creator language + + // Initializing localization by the distribution creator language + $values = $record; + + // Exit (success) + break; + } + } + } + + if (is_null($values)) { + // Not initialized localization by the distribution creator language + + // Initializing localization by the distribution creator language + $values = $localizations[0]; + } + } + } + } else { + // Not initialized the distributions localizations + + // Sending the message + $context->sendMessage('⚠️ *' . $localization['distribution_search_not_localized'] . '*') + ->then(function (message $message) use ($context) { + // Sended the message + + // Ending the conversation process + $context->endConversation(); + }); + } + + // Initializing name for the message + $name = $values instanceof record ? $values->name : $localization['distribution_search_not_named']; + + // Initializing accepting status for the message + $accepted = $distribution->accepted ? '🪽' : ''; + + // Initializing members of the distribution + $members = []; + + // Initializing amount of members for the message + $amount = '*' . $localization['distribution_search_members'] . ':* ' . count($members); + + // Initializing location for the message + $location = '*' . $localization['distribution_search_location'] . ':* ' . str_replace('.', '\\.', (empty($distribution->latitude) ? '_' . $localization['empty'] . '_' : round($distribution->latitude, 6)) . ', ' . (empty($distribution->longitude) ? '_' . $localization['empty'] . '_' : round($distribution->longitude, 6))); + + // Sending the message + $context->sendMessage( + <<identifier* \- $name $accepted + + $amount + $location + TXT, + [ + 'reply_markup' => [ + 'inline_keyboard' => [ + [ + [ + 'text' => '🗺 ' . $localization['distribution_search_button_map'], + 'web_app' => [ + 'url' => 'https://telegram.map.svoboda.works?distribution=' . $distribution->identifier + ] + ], + /* [ + 'text' => ' ' . $localization['distribution_search_button_vhod'], + 'callback_data' => 'distribution_search_vhod' + ], */ + [ + 'text' => '🐣 ' . $localization['distribution_search_button_members'], + 'callback_data' => 'distribution_search_members' + ], + ], + /* [ + [ + 'text' => ' ' . $localization['distribution_search_button_telegram'], + 'url' => 'https://t.me/' + ], + ], */ + [ + [ + 'text' => '✉️ ' . $localization['distribution_search_button_message'], + 'callback_data' => 'distribution_search_message' + ], + ], + ], + 'disable_notification' => true, + 'remove_keyboard' => true + ], + ] + )->then(function (message $message) use ($context, $next) { + // Sended the message + + }); + } + + if ($next) { + // Exists the next page + + // Sending the message + $context->sendMessage( + '🔎 *' . $localization['distribution_search_page_next_exists'] . '*', + [ + 'reply_markup' => [ + 'inline_keyboard' => [ + [ + [ + 'text' => $localization['distribution_search_button_end'], + 'callback_data' => 'distribution_search_end' + ] + ], + [ + [ + 'text' => $localization['distribution_search_button_page_next'], + 'callback_data' => 'distribution_search_next' + ] + ] + ], + 'disable_notification' => true, + 'remove_keyboard' => true + ], + ] + )->then(function (message $message) use ($context) { + // Sended the message + + // Ending the conversation process + $context->endConversation(); + }); + } else { + // Not exists the next page + + // Sending the message + $context->sendMessage( + '🔎 *' . $localization['distribution_search_page_next_not_exists'] . '*', + [ + 'reply_markup' => [ + 'inline_keyboard' => [ + [ + [ + 'text' => $localization['distribution_search_button_end'], + 'callback_data' => 'distribution_search_end' + ] + ] + ], + 'disable_notification' => true, + 'remove_keyboard' => true + ], + ] + ) + ->then(function (message $message) use ($context) { + // Sended the message + + // Ending the conversation process + $context->endConversation(); + }); + } + } else { + // Not initialized distributions + + // Sending the message + $context->sendMessage( + '⚠️ *' . $localization['distribution_search_empty'] . '*', + [ + 'reply_markup' => [ + 'inline_keyboard' => [ + [ + [ + 'text' => $localization['distribution_search_button_end'], + 'callback_data' => 'distribution_search_end' + ] + ] + ], + 'disable_notification' => true, + 'remove_keyboard' => true + ], + ] + ) + ->then(function (message $message) use ($context) { + // Sended the message + + // Ending the conversation process + $context->endConversation(); + }); + } + }); + }); + } else { + // Not found started search process + + // Sending the message + $context->sendMessage('⚠️ *' . $localization['distribution_search_not_started'] . '*') + ->then(function (message $message) use ($context) { + // Sended the message + + // 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) { + // 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(); + }); + } + } + + /** + * Text + * + * Write search text into the distribution search buffer + * + * @param context $context Request data from Telegram + * + * @return void + */ + public static function text(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 + + // Reading from the telegram user buffer + $context->getUserDataItem('distribution_search') + ->then(function ($search) use ($context, $localization) { + // Readed from the telegram user buffer + + if ($search) { + // Found started search process + + // Initializing the new search text + $new = $context->getMessage()->getText(); + + if (!empty($new)) { + // Initialized the new text + + if (mb_strlen($new) >= 3) { + // Passed minimum length check + + if (mb_strlen($new) <= 64) { + // Passed maximum length check + + // Search for restricted characters + preg_match_all('/[\W\d]/u', $new, $matches); + + // Declaring the buffer of found restricted characters (except spaces) + $characters = []; + + // Declaring the counter of found spaces + $spaces = 0; + + foreach ($matches[0] as $match) { + // Iterating over found restricted characters + + if ($match === ' ') { + // Space-character + + // Increasing the counter of found spaces + ++$spaces; + } else { + // Not space-character + + // Writing into the buffer of found restricted characers (except spaces) + $characters[] = $match; + } + } + + if (empty($characters)) { + // Not found restricted characters + + try { + // Initializing the old search text + $old = empty($search['text']) ? '_' . $localization['empty'] . '_' : $search['text']; + + // Writing into the distribution search process buffer + $search['text'] = $new; + + // Writing to the telegram user buffer + $context->setUserDataItem('distribution_search', $search) + ->then(function () use ($context, $localization, $new, $old) { + // Writed to the telegram user buffer + + // Sending the message + $context->sendMessage('✅ *' . $localization['distribution_search_text_update_success'] . "* $old → *$new*") + ->then(function (message $message) use ($context) { + // Sended the message + + // Sending the search menu + static::search($context); + }); + }); + } catch (error $error) { + // Failed to send the message about search text update + + // Sending the message + $context->sendMessage('❎ *' . $localization['distribution_search_text_update_fail']) + ->then(function (message $message) use ($context) { + // Ending the conversation process + $context->endConversation(); + }); + } + } else { + // Found restricted characters + + // Initializing title of the message + $title = '⚠️ *' . $localization['distribution_search_text_request_restricted_characters_title'] . '*'; + + // Initializing description of the message + $description = '*' . $localization['distribution_search_text_request_restricted_characters_description'] . '* \\' . implode(', \\', $characters); + + // Sending the message + $context->sendMessage( + <<then(function (message $message) use ($context) { + // Sended the message + + // Ending the conversation process + $context->endConversation(); + + // Requesting to enter search text again + button_distribution_search::text($context); + }); + } + } else { + // Not passed maximum length check + + // Sending the message + $context->sendMessage('⚠️ *' . $localization['distribution_search_text_request_too_long'] . '*') + ->then(function (message $message) use ($context) { + // Sended the message + + // Ending the conversation process + $context->endConversation(); + + // Requesting to enter search text again + button_distribution_search::text($context); + }); + } + } else { + // Not passed minimum length check + + // Sending the message + $context->sendMessage('⚠️ *' . $localization['distribution_search_text_request_too_short'] . '*') + ->then(function (message $message) use ($context) { + // Sended the message + + // Ending the conversation process + $context->endConversation(); + + // Requesting to enter search text again + button_distribution_search::text($context); + }); + } + } else { + // Failed to initialize the new search text + + // Sending the message + $context->sendMessage('📄 *' . $localization['distribution_search_text_request_not_acceptable'] . '*') + ->then(function (message $message) use ($context) { + // Sended the message + + // Ending the conversation process + $context->endConversation(); + + // Requesting to enter search text again + button_distribution_search::text($context); + }); + } + } 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 $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(); + }); + } + } + + /** + * Confirmed + * + * Toggle filter by confirmation status into the distribution search buffer + * + * @param context $context Request data from Telegram + * + * @return void + */ + public static function confirmed(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 + + // Reading from the telegram user buffer + $context->getUserDataItem('distribution_search') + ->then(function ($search) use ($context, $localization) { + // Readed from the telegram user buffer + + if ($search) { + // Found started search process + + // Iverting the "confirmed" parameter + $search['confirmed'] = !$search['confirmed']; + + // Writing to the telegram user buffer + $context->setUserDataItem('distribution_search', $search) + ->then(function () use ($context, $search, $localization) { + // Writed to the telegram user buffer + + // Initializing the old value for the message + $old = $search['confirmed'] ? $localization['distribution_search_button_confirmed_all'] : $localization['distribution_search_button_confirmed']; + + // Initializing the new value for the message + $new = $search['confirmed'] ? $localization['distribution_search_button_confirmed'] : $localization['distribution_search_button_confirmed_all']; + + // Sending the message + $context->sendMessage('✅ *' . $localization['distribution_search_confirmed_update_success'] . "* $old → *$new*") + ->then(function (message $message) use ($context) { + // Sended the message + + // Sending the search menu + static::search($context); + }); + }); + } 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 $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(); + }); + } + } + + /** + * Location + * + * Write location into the distribution search buffer + * + * @param context $context Request data from Telegram + * + * @return void + */ + public static function location(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 + + // Reading from the telegram user buffer + $context->getUserDataItem('distribution_search') + ->then(function ($search) use ($context, $localization) { + // Readed from the telegram user buffer + + if ($search) { + // Found started search process + + // Initializing the new location + preg_match_all('/(\-?\d{1,2})\.?(\d*)/', $context->getMessage()->getText(), $matches); + + if ($matches[0]) { + // Initialized the new location + + // Initializing the new latitude + $latitude = round((float) $matches[0][0], 6); + + // Initializing the new longitude + $longitude = round((float) $matches[0][1], 6); + + if (!empty($latitude) && !empty($longitude)) { + // Initialized the new latitude and the new longitude + + if ($latitude >= 0) { + // Passed latitude minimum value check + + if ($latitude <= 90) { + // Passed latitude maximum value check + + if ($longitude >= 0) { + // Passed longitude minimum value check + + if ($longitude <= 180) { + // Passed longitude maximum value check + + try { + // Initializing the old location + $old = str_replace('.', '\\.', (empty($search['location']['latitude']) ? '_' . $localization['empty'] . '_' : $search['location']['latitude']) . ', ' . (empty($search['location']['longitude']) ? '_' . $localization['empty'] . '_' : $search['location']['longitude'])); + + // Writing into the distribution search process buffer + $search['location']['latitude'] = $latitude; + $search['location']['longitude'] = $longitude; + + // Writing to the telegram user buffer + $context->setUserDataItem('distribution_search', $search) + ->then(function () use ($context, $localization, $latitude, $longitude, $old) { + // Writed to the telegram user buffer + + // Initializing the new location + $new = str_replace('.', '\\.', $latitude . ', ' . $longitude); + + // Sending the message + $context->sendMessage('✅ *' . $localization['distribution_search_location_update_success'] . "*\n$old → *$new*") + ->then(function (message $message) use ($context) { + // Sended the message + + // Sending the search menu + static::search($context); + }); + }); + } catch (error $error) { + // Failed to send the message about name update + + // Sending the message + $context->sendMessage('❎ *' . $localization['distribution_search_location_update_fail']) + ->then(function (message $message) use ($context) { + // Sended the message + + // Ending the conversation process + $context->endConversation(); + }); + } + } else { + // Not passed longitude maximum value check + + // Sending the message + $context->sendMessage('⚠️ *' . $localization['distribution_search_location_send_longitude_too_big'] . '*') + ->then(function (message $message) use ($context) { + // Sended the message + + // Ending the conversation process + $context->endConversation(); + + // Requesting to enter locaztion again + button_distribution_search::location($context); + }); + } + } else { + // Not passed longitude minimum value check + + // Sending the message + $context->sendMessage('⚠️ *' . $localization['distribution_search_location_send_longitude_too_small'] . '*') + ->then(function (message $message) use ($context) { + // Sended the message + + // Ending the conversation process + $context->endConversation(); + + // Requesting to enter locaztion again + button_distribution_search::location($context); + }); + } + } else { + // Not passed latitude maximum value check + + // Sending the message + $context->sendMessage('⚠️ *' . $localization['distribution_search_location_send_latitude_too_big'] . '*') + ->then(function (message $message) use ($context) { + // Sended the message + + // Ending the conversation process + $context->endConversation(); + + // Requesting to enter locaztion again + button_distribution_search::location($context); + }); + } + } else { + // Not passed latitude minimum value check + + // Sending the message + $context->sendMessage('⚠️ *' . $localization['distribution_search_location_send_latitude_too_small'] . '*') + ->then(function (message $message) use ($context) { + // Sended the message + + // Ending the conversation process + $context->endConversation(); + + // Requesting to enter locaztion again + button_distribution_search::location($context); + }); + } + } else { + // Failed to initialize the new location + + // Sending the message + $context->sendMessage('📄 *' . $localization['distribution_search_location_send_not_acceptable'] . '*') + ->then(function (message $message) use ($context) { + // Sended the message + + // Ending the conversation process + $context->endConversation(); + + // Requesting to send location again + button_distribution_search::location($context); + }); + } + } else { + // Not initialized the new location + + // Sending the message + $context->sendMessage('📄 *' . $localization['distribution_search_location_send_not_acceptable'] . '*') + ->then(function (message $message) use ($context) { + // Sended the message + + // Ending the conversation process + $context->endConversation(); + + // Requesting to send locaztion again + button_distribution_search::location($context); + }); + } + } 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 $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(); + }); + } + } + + /** + * Distance + * + * Write location distance into the distribution search buffer + * + * @param context $context Request data from Telegram + * + * @return void + */ + public static function distance(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 + + // Reading from the telegram user buffer + $context->getUserDataItem('distribution_search') + ->then(function ($search) use ($context, $localization) { + // Readed from the telegram user buffer + + if ($search) { + // Found started search process + + // Initializing the new distance + $new = $context->getMessage()->getText(); + + if (!empty($new)) { + // Initialized the new distance + + // Search for restricted characters + preg_match_all('/[^\d]/u', $new, $matches); + + // Initializing the buffer of found restricted characters (except spaces) + $characters = $matches[0]; + + if (empty($characters)) { + // Not found restricted characters + + // Converting the new value from string to integer + $new = (int) $new; + + if ($new >= 0) { + // Passed minimum value check + + if ($new <= 600) { + // Passed maximum value check + + try { + // Initializing the old name + $old = empty($search['location']['distance']) ? '_' . $localization['empty'] . '_' : $search['location']['distance']; + + // Writing into the distribution search process buffer + $search['location']['distance'] = $new; + + // Writing to the telegram user buffer + $context->setUserDataItem('distribution_search', $search) + ->then(function () use ($context, $localization, $new, $old) { + // Writed to the telegram user buffer + + // Sending the message + $context->sendMessage('✅ *' . $localization['distribution_search_distance_update_success'] . "* $old \(" . $localization['distribution_search_km'] . '\) ' . " → *$new* \(" . $localization['distribution_search_km'] . '\)') + ->then(function (message $message) use ($context) { + // Sended the message + + // Sending the search menu + static::search($context); + }); + }); + } catch (error $error) { + // Failed to send the message about name update + + // Sending the message + $context->sendMessage('❎ *' . $localization['distribution_search_distance_update_fail']) + ->then(function (message $message) use ($context) { + // Sended the message + + // Ending the conversation process + $context->endConversation(); + }); + } + } else { + // Not passed maximum value check + + // Sending the message + $context->sendMessage('⚠️ *' . $localization['distribution_search_distance_request_too_long_km'] . '*') + ->then(function (message $message) use ($context) { + // Sended the message + + // Ending the conversation process + $context->endConversation(); + + // Requesting to enter distance again + button_distribution_search::distance($context); + }); + } + } else { + // Not passed minimum value check + + // Sending the message + $context->sendMessage('⚠️ *' . $localization['distribution_search_distance_request_too_short_km'] . '*') + ->then(function (message $message) use ($context) { + // Sended the message + + // Ending the conversation process + $context->endConversation(); + + // Requesting to enter ditance again + button_distribution_search::distance($context); + }); + } + } else { + // Found restricted characters + + // Initializing title of the message + $title = '⚠️ *' . $localization['distribution_search_distance_request_restricted_characters_title'] . '*'; + + // Initializing description of the message + $description = '*' . $localization['distribution_search_distance_request_restricted_characters_description'] . '* \\' . implode(', \\', $characters); + + // Sending the message + $context->sendMessage( + <<then(function (message $message) use ($context) { + // Sended the message + + // Ending the conversation process + $context->endConversation(); + + // Requesting to enter distance again + button_distribution_search::distance($context); + }); + } + } else { + // Failed to initialize the new distance + + // Sending the message + $context->sendMessage('📄 *' . $localization['distribution_search_distance_request_not_acceptable'] . '*') + ->then(function (message $message) use ($context) { + // Sended the message + + // Ending the conversation process + $context->endConversation(); + + // Requesting to enter distance again + button_distribution_search::distance($context); + }); + } + } 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 $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(); + }); + } + } +} diff --git a/svoboda/negotiator/system/models/telegram/selections.php b/svoboda/svoboder/system/models/telegram/selections.php similarity index 92% rename from svoboda/negotiator/system/models/telegram/selections.php rename to svoboda/svoboder/system/models/telegram/selections.php index 907d8c1..f8a681b 100755 --- a/svoboda/negotiator/system/models/telegram/selections.php +++ b/svoboda/svoboder/system/models/telegram/selections.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace svoboda\negotiator\models\telegram; +namespace svoboda\svoboder\models\telegram; // Files of the project -use svoboda\negotiator\models\core, - svoboda\negotiator\models\enumerations\language; +use svoboda\svoboder\models\core, + svoboda\svoboder\models\enumerations\language; // Framework for Telegram use Zanzara\Context as context, @@ -18,7 +18,7 @@ use mirzaev\baza\record; /** * Telegram selections * - * @package svoboda\negotiator\models\telegram + * @package svoboda\svoboder\models\telegram * * @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License * @author Arsen Mirzaev Tatyano-Muradovich @@ -92,7 +92,7 @@ final class selections extends core $keyboard[++$row] = [ [ 'text' => '🗂 ' . $localization['select_language_button_add'], - 'url' => 'https://git.svoboda.works/svoboda/negotiator/src/branch/stable/svoboda/negotiator/system/localizations' + 'url' => 'https://git.svoboda.works/svoboda/svoboder/src/branch/stable/svoboda/svoboder/system/localizations' ] ]; diff --git a/svoboda/negotiator/system/models/telegram/settings.php b/svoboda/svoboder/system/models/telegram/settings.php similarity index 94% rename from svoboda/negotiator/system/models/telegram/settings.php rename to svoboda/svoboder/system/models/telegram/settings.php index 8cc8a0f..eb8cea3 100755 --- a/svoboda/negotiator/system/models/telegram/settings.php +++ b/svoboda/svoboder/system/models/telegram/settings.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace svoboda\negotiator\models\telegram; +namespace svoboda\svoboder\models\telegram; // Files of the project -use svoboda\negotiator\models\core, - svoboda\negotiator\models\account, - svoboda\negotiator\models\enumerations\language, - svoboda\negotiator\models\telegram\middlewares; +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, @@ -25,7 +25,7 @@ use Error as error; /** * Telegram settings * - * @package svoboda\negotiator\models\telegram + * @package svoboda\svoboder\models\telegram * * @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License * @author Arsen Mirzaev Tatyano-Muradovich diff --git a/svoboda/svoboder/system/models/traits/coordinates.php b/svoboda/svoboder/system/models/traits/coordinates.php new file mode 100644 index 0000000..9450b57 --- /dev/null +++ b/svoboda/svoboder/system/models/traits/coordinates.php @@ -0,0 +1,66 @@ + + */ +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; + } +} diff --git a/svoboda/negotiator/system/public/telegram.php b/svoboda/svoboder/system/public/telegram.php similarity index 70% rename from svoboda/negotiator/system/public/telegram.php rename to svoboda/svoboder/system/public/telegram.php index 2095d83..d3fb4fb 100755 --- a/svoboda/negotiator/system/public/telegram.php +++ b/svoboda/svoboder/system/public/telegram.php @@ -2,20 +2,22 @@ declare(strict_types=1); -namespace svoboda\negotiator; +namespace svoboda\svoboder; // Files of the project -use svoboda\negotiator\models\distribution, - svoboda\negotiator\models\localization\distribution as distribution_localization, - svoboda\negotiator\models\telegram\middlewares, - svoboda\negotiator\models\telegram\commands, - svoboda\negotiator\models\telegram\buttons, - svoboda\negotiator\models\telegram\selections, - svoboda\negotiator\models\telegram\settings, - svoboda\negotiator\models\enumerations\language, - svoboda\negotiator\models\telegram\processes\distribution\registration as process_distribution_registration, - svoboda\negotiator\models\telegram\buttons\distribution\registration as button_distribution_registration, - svoboda\negotiator\models\telegram\processes\distribution\localization as process_distribution_localization; +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, @@ -77,9 +79,27 @@ $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('distributions', [commands::class, 'distributions']); $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']); @@ -97,10 +117,10 @@ foreach (language::cases() as $language) { $robot->onCbQueryData(['distribution_registration_select_language_' . $language->name], fn(context $context) => process_distribution_registration::language($context, $language)); }; -// Initializing the robot distribution localization name enter button handler +// Initializing the robot distribution registration localization name enter button handler $robot->onCbQueryData(['distribution_registration_name'], [button_distribution_registration::class, 'name']); -// Initializing the robot distribution location send button handler +// Initializing the robot distribution registration location send button handler $robot->onCbQueryData(['distribution_registration_location'], [button_distribution_registration::class, 'location']); diff --git a/svoboda/negotiator/system/settings/.gitignore b/svoboda/svoboder/system/settings/.gitignore similarity index 100% rename from svoboda/negotiator/system/settings/.gitignore rename to svoboda/svoboder/system/settings/.gitignore diff --git a/svoboda/negotiator/system/settings/telegram.php.sample b/svoboda/svoboder/system/settings/telegram.php.sample similarity index 100% rename from svoboda/negotiator/system/settings/telegram.php.sample rename to svoboda/svoboder/system/settings/telegram.php.sample diff --git a/svoboda/negotiator/system/storage/images/mushroom.jpg b/svoboda/svoboder/system/storage/images/mushroom.jpg similarity index 100% rename from svoboda/negotiator/system/storage/images/mushroom.jpg rename to svoboda/svoboder/system/storage/images/mushroom.jpg