diff --git a/composer.json b/composer.json index 429a9c4..120c991 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,7 @@ "react/filesystem": "^0.1.2", "nyholm/psr7": "^1.8", "irazasyed/telegram-bot-sdk": "^3.15", - "nutgram/nutgram": "^4.40", + "nutgram/nutgram": "^4.42", "psr/simple-cache": "^3.0", "symfony/cache": "^8.0" }, diff --git a/composer.lock b/composer.lock index aefbefd..ffb5173 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "1f5b64f8a594a24294320f54e2470337", + "content-hash": "44219ee87ec9e34c98a5404150eb4ac0", "packages": [ { "name": "badfarm/zanzara", @@ -1923,16 +1923,16 @@ }, { "name": "nutgram/nutgram", - "version": "4.40.2", + "version": "4.42.0", "source": { "type": "git", "url": "https://github.com/nutgram/nutgram.git", - "reference": "caf0deb11f6dae93b407f5bb85a94d5336a1b945" + "reference": "034257dbc29947b73e04b5d92b07d780d8962810" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nutgram/nutgram/zipball/caf0deb11f6dae93b407f5bb85a94d5336a1b945", - "reference": "caf0deb11f6dae93b407f5bb85a94d5336a1b945", + "url": "https://api.github.com/repos/nutgram/nutgram/zipball/034257dbc29947b73e04b5d92b07d780d8962810", + "reference": "034257dbc29947b73e04b5d92b07d780d8962810", "shasum": "" }, "require": { @@ -1994,7 +1994,7 @@ ], "support": { "issues": "https://github.com/nutgram/nutgram/issues", - "source": "https://github.com/nutgram/nutgram/tree/4.40.2" + "source": "https://github.com/nutgram/nutgram/tree/4.42.0" }, "funding": [ { @@ -2006,7 +2006,7 @@ "type": "github" } ], - "time": "2026-01-25T17:57:40+00:00" + "time": "2026-02-12T17:23:52+00:00" }, { "name": "nyholm/psr7", diff --git a/kodorvan/constructor/system/localizations/russian.php b/kodorvan/constructor/system/localizations/russian.php index b38c708..a9aa276 100644 --- a/kodorvan/constructor/system/localizations/russian.php +++ b/kodorvan/constructor/system/localizations/russian.php @@ -10,7 +10,7 @@ return [ // Главное меню 'menu_title' => 'Главное меню', 'menu_description_guest' => "🔥 *Создайте ваш первый проект* и получите *ориентировочную стоимость* всего за 2 минуты", - 'menu_description_partner' => "*Благодарю за выбор нашей команды*. Теперь Вы один из наших %d партнёров!", + 'menu_description_partner' => "*Благодарю за выбор нашей команды*\. Теперь Вы один из наших %d партнёров!", 'menu_update' => 'Последнее обновление', 'menu_button_project_new' => 'Создать', 'menu_button_projects' => 'Проекты', @@ -24,14 +24,17 @@ return [ // Проект: создание 'project_create_title' => 'Создание проекта', - 'project_create_description' => 'Получите ориентировочную стоимость всего за 2 минуты\!', - 'project_create_cost' => 'Стоимость', + /* 'project_create_description' => "Расчитайте ориентировочное время разработки, затем выберите разработчиков и получите стоимость\n\nПосле расчётов можно будет отправить проект в заказ разработчикам и приложить ТЗ, либо краткое описание задачи\n\nМы погружаемся в проекты полностью, поэтому стараемся не распыляться - от степени нагрузки меняется коэффициент стоимости!", */ + 'project_create_description' => "Задайте параметры и получите ориентировочное время разработки, затем выберите разработчиков и получите стоимость их работы\n\n_После расчётов можно отправить проект в заказ и приложить ТЗ, либо описание задачи_", + 'project_create_time' => 'Время разработки', + 'project_create_time_hours' => 'ч', + 'project_create_time_hours_from' => 'от', 'project_create_button_request' => 'Заказать', - 'project_create_types_title' => 'Выбор типа проекта', - 'project_create_types_description' => 'Каждый тип имеет уникальные параметры и коэффициент', - 'project_create_button_type' => 'Тип проекта', - 'project_create_button_type_selected' => 'Тип', + 'project_create_architectures_title' => 'Выбор архитектуры проекта', + 'project_create_architectures_description' => 'Каждая архитектура имеет уникальные параметры и коэффициенты \- это основа дальнейших расчётов\!', + 'project_create_button_architecture' => 'Архитектура', + 'project_create_button_architecture_selected' => 'Архитектура', 'project_create_purposes_title' => 'Выбор назначения', 'project_create_purposes_description' => 'Вектор разработки, основание проекта', @@ -47,13 +50,13 @@ return [ 'project_create_cancelled' => 'Создание проекта отменено', // Проект: типы - 'project_type_chat_robot' => 'Чат-робот', - 'project_type_parser' => 'Парсер', - 'project_type_calculator' => 'Калькулятор', - 'project_type_crm' => 'CRM', - 'project_type_site' => 'Сайт', - 'project_type_program' => 'Программа', - 'project_type_complex' => 'Нестандартный', + 'project_architecture_chat_robot' => 'Чат-робот', + 'project_architecture_parser' => 'Парсер', + 'project_architecture_calculator' => 'Калькулятор', + 'project_architecture_crm' => 'CRM', + 'project_architecture_site' => 'Сайт', + 'project_architecture_program' => 'Программа', + 'project_architecture_complex' => 'Нестандартная', // Проект: назначение 'project_purpose_funnel' => 'Воронка', diff --git a/kodorvan/constructor/system/models/project/enumerations/type.php b/kodorvan/constructor/system/models/project/enumerations/architecture.php similarity index 81% rename from kodorvan/constructor/system/models/project/enumerations/type.php rename to kodorvan/constructor/system/models/project/enumerations/architecture.php index aa17d79..59baeb5 100644 --- a/kodorvan/constructor/system/models/project/enumerations/type.php +++ b/kodorvan/constructor/system/models/project/enumerations/architecture.php @@ -18,22 +18,22 @@ use InvalidArgumentException as exception_argument, DomainException as exception_domain; /** - * Type + * Architecture * * @package kodorvan\neurobot\models\project\enumerations * * @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License * @author Arsen Mirzaev Tatyano-Muradovich */ -enum type +enum architecture { case chat_robot; case parser; - case calculator; + case script; case crm; - /* case marketplace; */ case site; case program; + /* case calculator; */ case complex; @@ -42,7 +42,7 @@ enum type * * @param language $language The language * - * @return string The project type label + * @return string The project architecture label */ public function label(language $language = LANGUAGE_DEFAULT): string { @@ -56,17 +56,13 @@ enum type language::en => 'Parser', language::ru => 'Парсер' }, - static::calculator => match ($language) { - language::en => 'Calculator', - language::ru => 'Калькулятор' + static::script => match ($language) { + language::en => 'Script', + language::ru => 'Скрипт' }, static::crm => match ($language) { default => 'CRM' }, - /* static::marketplace => match ($language) { - language::en => 'Marketplace', - language::ru => 'Маркетплейс' - }, */ static::site => match ($language) { language::en => 'Site', language::ru => 'Сайт' @@ -93,9 +89,8 @@ enum type return match ($this) { static::chat_robot => 2, static::parser => 1, - static::calculator => 2, + static::script => 1, static::crm => 1, - /* static::marketplace => 4, */ static::site => 1, static::program => 1, static::complex => 2, @@ -119,6 +114,7 @@ enum type purpose::game, purpose::gallery, purpose::crm, + purpose::calculate, purpose::landing, purpose::marketplace, purpose::events, @@ -127,8 +123,8 @@ enum type static::parser => [ purpose::search ], - static::calculator => [ - purpose::calculate + static::script => [ + purpose::logic ], static::crm => [ purpose::workers, @@ -142,6 +138,7 @@ enum type purpose::neural_network, purpose::gallery, purpose::crm, + purpose::calculate, purpose::landing, purpose::marketplace, purpose::workers, @@ -153,6 +150,7 @@ enum type static::program => [ purpose::neural_network, purpose::crm, + purpose::calculate, purpose::marketplace, purpose::workers, purpose::tools, @@ -168,6 +166,8 @@ enum type * Cost * * @return int|float The minimal cost of the project development + * + * @deprecated */ public function cost(currency $currency = CURRENCY_DEFAULT): int|float { @@ -181,9 +181,9 @@ enum type currency::usd => 35, currency::rub => 3500 }, - static::calculator => match ($currency) { - currency::usd => 40, - currency::rub => 4000 + static::script => match ($currency) { + currency::usd => 10, + currency::rub => 1000 }, static::crm => match ($currency) { currency::usd => 100, @@ -203,4 +203,24 @@ enum type } }; } + + /** + * Coefficient + * + * @return int The project development hours + */ + public function coefficient(): int|float + { + // Exit (success) + return (int) match ($this) { + static::chat_robot => 3, + static::parser => 2, + static::script => 1, + static::crm => 6, + static::site => 3, + static::program => 4, + static::complex => 5, + default => 5 + }; + } } diff --git a/kodorvan/constructor/system/models/project/enumerations/purpose.php b/kodorvan/constructor/system/models/project/enumerations/purpose.php index faf3911..86615cb 100644 --- a/kodorvan/constructor/system/models/project/enumerations/purpose.php +++ b/kodorvan/constructor/system/models/project/enumerations/purpose.php @@ -31,6 +31,7 @@ enum purpose case charity; case search; case calculate; + case logic; case game; case workers; @@ -45,7 +46,7 @@ enum purpose * * @param language $language The language * - * @return string The project type label + * @return string The project form label */ public function label(language $language = LANGUAGE_DEFAULT): string { @@ -61,7 +62,7 @@ enum purpose }, static::neural_network => match ($language) { language::en => 'Neural network', - language::ru => 'Нейросети' + language::ru => 'Нейросеть' }, static::game => match ($language) { language::en => 'Game', @@ -94,6 +95,10 @@ enum purpose language::en => 'Calculate', language::ru => 'Расчёты' }, + static::logic => match ($language) { + language::en => 'Logic', + language::ru => 'Логика' + }, static::game => match ($language) { language::en => 'Game', language::ru => 'Игра' @@ -141,6 +146,7 @@ enum purpose static::charity => 2, static::search => 2, static::calculate => 2, + static::logic => 1, static::tools => 1, static::workers => 1, static::objects => 1, @@ -153,7 +159,7 @@ enum purpose /** * Coefficient * - * @return int|float Coefficient to the project development cost + * @return int|float Coefficient to the project development hours */ public function coefficient(): int|float { @@ -170,6 +176,7 @@ enum purpose static::charity => 0.8, static::search => 1, static::calculate => 1.1, + static::logic => 1, static::tools => 1, static::workers => 1.2, static::objects => 1, diff --git a/kodorvan/constructor/system/models/telegram/conversations/project/create.php b/kodorvan/constructor/system/models/telegram/conversations/project/create.php index d1d3ae0..d0959f1 100644 --- a/kodorvan/constructor/system/models/telegram/conversations/project/create.php +++ b/kodorvan/constructor/system/models/telegram/conversations/project/create.php @@ -9,7 +9,7 @@ use kodorvan\constructor\models\core, kodorvan\constructor\models\account, kodorvan\constructor\models\localization, kodorvan\constructor\models\settings, - kodorvan\constructor\models\project\enumerations\type as project_type, + kodorvan\constructor\models\project\enumerations\architecture as project_architecture, kodorvan\constructor\models\project\enumerations\purpose as project_purpose, kodorvan\constructor\models\telegram\processes\language\select as process_language_select; @@ -50,11 +50,11 @@ final class create extends menu public string $text = ''; /** - * Type + * Architecture * - * @var project_type $type The project type + * @var project_architecture $architecture The project architecture */ - public project_type $type; + public project_architecture $architecture; /** * Purpose @@ -69,29 +69,40 @@ final class create extends menu * Generate the project create menu and start the process * * @param telegram $robot The robot + * @param bool $new Create a new process? * * @return void */ - public function start(telegram $robot): void + public function start(telegram $robot, bool $new = true): void { - // Initializing the language + if ($new) { + // Requested creating a new process + + // Ending the conversation + $robot->endConversation(); + } + + // Initializing the account language $language = $robot->get('language') ?? LANGUAGE_DEFAULT; - // Initializing the menu message localization + // Initializing the account localization $localization = $robot->get('localization') ?? new localization($language); // Initializing the account $account = $robot->get('account'); - // Initializing the project development cost - $cost = $this->cost(); + // Initializing the project development hours + $hours = $this->hours(); // Generating the message text $text = implode( "\n\n", [ "🏛 *$localization->project_create_title*", - $cost > 0 ? "*$localization->project_create_cost:* " . $cost . ($account->currency?->symbol() ?? CURRENCY_DEFAULT->symbol()) : $localization->project_create_description + /* $hours > 0 ? "*$localization->project_create_time* " . unmarkdown((string) $hours) . " $localization->hours" : $localization->project_create_description */ + $hours > 0 + ? "*$localization->project_create_time:* $hours$localization->project_create_time_hours" + : $localization->project_create_description, ] ); @@ -104,19 +115,19 @@ final class create extends menu ); } - if (isset($this->type)) { - // Initialized the project type + if (isset($this->architecture)) { + // Initialized the project architecture // Initializing the buffer for the first row $first = []; - // Writing the project type button into the buffer of the first row + // Writing the project architecture button into the buffer of the first row $first[0] = button::make( - text: $localization['project_type_' . $this->type?->name] ?? $this->type?->label(language: $language), - callback_data: '@types' + text: $localization['project_architecture_' . $this->architecture?->name] ?? $this->architecture?->label(language: $language), + callback_data: '@architectures' ); - if (isset($this->purpose) || $this->type === project_type::complex) { + if (isset($this->purpose) || $this->architecture === project_architecture::complex) { // Initialized the project purpose // Writing the project purpose button into the buffer of the first row @@ -134,14 +145,13 @@ final class create extends menu // Initializing the maximum amount of buttons in a row $break = 2; - if (match ($this->type) { - project_type::chat_robot, - project_type::parser, - project_type::calculator, - project_type::crm, - project_type::site, - project_type::program, - project_type::complex => true, + if (match ($this->architecture) { + project_architecture::chat_robot, + project_architecture::parser, + project_architecture::crm, + project_architecture::site, + project_architecture::program, + project_architecture::complex => true, default => false }) { // Integrations @@ -155,14 +165,13 @@ final class create extends menu } } - if (match ($this->type) { - project_type::chat_robot, - project_type::parser, - project_type::calculator, - project_type::crm, - project_type::site, - project_type::program, - project_type::complex => true, + if (match ($this->architecture) { + project_architecture::chat_robot, + project_architecture::parser, + project_architecture::crm, + project_architecture::site, + project_architecture::program, + project_architecture::complex => true, default => false }) { // Server @@ -176,12 +185,11 @@ final class create extends menu } } - if (match ($this->type) { - project_type::calculator, - project_type::crm, - project_type::site, - project_type::program, - project_type::complex => true, + if (match ($this->architecture) { + project_architecture::crm, + project_architecture::site, + project_architecture::program, + project_architecture::complex => true, default => false }) { // Interface @@ -189,15 +197,11 @@ final class create extends menu if (isset($this->interface)) { // Initialized the project interface - if ($this->type === project_type::calculator) { - // Calculator - - // site, mobile or desktop program - } else if ($this->type === project_type::crm) { + if ($this->architecture === project_architecture::crm) { // CRM // site, mobile or desktop program - } else if ($this->type === project_type::program) { + } else if ($this->architecture === project_architecture::program) { // Program // mobile or desktop @@ -205,15 +209,11 @@ final class create extends menu } else { // Not initialized the project interface - if ($this->type === project_type::calculator) { - // Calculator - - // site, mobile or desktop program - } else if ($this->type === project_type::crm) { + if ($this->architecture === project_architecture::crm) { // CRM // site, mobile or desktop program - } else if ($this->type === project_type::program) { + } else if ($this->architecture === project_architecture::program) { // Program // mobile or desktop @@ -221,14 +221,13 @@ final class create extends menu } } - if (match ($this->type) { - project_type::chat_robot, - project_type::parser, - project_type::calculator, - project_type::crm, - project_type::site, - project_type::program, - project_type::complex => true, + if (match ($this->architecture) { + project_architecture::chat_robot, + project_architecture::parser, + project_architecture::crm, + project_architecture::site, + project_architecture::program, + project_architecture::complex => true, default => false }) { // Repository @@ -242,12 +241,31 @@ final class create extends menu } } - if (match ($this->type) { - project_type::calculator, - project_type::crm, - project_type::site, - project_type::program, - project_type::complex => true, + if (match ($this->architecture) { + project_architecture::chat_robot, + project_architecture::parser, + project_architecture::crm, + project_architecture::site, + project_architecture::program, + project_architecture::complex => true, + default => false + }) { + // Launch strategy (fast, quality, progressively) + + if (isset($this->strategy)) { + // Initialized the project strategy + + } else { + // Not initialized the project strategy + + } + } + + if (match ($this->architecture) { + project_architecture::crm, + project_architecture::site, + project_architecture::program, + project_architecture::complex => true, default => false }) { // Testing @@ -261,11 +279,11 @@ final class create extends menu } } - if (match ($this->type) { - project_type::crm, - project_type::site, - project_type::program, - project_type::complex => true, + if (match ($this->architecture) { + project_architecture::crm, + project_architecture::site, + project_architecture::program, + project_architecture::complex => true, default => false }) { // Security @@ -279,14 +297,13 @@ final class create extends menu } } - if (match ($this->type) { - project_type::chat_robot, - project_type::parser, - project_type::calculator, - project_type::crm, - project_type::site, - project_type::program, - project_type::complex => true, + if (match ($this->architecture) { + project_architecture::chat_robot, + project_architecture::parser, + project_architecture::crm, + project_architecture::site, + project_architecture::program, + project_architecture::complex => true, default => false }) { // Documenting @@ -300,13 +317,12 @@ final class create extends menu } } - if (match ($this->type) { - project_type::chat_robot, - project_type::calculator, - project_type::crm, - project_type::site, - project_type::program, - project_type::complex => true, + if (match ($this->architecture) { + project_architecture::chat_robot, + project_architecture::crm, + project_architecture::site, + project_architecture::program, + project_architecture::complex => true, default => false }) { // Localization @@ -320,13 +336,12 @@ final class create extends menu } } - if (match ($this->type) { - project_type::chat_robot, - project_type::parser, - project_type::calculator, - project_type::crm, - project_type::site, - project_type::complex => true, + if (match ($this->architecture) { + project_architecture::chat_robot, + project_architecture::parser, + project_architecture::crm, + project_architecture::site, + project_architecture::complex => true, default => false }) { // Journal @@ -340,13 +355,12 @@ final class create extends menu } } - if (match ($this->type) { - project_type::chat_robot, - project_type::calculator, - project_type::crm, - project_type::site, - project_type::program, - project_type::complex => true, + if (match ($this->architecture) { + project_architecture::chat_robot, + project_architecture::crm, + project_architecture::site, + project_architecture::program, + project_architecture::complex => true, default => false }) { // Scalability @@ -360,11 +374,11 @@ final class create extends menu } } - if (match ($this->type) { - project_type::chat_robot, - project_type::crm, - project_type::site, - project_type::complex => true, + if (match ($this->architecture) { + project_architecture::chat_robot, + project_architecture::crm, + project_architecture::site, + project_architecture::complex => true, default => false }) { // Framework @@ -378,14 +392,13 @@ final class create extends menu } } - if (match ($this->type) { - project_type::chat_robot, - project_type::parser, - project_type::calculator, - project_type::crm, - project_type::site, - project_type::program, - project_type::complex => true, + if (match ($this->architecture) { + project_architecture::chat_robot, + project_architecture::parser, + project_architecture::crm, + project_architecture::site, + project_architecture::program, + project_architecture::complex => true, default => false }) { // Database @@ -399,13 +412,12 @@ final class create extends menu } } - if (match ($this->type) { - project_type::chat_robot, - project_type::calculator, - project_type::crm, - project_type::site, - project_type::program, - project_type::complex => true, + if (match ($this->architecture) { + project_architecture::chat_robot, + project_architecture::crm, + project_architecture::site, + project_architecture::program, + project_architecture::complex => true, default => false }) { // Depth of development @@ -419,17 +431,16 @@ final class create extends menu } } - if (match ($this->type) { - project_type::chat_robot, - project_type::parser, - project_type::calculator, - project_type::crm, - project_type::site, - project_type::program, - project_type::complex => true, + if (match ($this->architecture) { + project_architecture::chat_robot, + project_architecture::parser, + project_architecture::crm, + project_architecture::site, + project_architecture::program, + project_architecture::complex => true, default => false }) { - // Form of cooperation + // architecture of cooperation if (isset($this->cooperation)) { // Initialized the project cooperation @@ -452,21 +463,21 @@ final class create extends menu $this->addButtonRow(...$first); } } else { - // Not initialized the project type + // Not initialized the project architecture - // Writing the project type button + // Writing the project architecture button $this->addButtonRow( button::make( - text: "🔸 $localization->project_create_button_type", - callback_data: '@types' + text: "🔸 $localization->project_create_button_architecture", + callback_data: '@architectures' ) ); } - if ($cost > 0) { - // The project development cost was calculated + if ($hours > 0) { + // The project development hours was calculated - // Writing the project type button + // Writing the project architecture button $this->addButtonRow( button::make( text: "☑️ $localization->project_create_button_request", @@ -480,20 +491,20 @@ final class create extends menu } /** - * Types + * Architectures * - * Generate the project type select menu + * Generate the project architecture select menu * * @param telegram $robot The robot * * @return void */ - public function types(telegram $robot): void + public function architectures(telegram $robot): void { - // Initializing the language + // Initializing the account language $language = $robot->get('language') ?? LANGUAGE_DEFAULT; - // Initializing the menu message localization + // Initializing the account localization $localization = $robot->get('localization') ?? new localization($language); // Initializing the account @@ -504,8 +515,8 @@ final class create extends menu text: implode( "\n\n", [ - "⚙️ *$localization->project_create_types_title*", - $localization->project_create_types_description, + "⚙️ *$localization->project_create_architectures_title*", + $localization->project_create_architectures_description, ] ), opt: [ @@ -525,37 +536,37 @@ final class create extends menu // Initializing the maximum amount of buttons in a row $break = 4; - // Initializing buffer of types - $types = project_type::cases(); + // Initializing buffer of architectures + $architectures = project_architecture::cases(); - if (isset($this->type)) { - // Initialized the selected type + if (isset($this->architecture)) { + // Initialized the selected architecture // Initializing the selected purpose index - $selected = array_search($this->type ?? null, $types, strict: true); + $selected = array_search($this->architecture ?? null, $architectures, strict: true); if ($selected !== false) { - // Found the selected type index + // Found the selected architecture index - // Exclude the selected type from buffer of types - unset($types[$selected]); + // Exclude the selected architecture from buffer of architectures + unset($architectures[$selected]); } } // Declaring the generated buttons registry $generated = []; - foreach ($types as $index => $type) { - // Iterating over types + foreach ($architectures as $index => $architecture) { + // Iterating over architectures - if (array_search($type, $generated)) { - // The type button is already generated + if (array_search($architecture, $generated)) { + // The architecture button is already generated // Skipping the iteration continue; } - if ($length + $type->length() > $break && !empty($row)) { + if ($length + $architecture->length() > $break && !empty($row)) { // Reached the limit of buttons in a row // Writing the row into the menu @@ -573,19 +584,19 @@ final class create extends menu } // Addition to row buttons length - $length += $type->length(); + $length += $architecture->length(); - // Writing the type button into the row + // Writing the architecture button into the row $row[] = button::make( - text: $localization['project_type_' . $type->name] ?? $type->label(language: $language), - callback_data: "$type->name@type" + text: $localization['project_architecture_' . $architecture->name] ?? $architecture->label(language: $language), + callback_data: "$architecture->name@architecture" ); - // Initializing the next type - $next = $types[$index + 1] ?? null; + // Initializing the next architecture + $next = $architectures[$index + 1] ?? null; if ($next?->length() >= $break) { - // The next type is the full-length button + // The next architecture is the full-length button // Writing the row into the menu $this->addButtonRow(...$row); @@ -601,8 +612,8 @@ final class create extends menu // Writing the button into the menu $this->addButtonRow(button::make( - text: $localization['project_type_' . $next->name] ?? $next->label(language: $language), - callback_data: "$next->name@type" + text: $localization['project_architecture_' . $next->name] ?? $next->label(language: $language), + callback_data: "$next->name@architecture" )); // Writing the button into the generated buttons registry @@ -618,41 +629,62 @@ final class create extends menu } // Deinitializing deprecated variables - unset($row, $limit, $length, $generated, $types, $type); + unset($row, $limit, $length, $generated, $architectures, $architecture); // Updating the message and saving its text $this->text = $this->showMenu()->text; } /** - * Type + * architecture * - * Write the project type + * Write the project architecture * * @param telegram $robot The robot * * @return void */ - public function type(telegram $robot): void + public function architecture(telegram $robot): void { - // Initializing the project type - $this->type = project_type::{$robot->callbackQuery()->data}; + // Initializing the language + $language = $robot->get('language') ?? LANGUAGE_DEFAULT; - // Deinitializing the project purpose - unset($this->purpose); + // Initializing the account localization + $localization = $robot->get('localization') ?? new localization($language); - if (count($this->type->purposes()) === 1) { - // The project type has only 1 purpose + // Initializing the project architecture + $this->architecture = project_architecture::{$robot->callbackQuery()->data}; + + // Initializing the project architecture purposes + $purposes = $this->architecture->purposes(); + + if (count($purposes) === 1) { + // The project architecture has only 1 purpose // Initializing the project purpose - $this->purpose = $this->type->purposes()[0]; + $this->purpose = $purposes[0]; + } else if (isset($this->purpose) && array_search($this->purpose, $purposes) !== false) { + // The project architrcture purpose is the same from deprecated purpose + + // keep it + } else { + // + + // Deinitializing the project purpose + unset($this->purpose); } + // Sending the popup notification + $robot->answerCallbackQuery( + text: $localization['project_architecture_' . $this->architecture?->name] ?? $this->architecture?->label(language: $language), + show_alert: false + ); + // Deleting the message buttons $this->clearButtons(); // Deleting the message buttons - $this->start(robot: $robot); + $this->start(robot: $robot, new: false); } /** @@ -666,10 +698,10 @@ final class create extends menu */ public function purposes(telegram $robot): void { - // Initializing the language + // Initializing the account language $language = $robot->get('language') ?? LANGUAGE_DEFAULT; - // Initializing the menu message localization + // Initializing the account localization $localization = $robot->get('localization') ?? new localization($language); // Initializing the account @@ -702,7 +734,7 @@ final class create extends menu $break = 4; // Initializing buffer of purposes - $purposes = $this->type->purposes(); + $purposes = $this->architecture->purposes(); if (isset($this->purpose)) { // Initialized the selected purpose @@ -826,44 +858,65 @@ final class create extends menu */ public function purpose(telegram $robot): void { + // Initializing the account language + $language = $robot->get('language') ?? LANGUAGE_DEFAULT; + + // Initializing the account localization + $localization = $robot->get('localization') ?? new localization($language); + // Initializing the project purpose $this->purpose = project_purpose::{$robot->callbackQuery()->data}; + // Sending the popup notification + $robot->answerCallbackQuery( + text: $localization['project_purpose_' . $this->purpose?->name] ?? $this->purpose?->label(language: $language), + show_alert: false + ); + // Deleting the message buttons $this->clearButtons(); // Deleting the message buttons - $this->start(robot: $robot); + $this->start(robot: $robot, new: false); } /** - * Cost + * Hours * - * Calculate the project development cost + * Calculate the project development hours * - * @return int|float The project development cost + * @return int|float The project development hours */ - public function cost(): int|float - { - // Declaring the project development cost - $cost = 0; + public function hours(): int|float + { // Declaring coefficient + $coefficient = PROJECT_CREATE_START_COEFFICIENT ?? 0; - if (isset($this->type)) { - // Initialized the project type + if (isset($this->architecture)) { + // Initialized the project architecture - // Calculating the project development cost - $cost = $this->type->cost(); + // Adding into the coefficient + $coefficient += $this->architecture->coefficient(); } if (isset($this->purpose)) { // Initialized the project purpose - // Calculating the project development cost - $cost *= $this->purpose->coefficient(); + // Adding into the coefficient + $coefficient += $this->purpose->coefficient(); } - // Exit (success) - return $cost; + // Initializing start hours + $start = PROJECT_CREATE_START_HOURS ?? 1; + $start < 1 and $start = 1; + + // Initializing additional hours + $additional = PROJECT_CREATE_HOURS_ADDITIONAL ?? 0; + + // Calculating the development hours + $hours = $start * $coefficient + $additional; + + // Calculating and exit (success) + return ceil(max($hours, PROJECT_CREATE_HOURS_MINIMAL)); } /** @@ -877,10 +930,10 @@ final class create extends menu */ public function request(telegram $robot): void { - // Initializing the language + // Initializing the account language $language = $robot->get('language') ?? LANGUAGE_DEFAULT; - // Initializing the menu message localization + // Initializing the account localization $localization = $robot->get('localization') ?? new localization($language); // Sending the message @@ -890,7 +943,7 @@ final class create extends menu disable_notification: true ); - // Stopping conversation + // Ending the conversation $this->end(); } @@ -905,10 +958,10 @@ final class create extends menu */ public function stop(telegram $robot): void { - // Initializing the language + // Initializing the account language $language = $robot->get('language') ?? LANGUAGE_DEFAULT; - // Initializing the menu message localization + // Initializing the account localization $localization = $robot->get('localization') ?? new localization($language); // Sending the message @@ -918,7 +971,7 @@ final class create extends menu disable_notification: true ); - // Stopping conversation + // Ending the conversation $this->end(); } } diff --git a/kodorvan/constructor/system/models/telegram/middlewares/account.php b/kodorvan/constructor/system/models/telegram/middlewares/account.php index 124e5d1..1fcd09f 100644 --- a/kodorvan/constructor/system/models/telegram/middlewares/account.php +++ b/kodorvan/constructor/system/models/telegram/middlewares/account.php @@ -5,8 +5,7 @@ declare(strict_types=1); namespace kodorvan\constructor\models\telegram\middlewares; // Files of the project -use kodorvan\constructor\models\core, - kodorvan\constructor\models\account as model, +use kodorvan\constructor\models\account as model, kodorvan\constructor\models\authorizations; // The library for languages support @@ -30,7 +29,7 @@ use Error as error; * @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License * @author Arsen Mirzaev Tatyano-Muradovich */ -final class account extends core +final class account { /** * Account diff --git a/kodorvan/constructor/system/models/telegram/middlewares/authorizations.php b/kodorvan/constructor/system/models/telegram/middlewares/authorizations.php index 4fd3998..19bca2e 100644 --- a/kodorvan/constructor/system/models/telegram/middlewares/authorizations.php +++ b/kodorvan/constructor/system/models/telegram/middlewares/authorizations.php @@ -5,8 +5,7 @@ declare(strict_types=1); namespace kodorvan\constructor\models\telegram\middlewares; // Files of the project -use kodorvan\constructor\models\core, - kodorvan\constructor\models\account, +use kodorvan\constructor\models\account, kodorvan\constructor\models\authorizations as model; // The library for languages support @@ -30,7 +29,7 @@ use Error as error; * @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License * @author Arsen Mirzaev Tatyano-Muradovich */ -final class authorizations extends core +final class authorizations { /** * Authorizations diff --git a/kodorvan/constructor/system/models/telegram/middlewares/language.php b/kodorvan/constructor/system/models/telegram/middlewares/language.php index c61ebeb..68b6c89 100644 --- a/kodorvan/constructor/system/models/telegram/middlewares/language.php +++ b/kodorvan/constructor/system/models/telegram/middlewares/language.php @@ -5,8 +5,7 @@ declare(strict_types=1); namespace kodorvan\constructor\models\telegram\middlewares; // Files of the project -use kodorvan\constructor\models\core, - kodorvan\constructor\models\account, +use kodorvan\constructor\models\account, kodorvan\constructor\models\authorizations; // The library for languages support @@ -30,7 +29,7 @@ use Error as error; * @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License * @author Arsen Mirzaev Tatyano-Muradovich */ -final class language extends core +final class language { /** * Language diff --git a/kodorvan/constructor/system/models/telegram/middlewares/localization.php b/kodorvan/constructor/system/models/telegram/middlewares/localization.php index eb6b653..e51cd55 100644 --- a/kodorvan/constructor/system/models/telegram/middlewares/localization.php +++ b/kodorvan/constructor/system/models/telegram/middlewares/localization.php @@ -5,8 +5,7 @@ declare(strict_types=1); namespace kodorvan\constructor\models\telegram\middlewares; // Files of the project -use kodorvan\constructor\models\core, - kodorvan\constructor\models\account, +use kodorvan\constructor\models\account, kodorvan\constructor\models\localization as model, kodorvan\constructor\models\authorizations; @@ -32,7 +31,7 @@ use Exception as exception, * @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License * @author Arsen Mirzaev Tatyano-Muradovich */ -final class localization extends core +final class localization { /** * Localization diff --git a/kodorvan/constructor/system/models/telegram/middlewares/settings.php b/kodorvan/constructor/system/models/telegram/middlewares/settings.php index 6ebeee7..d4b8e30 100644 --- a/kodorvan/constructor/system/models/telegram/middlewares/settings.php +++ b/kodorvan/constructor/system/models/telegram/middlewares/settings.php @@ -5,8 +5,7 @@ declare(strict_types=1); namespace kodorvan\constructor\models\telegram\middlewares; // Files of the project -use kodorvan\constructor\models\core, - kodorvan\constructor\models\account, +use kodorvan\constructor\models\account, kodorvan\constructor\models\authorizations; // The library for languages support @@ -30,7 +29,7 @@ use Error as error; * @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License * @author Arsen Mirzaev Tatyano-Muradovich */ -final class settings extends core +final class settings { /** * Settings @@ -75,7 +74,7 @@ final class settings extends core // Sending the message $robot->sendMessage( - text: '⛔ *' . $localization['not_authorized_settings'] . '*', + text: "⛔ *$localization->not_authorized_settings*", parse_mode: mode::MARKDOWN ); diff --git a/kodorvan/constructor/system/models/telegram/middlewares/system/settings.php b/kodorvan/constructor/system/models/telegram/middlewares/system/settings.php index 8a6169f..2aa1ca7 100644 --- a/kodorvan/constructor/system/models/telegram/middlewares/system/settings.php +++ b/kodorvan/constructor/system/models/telegram/middlewares/system/settings.php @@ -5,8 +5,7 @@ declare(strict_types=1); namespace kodorvan\constructor\models\telegram\middlewares\system; // Files of the project -use kodorvan\constructor\models\core, - kodorvan\constructor\models\account, +use kodorvan\constructor\models\account, kodorvan\constructor\models\authorizations; // The library for languages support @@ -23,14 +22,14 @@ use SergiX44\Nutgram\Nutgram as telegram, use Error as error; /** - * Telegram middleware: language + * Telegram middleware: system settings * * @package kodorvan\constructor\models\telegram\middlewares\system * * @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License * @author Arsen Mirzaev Tatyano-Muradovich */ -final class settings extends core +final class settings { /** * System settings (middleware) diff --git a/kodorvan/constructor/system/public/telegram.php b/kodorvan/constructor/system/public/telegram.php deleted file mode 100644 index 65fd5d1..0000000 --- a/kodorvan/constructor/system/public/telegram.php +++ /dev/null @@ -1,109 +0,0 @@ - [ - 'constructor' => [ - 'token' => TELEGRAM['constructor']['key'], - 'certificate_path' => PROJECT_CERTIFICATE, - 'webhook_url' => 'https://' . PROJECT_DOMAIN . '/telegram/constructor.php', - 'commands' => [ - start::class, - ] - ], - 'async_requests' => true, - 'base_bot_url' => 'https://' . PROJECT_DOMAIN . '/telegram', - ] -]; - -// Initializing the robots manager -$robot = new telegram($settings); - -var_dump($telegram->bot('constructor')->getWebhookUpdate()); - -/* // Initializing the updates listener -$robot->onUpdate(function (context $context): void {}); - -// Initializing the robot middlewares -$robot->middleware([middlewares::class, 'account']); -$robot->middleware([middlewares::class, 'language']); -$robot->middleware([middlewares::class, 'localization']); -$robot->middleware([middlewares::class, 'authorizations']); - -// Initializing the robot commands handlers -$robot->onCommand('start', [commands::class, 'start']); - -$robot->onCommand('start telegram voronka', [commands::class, 'start']); -$robot->onCommand('start parser', [commands::class, 'start']); -$robot->onCommand('start calculator', [commands::class, 'start']); - -$robot->onCommand('language', [commands::class, 'language'])->middleware([middlewares::class, 'settings']); -$robot->onCommand('society', [commands::class, 'society']); - -// Initializing the robot settings language buttons handlers -foreach (language::cases() as $language) { - // Iterating over languages - - // Initializing language buttons - $robot->onCbQueryData(["settings_language_$language->name"], fn(context $context) => settings::language($context, $language)); -}; - -$robot->onCbQueryData('project_create', ['process_project_create', 'name']); - -// Starting chat-robot -$robot->run(); */ diff --git a/kodorvan/constructor/system/public/telegram/constructor/install.php b/kodorvan/constructor/system/public/telegram/constructor/install.php index 4595d18..0f2f6c4 100644 --- a/kodorvan/constructor/system/public/telegram/constructor/install.php +++ b/kodorvan/constructor/system/public/telegram/constructor/install.php @@ -60,9 +60,9 @@ require ROOT . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'; // Initializing the robot $robot = new telegram( - token: TELEGRAM['constructor']['key'], + token: TELEGRAM['key'], config: new telegram_settings( - botName: TELEGRAM['constructor']['name'] + botName: TELEGRAM['name'] ) ); @@ -72,5 +72,5 @@ $robot->setWebhook( ip_address: SERVER_IP_ADDRESS, max_connections: 10, drop_pending_updates: false, - secret_token: 'bebra228' + secret_token: TELEGRAM['password'] ); diff --git a/kodorvan/constructor/system/public/telegram/constructor/webhook.php b/kodorvan/constructor/system/public/telegram/constructor/webhook.php index f920a5f..6cb6868 100644 --- a/kodorvan/constructor/system/public/telegram/constructor/webhook.php +++ b/kodorvan/constructor/system/public/telegram/constructor/webhook.php @@ -71,14 +71,14 @@ require ROOT . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'; // Initializing the robot $robot = new telegram( - token: TELEGRAM['constructor']['key'], + token: TELEGRAM['key'], config: new telegram_settings( - botName: TELEGRAM['constructor']['name'], + botName: TELEGRAM['name'], cache: new cache(new cache_adapter()) ) ); -$webhook = new webhook(secretToken: 'bebra228'); +$webhook = new webhook(secretToken: TELEGRAM['password']); $webhook->setSafeMode(true); $robot->setRunningMode($webhook); @@ -88,7 +88,6 @@ $robot->middleware(middleware_language::class); $robot->middleware(middleware_localization::class); $robot->middleware(middleware_authorizations::class); - // Start $robot->registerCommand(command_start::class); $robot->onCommand('start telegram voronka', command_start::class); diff --git a/kodorvan/constructor/system/settings/.gitignore b/kodorvan/constructor/system/settings/.gitignore index 2027072..05708aa 100644 --- a/kodorvan/constructor/system/settings/.gitignore +++ b/kodorvan/constructor/system/settings/.gitignore @@ -1,3 +1,5 @@ * !.gitignore !*.sample +!*/ +!*.md diff --git a/kodorvan/constructor/system/settings/certificate/README.md b/kodorvan/constructor/system/settings/certificate/README.md new file mode 100644 index 0000000..626e4a2 --- /dev/null +++ b/kodorvan/constructor/system/settings/certificate/README.md @@ -0,0 +1 @@ +openssl req -newkey rsa:2048 -sha256 -nodes -keyout private.key -x509 -days 365 -out public.pem -subj "/C=US/ST=New York/L=Brooklyn/O=Example Brooklyn Company/CN=Sex" diff --git a/kodorvan/constructor/system/settings/system.php.sample b/kodorvan/constructor/system/settings/system.php.sample index 8249c4d..ed18a15 100644 --- a/kodorvan/constructor/system/settings/system.php.sample +++ b/kodorvan/constructor/system/settings/system.php.sample @@ -21,9 +21,18 @@ define('PROJECT_MEDIA_URL', 'https://t.me/kodorvan'); define('PROJECT_OPERATOR_URL', 'https://t.me/kodorvan?direct'); define('PROJECT_REPOSITORY', REPOSITORY . '/' . PROJECT_CREATOR . '/' . PROJECT_NAME); define('PROJECT_REPOSITORY_LANGUAGE_ADD', PROJECT_REPOSITORY . '/src/branch/stable/' . PROJECT_CREATOR . '/' . PROJECT_NAME . '/system/localizations'); -/* define('PROJECT_CERTIFICATE', SETTINGS . DIRECTORY_SEPARATOR . 'cert.pem'); */ -define('CURRENCY_DEFAULT', currency::usd); +define('PROJECT_CREATE_START_HOURS', 1); +define('PROJECT_CREATE_START_COEFFICIENT', 0); +define('PROJECT_CREATE_HOURS_ADDITIONAL', 0); +define('PROJECT_CREATE_HOURS_MINIMAL', 4); +define('PROJECT_CREATE_COST_HOUR_DEFAULT', 1200); + +define('PROJECT_CREATE_REQUEST_CHATS', [ + +]); + +define('CURRENCY_DEFAULT', currency::rub); define('LANGUAGE_DEFAULT', language::en); // Initializing default theme for the views templater diff --git a/kodorvan/constructor/system/settings/telegram.php.sample b/kodorvan/constructor/system/settings/telegram.php.sample index 5b0515b..829df2a 100644 --- a/kodorvan/constructor/system/settings/telegram.php.sample +++ b/kodorvan/constructor/system/settings/telegram.php.sample @@ -2,18 +2,17 @@ // Telegram API chat-robot return [ - 'constructor' => [ - 'identifier' => 0, - 'name' => 'kodorvan', - 'domain' => '', - 'key' => '', - 'database' => [ - 'host' => '/run/mysqld/mysqld.sock', - 'port' => 3306, - 'user' => '', - 'password' => '', - 'database' => '', - ] + 'identifier' => 0, + 'domain' => 'kodorvan_bot', + 'name' => 'kodorvan', + 'password' => '', + 'key' => '', + 'database' => [ + 'host' => '/run/mysqld/mysqld.sock', + 'port' => 3306, + 'user' => '', + 'password' => '', + 'database' => '', ] ];