generated from mirzaev/pot-php-telegram
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 74d2eaa62b | |||
| 0692db9c80 |
@@ -29,6 +29,7 @@ return [
|
|||||||
'project_create_time' => 'Время разработки',
|
'project_create_time' => 'Время разработки',
|
||||||
'project_create_time_hours' => 'ч',
|
'project_create_time_hours' => 'ч',
|
||||||
'project_create_time_hours_from' => 'от',
|
'project_create_time_hours_from' => 'от',
|
||||||
|
'project_create_button_back' => 'Назад',
|
||||||
'project_create_button_request' => 'Заказать',
|
'project_create_button_request' => 'Заказать',
|
||||||
|
|
||||||
'project_create_architectures_title' => 'Выбор архитектуры проекта',
|
'project_create_architectures_title' => 'Выбор архитектуры проекта',
|
||||||
@@ -42,13 +43,25 @@ return [
|
|||||||
'project_create_button_purpose_selected' => 'Назнач.',
|
'project_create_button_purpose_selected' => 'Назнач.',
|
||||||
|
|
||||||
'project_create_integrations_title' => 'Выбор интеграций',
|
'project_create_integrations_title' => 'Выбор интеграций',
|
||||||
'project_create_integrations_description' => 'Синхронизация, скачивание, загрузка, запись...',
|
'project_create_integrations_description' => "Синхронизация данных в реальном времени, скачивание, загрузка, перенос информации, админ\-панель, рассылка сообщений, подключение аккаунтов\.\.\.\n\n_Отправка запросов в *API*, генерация и перехват *HTTP\-сообщений*, *эмуляция* действий пользователя через *виртуальный браузер* с курсором мыши и клавиатурой, либо *нестандартные протоколы связи*_",
|
||||||
'project_create_button_integrations' => 'Интеграции',
|
'project_create_button_integrations' => 'Интеграции',
|
||||||
'project_create_button_integrations_selected' => 'Интеграции',
|
'project_create_button_integrations_selected' => 'Интеграции',
|
||||||
|
|
||||||
'project_create_requested' => 'Проект создан и отправлен оператору',
|
'project_create_requested' => 'Проект создан и отправлен оператору',
|
||||||
'project_create_cancelled' => 'Создание проекта отменено',
|
'project_create_cancelled' => 'Создание проекта отменено',
|
||||||
|
|
||||||
|
'project_request_title' => 'Заказ #%d',
|
||||||
|
'project_request_architecture' => 'Архитектура',
|
||||||
|
'project_request_purpose' => 'Назначение',
|
||||||
|
'project_request_hours' => 'Часы',
|
||||||
|
'project_request_cost' => 'Стоимость',
|
||||||
|
'project_request_command' => 'Команда',
|
||||||
|
'project_request_empty' => 'Пусто',
|
||||||
|
'project_request_button_accept' => 'Принять',
|
||||||
|
'project_request_button_refuse' => 'Отказать',
|
||||||
|
'project_request_button_edit' => 'Редактировать',
|
||||||
|
'project_request_button_chat' => 'Чат с заказчиком',
|
||||||
|
|
||||||
// Проект: типы
|
// Проект: типы
|
||||||
'project_architecture_chat_robot' => 'Чат-робот',
|
'project_architecture_chat_robot' => 'Чат-робот',
|
||||||
'project_architecture_parser' => 'Парсер',
|
'project_architecture_parser' => 'Парсер',
|
||||||
@@ -68,13 +81,22 @@ return [
|
|||||||
'project_purpose_marketplace' => 'Маркетплейс',
|
'project_purpose_marketplace' => 'Маркетплейс',
|
||||||
'project_purpose_charity' => 'Благотворительность',
|
'project_purpose_charity' => 'Благотворительность',
|
||||||
'project_purpose_search' => 'Поиск',
|
'project_purpose_search' => 'Поиск',
|
||||||
'project_purpose_calculate' => 'Расчёт',
|
'project_purpose_calcul+ate' => 'Расчёт',
|
||||||
'project_purpose_tools' => 'Инструменты',
|
'project_purpose_tools' => 'Инструменты',
|
||||||
'project_purpose_workers' => 'Рабочие',
|
'project_purpose_workers' => 'Рабочие',
|
||||||
'project_purpose_objects' => 'Предметы',
|
'project_purpose_objects' => 'Предметы',
|
||||||
'project_purpose_events' => 'События',
|
'project_purpose_events' => 'События',
|
||||||
'project_purpose_special' => 'Особенный',
|
'project_purpose_special' => 'Особенный',
|
||||||
|
|
||||||
|
// Проект: интеграции
|
||||||
|
'project_integration_one_c' => '1C',
|
||||||
|
'project_integration_bitrix24' => 'Битрикс 24',
|
||||||
|
'project_integration_moy_sklad' => 'Мой Склад',
|
||||||
|
'project_integration_telegram' => 'Телеграм',
|
||||||
|
'project_integration_mail' => 'Почта',
|
||||||
|
'project_integration_excel' => 'Excel',
|
||||||
|
/* 'project_integration_' => '', */
|
||||||
|
|
||||||
// Настройки: язык
|
// Настройки: язык
|
||||||
'settings_language_title' => 'Выбери язык',
|
'settings_language_title' => 'Выбери язык',
|
||||||
'settings_language_description' => 'Выбранный язык будет использоваться для генерации системного отображения',
|
'settings_language_description' => 'Выбранный язык будет использоваться для генерации системного отображения',
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ declare(strict_types=1);
|
|||||||
namespace kodorvan\constructor\models\project\enumerations;
|
namespace kodorvan\constructor\models\project\enumerations;
|
||||||
|
|
||||||
// Files of the project
|
// Files of the project
|
||||||
use kodorvan\constructor\models\project\enumerations\purpose;
|
use kodorvan\constructor\models\project\enumerations\purpose,
|
||||||
|
kodorvan\constructor\models\project\enumerations\integration;
|
||||||
|
|
||||||
// The library for languages support
|
// The library for languages support
|
||||||
use mirzaev\languages\language;
|
use mirzaev\languages\language;
|
||||||
@@ -33,7 +34,7 @@ enum architecture
|
|||||||
case crm;
|
case crm;
|
||||||
case site;
|
case site;
|
||||||
case program;
|
case program;
|
||||||
/* case calculator; */
|
/* case calculator; */
|
||||||
|
|
||||||
case complex;
|
case complex;
|
||||||
|
|
||||||
@@ -105,6 +106,13 @@ enum architecture
|
|||||||
*/
|
*/
|
||||||
public function purposes(): array
|
public function purposes(): array
|
||||||
{
|
{
|
||||||
|
// Initializing purposes
|
||||||
|
$purposes = purpose::cases();
|
||||||
|
|
||||||
|
// Deleting the special purpose
|
||||||
|
$indexes = array_keys($purposes, purpose::special);
|
||||||
|
foreach ($indexes as $index) unset($purposes[$index]);
|
||||||
|
|
||||||
// Exit (success)
|
// Exit (success)
|
||||||
return match ($this) {
|
return match ($this) {
|
||||||
static::chat_robot => [
|
static::chat_robot => [
|
||||||
@@ -162,6 +170,44 @@ enum architecture
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Integrations
|
||||||
|
*
|
||||||
|
* @return array Integrations
|
||||||
|
*/
|
||||||
|
/* public function integrations(): array
|
||||||
|
{
|
||||||
|
// Exit (success)
|
||||||
|
return match ($this) {
|
||||||
|
static::chat_robot => [
|
||||||
|
integration::one_c,
|
||||||
|
integration::moy_sklad
|
||||||
|
],
|
||||||
|
static::parser => [
|
||||||
|
integration::one_c,
|
||||||
|
integration::moy_sklad
|
||||||
|
],
|
||||||
|
static::script => [],
|
||||||
|
static::crm => [
|
||||||
|
integration::one_c,
|
||||||
|
integration::moy_sklad
|
||||||
|
],
|
||||||
|
static::site => [
|
||||||
|
integration::one_c,
|
||||||
|
integration::moy_sklad
|
||||||
|
],
|
||||||
|
static::program => [
|
||||||
|
integration::one_c,
|
||||||
|
integration::moy_sklad
|
||||||
|
],
|
||||||
|
static::complex => [
|
||||||
|
integration::one_c,
|
||||||
|
integration::moy_sklad
|
||||||
|
],
|
||||||
|
default => []
|
||||||
|
};
|
||||||
|
} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cost
|
* Cost
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -0,0 +1,99 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace kodorvan\constructor\models\project\enumerations;
|
||||||
|
|
||||||
|
// The library for languages support
|
||||||
|
use mirzaev\languages\language;
|
||||||
|
|
||||||
|
// Built-in libraries
|
||||||
|
use InvalidArgumentException as exception_argument,
|
||||||
|
DomainException as exception_domain;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Integration
|
||||||
|
*
|
||||||
|
* @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 <arsen@mirzaev.sexy>
|
||||||
|
*/
|
||||||
|
enum integration
|
||||||
|
{
|
||||||
|
case one_c;
|
||||||
|
case bitrix24;
|
||||||
|
case moy_sklad;
|
||||||
|
case telegram;
|
||||||
|
case mail;
|
||||||
|
case excel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Label
|
||||||
|
*
|
||||||
|
* @param language $language The language
|
||||||
|
*
|
||||||
|
* @return string The project form label
|
||||||
|
*/
|
||||||
|
public function label(language $language = LANGUAGE_DEFAULT): string
|
||||||
|
{
|
||||||
|
// Exit (success)
|
||||||
|
return match ($this) {
|
||||||
|
static::one_c => '1C',
|
||||||
|
static::bitrix24 => match ($language) {
|
||||||
|
language::en => 'Bitrix 24',
|
||||||
|
language::ru => 'Битрикс 24'
|
||||||
|
},
|
||||||
|
static::moy_sklad => match ($language) {
|
||||||
|
language::en => 'Moy Sklad',
|
||||||
|
language::ru => 'Мой Склад'
|
||||||
|
},
|
||||||
|
static::telegram => match ($language) {
|
||||||
|
language::en => 'Telegram',
|
||||||
|
language::ru => 'Телеграм'
|
||||||
|
},
|
||||||
|
static::mail => match ($language) {
|
||||||
|
language::en => 'Mail',
|
||||||
|
language::ru => 'Почта'
|
||||||
|
},
|
||||||
|
static::excel => 'Excel'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Length
|
||||||
|
*
|
||||||
|
* @return int Amount of buttons cells length
|
||||||
|
*/
|
||||||
|
public function length(): int
|
||||||
|
{
|
||||||
|
// Exit (success)
|
||||||
|
return match ($this) {
|
||||||
|
static::one_c => 1,
|
||||||
|
static::bitrix24 => 2,
|
||||||
|
static::moy_sklad => 2,
|
||||||
|
static::telegram => 2,
|
||||||
|
static::mail => 1,
|
||||||
|
static::excel => 1,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Coefficient
|
||||||
|
*
|
||||||
|
* @return int|float Coefficient to the project development hours
|
||||||
|
*/
|
||||||
|
public function coefficient(): int|float
|
||||||
|
{
|
||||||
|
// Exit (success)
|
||||||
|
return match ($this) {
|
||||||
|
static::one_c => 5,
|
||||||
|
static::bitrix24 => 3.5,
|
||||||
|
static::moy_sklad => 3,
|
||||||
|
static::telegram => 2,
|
||||||
|
static::mail => 1.2,
|
||||||
|
static::excel => 1.5,
|
||||||
|
default => 2
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -126,6 +126,85 @@ enum purpose
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Integrations
|
||||||
|
*
|
||||||
|
* @return array Integrations
|
||||||
|
*/
|
||||||
|
public function integrations(): array
|
||||||
|
{
|
||||||
|
// Exit (success)
|
||||||
|
return match ($this) {
|
||||||
|
static::funnel => [
|
||||||
|
integration::telegram,
|
||||||
|
integration::mail,
|
||||||
|
integration::bitrix24
|
||||||
|
],
|
||||||
|
static::contact => [
|
||||||
|
integration::mail,
|
||||||
|
integration::bitrix24
|
||||||
|
],
|
||||||
|
static::neural_network => [
|
||||||
|
integration::telegram
|
||||||
|
],
|
||||||
|
static::game => [
|
||||||
|
integration::telegram
|
||||||
|
],
|
||||||
|
static::gallery => [],
|
||||||
|
static::crm => [
|
||||||
|
integration::one_c,
|
||||||
|
integration::moy_sklad,
|
||||||
|
integration::excel
|
||||||
|
],
|
||||||
|
static::landing => [
|
||||||
|
integration::telegram
|
||||||
|
],
|
||||||
|
static::marketplace => [
|
||||||
|
integration::one_c,
|
||||||
|
integration::moy_sklad,
|
||||||
|
integration::excel
|
||||||
|
],
|
||||||
|
static::charity => [
|
||||||
|
integration::one_c,
|
||||||
|
integration::moy_sklad,
|
||||||
|
integration::excel
|
||||||
|
],
|
||||||
|
static::search => [],
|
||||||
|
static::calculate => [
|
||||||
|
integration::one_c,
|
||||||
|
integration::moy_sklad,
|
||||||
|
integration::excel
|
||||||
|
],
|
||||||
|
static::logic => [],
|
||||||
|
static::tools => [
|
||||||
|
integration::one_c,
|
||||||
|
integration::moy_sklad,
|
||||||
|
integration::excel
|
||||||
|
],
|
||||||
|
static::workers => [
|
||||||
|
integration::one_c,
|
||||||
|
integration::moy_sklad,
|
||||||
|
integration::excel
|
||||||
|
],
|
||||||
|
static::objects => [
|
||||||
|
integration::one_c,
|
||||||
|
integration::moy_sklad,
|
||||||
|
integration::excel
|
||||||
|
],
|
||||||
|
static::events => [
|
||||||
|
integration::one_c,
|
||||||
|
integration::moy_sklad,
|
||||||
|
integration::excel
|
||||||
|
],
|
||||||
|
static::special => [
|
||||||
|
integration::one_c,
|
||||||
|
integration::moy_sklad,
|
||||||
|
integration::excel
|
||||||
|
],
|
||||||
|
default => []
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Length
|
* Length
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ use kodorvan\constructor\models\core,
|
|||||||
kodorvan\constructor\models\settings,
|
kodorvan\constructor\models\settings,
|
||||||
kodorvan\constructor\models\project\enumerations\architecture as project_architecture,
|
kodorvan\constructor\models\project\enumerations\architecture as project_architecture,
|
||||||
kodorvan\constructor\models\project\enumerations\purpose as project_purpose,
|
kodorvan\constructor\models\project\enumerations\purpose as project_purpose,
|
||||||
|
kodorvan\constructor\models\project\enumerations\integration as project_integration,
|
||||||
kodorvan\constructor\models\telegram\processes\language\select as process_language_select;
|
kodorvan\constructor\models\telegram\processes\language\select as process_language_select;
|
||||||
|
|
||||||
// Library for languages support
|
// Library for languages support
|
||||||
@@ -63,6 +64,13 @@ final class create extends menu
|
|||||||
*/
|
*/
|
||||||
public project_purpose $purpose;
|
public project_purpose $purpose;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Integrations
|
||||||
|
*
|
||||||
|
* @var array $integrations The project integrations
|
||||||
|
*/
|
||||||
|
public array $integrations = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start
|
* Start
|
||||||
*
|
*
|
||||||
@@ -82,6 +90,9 @@ final class create extends menu
|
|||||||
$robot->endConversation();
|
$robot->endConversation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deleting the message buttons
|
||||||
|
$this->clearButtons();
|
||||||
|
|
||||||
// Initializing the account language
|
// Initializing the account language
|
||||||
$language = $robot->get('language') ?? LANGUAGE_DEFAULT;
|
$language = $robot->get('language') ?? LANGUAGE_DEFAULT;
|
||||||
|
|
||||||
@@ -100,9 +111,9 @@ final class create extends menu
|
|||||||
[
|
[
|
||||||
"🏛 *$localization->project_create_title*",
|
"🏛 *$localization->project_create_title*",
|
||||||
/* $hours > 0 ? "*$localization->project_create_time* " . unmarkdown((string) $hours) . " $localization->hours" : $localization->project_create_description */
|
/* $hours > 0 ? "*$localization->project_create_time* " . unmarkdown((string) $hours) . " $localization->hours" : $localization->project_create_description */
|
||||||
$hours > 0
|
$new
|
||||||
? "*$localization->project_create_time:* $hours$localization->project_create_time_hours"
|
? $localization->project_create_description
|
||||||
: $localization->project_create_description,
|
: "*$localization->project_create_time:* $hours$localization->project_create_time_hours"
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -115,6 +126,12 @@ final class create extends menu
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Initializing the row
|
||||||
|
$row = [];
|
||||||
|
|
||||||
|
// Initializing the maximum amount of buttons in a row
|
||||||
|
$break = 3;
|
||||||
|
|
||||||
if (isset($this->architecture)) {
|
if (isset($this->architecture)) {
|
||||||
// Initialized the project architecture
|
// Initialized the project architecture
|
||||||
|
|
||||||
@@ -127,7 +144,7 @@ final class create extends menu
|
|||||||
callback_data: '@architectures'
|
callback_data: '@architectures'
|
||||||
);
|
);
|
||||||
|
|
||||||
if (isset($this->purpose) || $this->architecture === project_architecture::complex) {
|
if (isset($this->purpose)) {
|
||||||
// Initialized the project purpose
|
// Initialized the project purpose
|
||||||
|
|
||||||
// Writing the project purpose button into the buffer of the first row
|
// Writing the project purpose button into the buffer of the first row
|
||||||
@@ -139,29 +156,41 @@ final class create extends menu
|
|||||||
// Writing the project buttons first row
|
// Writing the project buttons first row
|
||||||
$this->addButtonRow(...$first);
|
$this->addButtonRow(...$first);
|
||||||
|
|
||||||
// Initializing the row
|
// Initializing the project integrations
|
||||||
$row = [];
|
$integrations = $this->purpose->integrations();
|
||||||
|
|
||||||
// Initializing the maximum amount of buttons in a row
|
if (!empty($integrations)) {
|
||||||
$break = 2;
|
|
||||||
|
|
||||||
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
|
// Integrations
|
||||||
|
|
||||||
if (isset($this->integrations)) {
|
// Initializing the button text
|
||||||
// Initialized the project integrations
|
$text = unmarkdown(
|
||||||
|
trim(
|
||||||
|
implode(
|
||||||
|
', ',
|
||||||
|
array_map(
|
||||||
|
fn(project_integration $integration) => $localization['project_integration_' . $integration?->name] ?? $integration?->label($language) ?? '',
|
||||||
|
$this->integrations,
|
||||||
|
)
|
||||||
|
),
|
||||||
|
' '
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
} else {
|
// Writing the project integrations button into the buffer of the first row
|
||||||
// Not initialized the project integrations
|
$row[] = button::make(
|
||||||
|
text: empty($text) ? $localization->project_create_button_integrations : $text,
|
||||||
|
callback_data: '@integrations'
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
if (count($row) >= $break) {
|
||||||
|
// The buttons row reach the limit
|
||||||
|
|
||||||
|
// Writing the buttons row
|
||||||
|
$this->addButtonRow(...$row);
|
||||||
|
|
||||||
|
// Deinitializing the buttons row
|
||||||
|
$row = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -474,7 +503,17 @@ final class create extends menu
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($hours > 0) {
|
if (!empty($row)) {
|
||||||
|
// The buttons row has buttons
|
||||||
|
|
||||||
|
// Writing the buttons row
|
||||||
|
$this->addButtonRow(...$row);
|
||||||
|
|
||||||
|
// Deinitializing the buttons row
|
||||||
|
$row = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$new) {
|
||||||
// The project development hours was calculated
|
// The project development hours was calculated
|
||||||
|
|
||||||
// Writing the project architecture button
|
// Writing the project architecture button
|
||||||
@@ -490,6 +529,22 @@ final class create extends menu
|
|||||||
$this->text = $this->orNext('stop')->showMenu()->text;
|
$this->text = $this->orNext('stop')->showMenu()->text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Continue
|
||||||
|
*
|
||||||
|
* Generate the project create menu and continue the process
|
||||||
|
*
|
||||||
|
* @param telegram $robot The robot
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function continue(telegram $robot): void
|
||||||
|
{
|
||||||
|
// Continuing the process
|
||||||
|
$this->start(robot: $robot, new: false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Architectures
|
* Architectures
|
||||||
*
|
*
|
||||||
@@ -576,7 +631,6 @@ final class create extends menu
|
|||||||
$generated += $row;
|
$generated += $row;
|
||||||
|
|
||||||
// Reinitializing the row buttons length
|
// Reinitializing the row buttons length
|
||||||
/* $length -= $break; */
|
|
||||||
$length = 0;
|
$length = 0;
|
||||||
|
|
||||||
// Reinitializing the row
|
// Reinitializing the row
|
||||||
@@ -621,7 +675,7 @@ final class create extends menu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($row) > 0) {
|
if (!empty($row)) {
|
||||||
// The row was not writed
|
// The row was not writed
|
||||||
|
|
||||||
// Writing the row into the menu
|
// Writing the row into the menu
|
||||||
@@ -636,7 +690,7 @@ final class create extends menu
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* architecture
|
* Architecture
|
||||||
*
|
*
|
||||||
* Write the project architecture
|
* Write the project architecture
|
||||||
*
|
*
|
||||||
@@ -655,24 +709,8 @@ final class create extends menu
|
|||||||
// Initializing the project architecture
|
// Initializing the project architecture
|
||||||
$this->architecture = project_architecture::{$robot->callbackQuery()->data};
|
$this->architecture = project_architecture::{$robot->callbackQuery()->data};
|
||||||
|
|
||||||
// Initializing the project architecture purposes
|
// Clearing from deprecated parameters
|
||||||
$purposes = $this->architecture->purposes();
|
$this->clear();
|
||||||
|
|
||||||
if (count($purposes) === 1) {
|
|
||||||
// The project architecture has only 1 purpose
|
|
||||||
|
|
||||||
// Initializing the project purpose
|
|
||||||
$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
|
// Sending the popup notification
|
||||||
$robot->answerCallbackQuery(
|
$robot->answerCallbackQuery(
|
||||||
@@ -783,12 +821,9 @@ final class create extends menu
|
|||||||
// Addition to row buttons length
|
// Addition to row buttons length
|
||||||
$length += $purpose->length();
|
$length += $purpose->length();
|
||||||
|
|
||||||
// Initializing the coefficient
|
|
||||||
$coefficient = $purpose->coefficient();
|
|
||||||
|
|
||||||
// Writing the purpose button into the row
|
// Writing the purpose button into the row
|
||||||
$row[] = button::make(
|
$row[] = button::make(
|
||||||
/* text: ($localization['project_purpose_' . $purpose->name] ?? $purpose->label(language: $language)) . (!empty($coefficient) ? ' x' . $coefficient : ''), */
|
/* text: ($localization['project_purpose_' . $purpose->name] ?? $purpose->label(language: $language)) . (!empty($coefficient) ? ' x' . $coeffici🔹ent : ''), */
|
||||||
text: $localization['project_purpose_' . $purpose->name] ?? $purpose->label(language: $language),
|
text: $localization['project_purpose_' . $purpose->name] ?? $purpose->label(language: $language),
|
||||||
callback_data: "$purpose->name@purpose"
|
callback_data: "$purpose->name@purpose"
|
||||||
);
|
);
|
||||||
@@ -811,9 +846,6 @@ final class create extends menu
|
|||||||
// Reinitializing the row buttons length
|
// Reinitializing the row buttons length
|
||||||
$length = 0;
|
$length = 0;
|
||||||
|
|
||||||
// Initializing the coefficient
|
|
||||||
$coefficient = $next->coefficient();
|
|
||||||
|
|
||||||
// Writing the button into the menu
|
// Writing the button into the menu
|
||||||
$this->addButtonRow(button::make(
|
$this->addButtonRow(button::make(
|
||||||
/* text: ($localization['project_purpose_' . $next->name] ?? $next->label(language: $language)) . (!empty($coefficient) ? ' x' . $coefficient : ''), */
|
/* text: ($localization['project_purpose_' . $next->name] ?? $next->label(language: $language)) . (!empty($coefficient) ? ' x' . $coefficient : ''), */
|
||||||
@@ -826,7 +858,7 @@ final class create extends menu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($row) > 0) {
|
if (!empty($row)) {
|
||||||
// The row was not writed
|
// The row was not writed
|
||||||
|
|
||||||
// Writing the row into the menu
|
// Writing the row into the menu
|
||||||
@@ -867,6 +899,9 @@ final class create extends menu
|
|||||||
// Initializing the project purpose
|
// Initializing the project purpose
|
||||||
$this->purpose = project_purpose::{$robot->callbackQuery()->data};
|
$this->purpose = project_purpose::{$robot->callbackQuery()->data};
|
||||||
|
|
||||||
|
// Clearing from deprecated parameters
|
||||||
|
$this->clear();
|
||||||
|
|
||||||
// Sending the popup notification
|
// Sending the popup notification
|
||||||
$robot->answerCallbackQuery(
|
$robot->answerCallbackQuery(
|
||||||
text: $localization['project_purpose_' . $this->purpose?->name] ?? $this->purpose?->label(language: $language),
|
text: $localization['project_purpose_' . $this->purpose?->name] ?? $this->purpose?->label(language: $language),
|
||||||
@@ -880,6 +915,220 @@ final class create extends menu
|
|||||||
$this->start(robot: $robot, new: false);
|
$this->start(robot: $robot, new: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Integrations
|
||||||
|
*
|
||||||
|
* Generate the project integrations select menu
|
||||||
|
*
|
||||||
|
* @param telegram $robot The robot
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function integrations(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 account
|
||||||
|
$account = $robot->get('account');
|
||||||
|
|
||||||
|
// Updating the message text
|
||||||
|
$this->menuText(
|
||||||
|
text: implode(
|
||||||
|
"\n\n",
|
||||||
|
[
|
||||||
|
"📡 *$localization->project_create_integrations_title*",
|
||||||
|
$localization->project_create_integrations_description,
|
||||||
|
]
|
||||||
|
),
|
||||||
|
opt: [
|
||||||
|
'parse_mode' => mode::MARKDOWN
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
// Deleting the message buttons
|
||||||
|
$this->clearButtons();
|
||||||
|
|
||||||
|
// Initializing the row
|
||||||
|
$row = [];
|
||||||
|
|
||||||
|
// Declaring the buffer of the row buttons length
|
||||||
|
$length = 0;
|
||||||
|
|
||||||
|
// Initializing the maximum amount of buttons in a row
|
||||||
|
$break = 4;
|
||||||
|
|
||||||
|
// Initializing buffer of integrations
|
||||||
|
$integrations = $this->purpose->integrations();
|
||||||
|
|
||||||
|
// Declaring the generated buttons registry
|
||||||
|
$generated = [];
|
||||||
|
|
||||||
|
foreach ($integrations as $index => $integration) {
|
||||||
|
// Iterating over integrations
|
||||||
|
|
||||||
|
if ($length + $integration->length() > $break && !empty($row)) {
|
||||||
|
// Reached the limit of buttons in a row
|
||||||
|
|
||||||
|
// Writing the row into the menu
|
||||||
|
$this->addButtonRow(...$row);
|
||||||
|
|
||||||
|
// Writing buttons into the generated buttons registry
|
||||||
|
$generated += $row;
|
||||||
|
|
||||||
|
// Reinitializing the row buttons length
|
||||||
|
$length = 0;
|
||||||
|
|
||||||
|
// Reinitializing the row
|
||||||
|
$row = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Addition to row buttons length
|
||||||
|
$length += $integration->length();
|
||||||
|
|
||||||
|
// Initializing the target
|
||||||
|
$target = $this->integrations[$integration->name] ?? null;
|
||||||
|
|
||||||
|
// Writing the integration button into the row
|
||||||
|
$row[] = button::make(
|
||||||
|
text: (isset($target) && $target ? '🔹' : '') . ($localization['project_integration_' . $integration->name] ?? $integration->label(language: $language)),
|
||||||
|
callback_data: "$integration->name@integration"
|
||||||
|
);
|
||||||
|
|
||||||
|
// Initializing the next integration
|
||||||
|
$next = $integrations[$index + 1] ?? null;
|
||||||
|
|
||||||
|
if ($next?->length() >= $break) {
|
||||||
|
// The next integration is the full-length button
|
||||||
|
|
||||||
|
// Writing the row into the menu
|
||||||
|
$this->addButtonRow(...$row);
|
||||||
|
|
||||||
|
// Writing buttons into the generated buttons registry
|
||||||
|
$generated += $row;
|
||||||
|
|
||||||
|
// Reinitializing the row
|
||||||
|
$row = [];
|
||||||
|
|
||||||
|
// Reinitializing the row buttons length
|
||||||
|
$length = 0;
|
||||||
|
|
||||||
|
// Initializing the target
|
||||||
|
$target = $this->integrations[$integration->name] ?? null;
|
||||||
|
|
||||||
|
// Writing the button into the menu
|
||||||
|
$this->addButtonRow(button::make(
|
||||||
|
text: (isset($target) && $target ? '🔹' : '') . ($localization['project_integration_' . $integration->name] ?? $integration->label(language: $language)),
|
||||||
|
callback_data: "$integration->name@integration"
|
||||||
|
));
|
||||||
|
|
||||||
|
// Writing the button into the generated buttons registry
|
||||||
|
$generated[] = $next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($row) > 0) {
|
||||||
|
// The row was not writed
|
||||||
|
|
||||||
|
// Writing the row into the menu
|
||||||
|
$this->addButtonRow(...$row);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Writing the "back" button into the menu
|
||||||
|
$this->addButtonRow(button::make(
|
||||||
|
text: "🔏 $localization->project_create_button_back",
|
||||||
|
callback_data: '@continue'
|
||||||
|
));
|
||||||
|
|
||||||
|
// Deinitializing deprecated variables
|
||||||
|
unset($row, $limit, $length, $generated, $integrations, $integration);
|
||||||
|
|
||||||
|
// Updating the message and saving its text
|
||||||
|
$this->text = $this->showMenu()->text;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Integration
|
||||||
|
*
|
||||||
|
* Write the project integration
|
||||||
|
*
|
||||||
|
* @param telegram $robot The robot
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function integration(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 integration
|
||||||
|
$integration = project_integration::{$robot->callbackQuery()->data};
|
||||||
|
|
||||||
|
if (isset($this->integrations[$integration->name])) {
|
||||||
|
// Enabled
|
||||||
|
|
||||||
|
// Disabling
|
||||||
|
unset($this->integrations[$integration->name]);
|
||||||
|
} else {
|
||||||
|
// Disabled
|
||||||
|
|
||||||
|
// Enabling
|
||||||
|
$this->integrations[$integration->name] = $integration;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Sending the popup notification
|
||||||
|
$robot->answerCallbackQuery(
|
||||||
|
text: $localization['project_integrations_' . (isset($this->integrations[$integration->name]) ? 'enabled' : 'disabled')],
|
||||||
|
show_alert: false
|
||||||
|
);
|
||||||
|
|
||||||
|
// Deleting the message buttons
|
||||||
|
$this->integrations(robot: $robot);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear
|
||||||
|
*
|
||||||
|
* Deinitialize all deprecated parameters
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function clear(): void
|
||||||
|
{
|
||||||
|
// Initializing the project architecture purposes
|
||||||
|
$purposes = $this->architecture->purposes();
|
||||||
|
|
||||||
|
if (empty($purposes)) {
|
||||||
|
// The project architecture has no purposes
|
||||||
|
|
||||||
|
// Initializing the project purpose
|
||||||
|
$this->purpose = project_purpose::special;
|
||||||
|
} else if (count($purposes) === 1) {
|
||||||
|
// The project architecture has only 1 purpose
|
||||||
|
|
||||||
|
// Initializing the project purpose
|
||||||
|
$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 {
|
||||||
|
// The project can have other purposes
|
||||||
|
|
||||||
|
// Deinitializing the deprecated project purpose
|
||||||
|
unset($this->purpose);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deinitializing integrations
|
||||||
|
$this->integrations = [];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hours
|
* Hours
|
||||||
*
|
*
|
||||||
@@ -905,6 +1154,17 @@ final class create extends menu
|
|||||||
$coefficient += $this->purpose->coefficient();
|
$coefficient += $this->purpose->coefficient();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($this->integrations)) {
|
||||||
|
// Initialized the project integrations
|
||||||
|
|
||||||
|
foreach ($this->integrations as $integration) {
|
||||||
|
// Iterating over the project integrations
|
||||||
|
|
||||||
|
// Adding into the coefficient
|
||||||
|
$coefficient += $integration->coefficient();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Initializing start hours
|
// Initializing start hours
|
||||||
$start = PROJECT_CREATE_START_HOURS ?? 1;
|
$start = PROJECT_CREATE_START_HOURS ?? 1;
|
||||||
$start < 1 and $start = 1;
|
$start < 1 and $start = 1;
|
||||||
@@ -936,6 +1196,73 @@ final class create extends menu
|
|||||||
// Initializing the account localization
|
// Initializing the account localization
|
||||||
$localization = $robot->get('localization') ?? new localization($language);
|
$localization = $robot->get('localization') ?? new localization($language);
|
||||||
|
|
||||||
|
// Initializing the receivers registry
|
||||||
|
$receivers = PROJECT_CREATE_REQUEST_RECEIVERS;
|
||||||
|
|
||||||
|
// Initializing project data
|
||||||
|
$architecture = unmarkdown($this->architecture?->label(language: $language) ?? $localization->project_request_empty);
|
||||||
|
$purpose = unmarkdown(isset($this->purpose) ? $this->purpose->label(language: $language) : $localization->project_request_empty);
|
||||||
|
$hours = $this->hours();
|
||||||
|
|
||||||
|
// Generating the message text
|
||||||
|
$text = implode(
|
||||||
|
"\n\n",
|
||||||
|
[
|
||||||
|
'*' . unmarkdown(sprintf("💸 $localization->project_request_title", $sex ?? 0)) . '*',
|
||||||
|
<<<TXT
|
||||||
|
*$localization->project_request_architecture:* $architecture
|
||||||
|
*$localization->project_request_purpose:* $purpose
|
||||||
|
TXT,
|
||||||
|
<<<TXT
|
||||||
|
*$localization->project_request_hours:* $hours
|
||||||
|
TXT
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
// Initializing the keyboard
|
||||||
|
$keyboard = keyboard::make();
|
||||||
|
|
||||||
|
// Writing the row into the keyboard
|
||||||
|
$keyboard->addRow(
|
||||||
|
button::make(
|
||||||
|
text: "✉️ $localization->project_request_button_chat",
|
||||||
|
url: 'https://t.me/' . $robot->user()->username
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Writing the row into the keyboard
|
||||||
|
$keyboard->addRow(
|
||||||
|
button::make(
|
||||||
|
text: "⚖️ $localization->project_request_button_edit",
|
||||||
|
callback_data: 'edit'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Writing the row into the keyboard
|
||||||
|
$keyboard->addRow(
|
||||||
|
button::make(
|
||||||
|
text: "✅ $localization->project_request_button_accept",
|
||||||
|
callback_data: 'accept'
|
||||||
|
),
|
||||||
|
button::make(
|
||||||
|
text: "❌ $localization->project_request_button_refuse",
|
||||||
|
callback_data: 'refuse'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($receivers as $index => $receiver) {
|
||||||
|
// Iterating over receivers
|
||||||
|
|
||||||
|
// Sending the message
|
||||||
|
$robot->sendMessage(
|
||||||
|
text: $text,
|
||||||
|
chat_id: $receiver,
|
||||||
|
parse_mode: mode::MARKDOWN,
|
||||||
|
disable_notification: true,
|
||||||
|
reply_markup: $keyboard
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Sending the message
|
// Sending the message
|
||||||
$robot->sendMessage(
|
$robot->sendMessage(
|
||||||
text: "✅ *$localization->project_create_requested*",
|
text: "✅ *$localization->project_create_requested*",
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ define('PROJECT_CREATE_HOURS_ADDITIONAL', 0);
|
|||||||
define('PROJECT_CREATE_HOURS_MINIMAL', 4);
|
define('PROJECT_CREATE_HOURS_MINIMAL', 4);
|
||||||
define('PROJECT_CREATE_COST_HOUR_DEFAULT', 1200);
|
define('PROJECT_CREATE_COST_HOUR_DEFAULT', 1200);
|
||||||
|
|
||||||
define('PROJECT_CREATE_REQUEST_CHATS', [
|
define('PROJECT_CREATE_REQUEST_RECEIVERS', [
|
||||||
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user