generated from mirzaev/pot-php-telegram
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4fdcae74be | |||
| 4839f950e5 |
@@ -25,13 +25,19 @@ return [
|
|||||||
// Проект: создание
|
// Проект: создание
|
||||||
'project_create_title' => 'Создание проекта',
|
'project_create_title' => 'Создание проекта',
|
||||||
/* 'project_create_description' => "Расчитайте ориентировочное время разработки, затем выберите разработчиков и получите стоимость\n\nПосле расчётов можно будет отправить проект в заказ разработчикам и приложить ТЗ, либо краткое описание задачи\n\nМы погружаемся в проекты полностью, поэтому стараемся не распыляться - от степени нагрузки меняется коэффициент стоимости!", */
|
/* 'project_create_description' => "Расчитайте ориентировочное время разработки, затем выберите разработчиков и получите стоимость\n\nПосле расчётов можно будет отправить проект в заказ разработчикам и приложить ТЗ, либо краткое описание задачи\n\nМы погружаемся в проекты полностью, поэтому стараемся не распыляться - от степени нагрузки меняется коэффициент стоимости!", */
|
||||||
'project_create_description' => "Задайте параметры и получите ориентировочное время разработки, затем выберите разработчиков и получите стоимость их работы\n\n_После расчётов можно отправить проект в заказ и приложить ТЗ, либо описание задачи_",
|
'project_create_description' => "Установите параметры и получите ориентировочное время разработки\n\n_После расчётов можно отправить проект в заказ приложив ТЗ, либо описание задачи_",
|
||||||
'project_create_cost_description' => "Стоимость и сроки выполнения предоставлены для планирования и *не являются публичной офертой*",
|
'project_create_cost_description' => "Стоимость и сроки выполнения предоставлены для планирования и *не являются публичной офертой*",
|
||||||
'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_time_days' => 'дн',
|
'project_create_time_days' => 'дн',
|
||||||
'project_create_cost' => 'Стоимость',
|
'project_create_cost' => 'Стоимость',
|
||||||
|
'project_create_request_cost_title' => 'Стоимость разработки',
|
||||||
|
'project_create_request_cost_description' => 'Введите предложение по *оплате за 1 час* разработки',
|
||||||
|
'project_create_request_cost_default' => '*`%d%s`* \- средняя стоимость с учётом *компетенции*, совокупного опыта, *уникальных* разработок\. Цена уже включает\: *наши сервера*, документирование кода, *передачу кода*, ведение репозитория, *техподдержку* и репутационные гарантии',
|
||||||
|
'project_create_request_cost_warning' => '_Если цена окажется *недостаточной*, мы выставим *справедливое* и *конкурентное* встречное предложение_',
|
||||||
|
'project_create_request_cost_error_distance' => 'Длина сообщения должна быть от %d и до %d символов',
|
||||||
|
'project_create_request_cost_error_not_a_number' => 'Значение должно быть числом',
|
||||||
'project_create_button_back' => 'Назад',
|
'project_create_button_back' => 'Назад',
|
||||||
'project_create_button_cost_per_hour' => 'Час',
|
'project_create_button_cost_per_hour' => 'Час',
|
||||||
'project_create_button_request' => 'Заказать',
|
'project_create_button_request' => 'Заказать',
|
||||||
@@ -47,7 +53,7 @@ return [
|
|||||||
'project_create_button_purpose_selected' => 'Назнач.',
|
'project_create_button_purpose_selected' => 'Назнач.',
|
||||||
|
|
||||||
'project_create_integrations_title' => 'Выбор интеграций',
|
'project_create_integrations_title' => 'Выбор интеграций',
|
||||||
'project_create_integrations_description' => "Синхронизация данных в реальном времени, скачивание, загрузка, перенос информации, админ\-панель, рассылка сообщений, подключение аккаунтов\.\.\.\n\n_Отправка запросов в *API*, генерация и перехват *HTTP\-сообщений*, *эмуляция* действий пользователя через *виртуальный браузер* с курсором мыши и клавиатурой, либо *нестандартные протоколы связи*_",
|
'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' => 'Интеграции',
|
||||||
|
|
||||||
|
|||||||
@@ -78,6 +78,15 @@ final class create extends menu
|
|||||||
*/
|
*/
|
||||||
public int|float $cost = PROJECT_CREATE_COST_HOUR_DEFAULT ?? 0;
|
public int|float $cost = PROJECT_CREATE_COST_HOUR_DEFAULT ?? 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Messages
|
||||||
|
*
|
||||||
|
* Registry of messages for cleaning
|
||||||
|
*
|
||||||
|
* @var array $messages
|
||||||
|
*/
|
||||||
|
public array $messages = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start
|
* Start
|
||||||
*
|
*
|
||||||
@@ -515,8 +524,8 @@ final class create extends menu
|
|||||||
// Writing the project buttons
|
// Writing the project buttons
|
||||||
$this->addButtonRow(
|
$this->addButtonRow(
|
||||||
button::make(
|
button::make(
|
||||||
text: '⚖️ ' . "$localization->project_create_button_cost_per_hour: $this->cost" . $account->currency->symbol(),
|
text: '🛠 ' . "$localization->project_create_button_cost_per_hour: $this->cost" . $account->currency->symbol(),
|
||||||
callback_data: '@cost'
|
callback_data: 'set@cost'
|
||||||
),
|
),
|
||||||
button::make(
|
button::make(
|
||||||
text: "📦 $localization->project_create_button_request",
|
text: "📦 $localization->project_create_button_request",
|
||||||
@@ -529,8 +538,8 @@ final class create extends menu
|
|||||||
// Writing the project cost per hour button
|
// Writing the project cost per hour button
|
||||||
$this->addButtonRow(
|
$this->addButtonRow(
|
||||||
button::make(
|
button::make(
|
||||||
text: '⚖️ ' . $localization->project_create_button_cost_per_hour,
|
text: '🛠 ' . $localization->project_create_button_cost_per_hour,
|
||||||
callback_data: '@cost'
|
callback_data: 'set@cost'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -551,7 +560,7 @@ final class create extends menu
|
|||||||
*/
|
*/
|
||||||
public function continue(telegram $robot): void
|
public function continue(telegram $robot): void
|
||||||
{
|
{
|
||||||
// Continuing the process
|
// Sending the process main menu
|
||||||
$this->start(robot: $robot, new: false);
|
$this->start(robot: $robot, new: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -580,10 +589,12 @@ final class create extends menu
|
|||||||
$this->menuText(
|
$this->menuText(
|
||||||
text: implode(
|
text: implode(
|
||||||
"\n\n",
|
"\n\n",
|
||||||
[
|
array_filter(
|
||||||
"⚙️ *$localization->project_create_architectures_title*",
|
[
|
||||||
$localization->project_create_architectures_description,
|
"⚙️ *$localization->project_create_architectures_title*",
|
||||||
]
|
$localization->project_create_architectures_description,
|
||||||
|
]
|
||||||
|
)
|
||||||
),
|
),
|
||||||
opt: [
|
opt: [
|
||||||
'parse_mode' => mode::MARKDOWN
|
'parse_mode' => mode::MARKDOWN
|
||||||
@@ -732,7 +743,7 @@ final class create extends menu
|
|||||||
// Deleting the message buttons
|
// Deleting the message buttons
|
||||||
$this->clearButtons();
|
$this->clearButtons();
|
||||||
|
|
||||||
// Deleting the message buttons
|
// Sending the process main menu
|
||||||
$this->start(robot: $robot, new: false);
|
$this->start(robot: $robot, new: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -760,10 +771,10 @@ final class create extends menu
|
|||||||
$this->menuText(
|
$this->menuText(
|
||||||
text: implode(
|
text: implode(
|
||||||
"\n\n",
|
"\n\n",
|
||||||
[
|
array_filter([
|
||||||
"🛠 *$localization->project_create_purposes_title*",
|
"🛠 *$localization->project_create_purposes_title*",
|
||||||
$localization->project_create_purposes_description,
|
$localization->project_create_purposes_description,
|
||||||
]
|
])
|
||||||
),
|
),
|
||||||
opt: [
|
opt: [
|
||||||
'parse_mode' => mode::MARKDOWN
|
'parse_mode' => mode::MARKDOWN
|
||||||
@@ -922,7 +933,7 @@ final class create extends menu
|
|||||||
// Deleting the message buttons
|
// Deleting the message buttons
|
||||||
$this->clearButtons();
|
$this->clearButtons();
|
||||||
|
|
||||||
// Deleting the message buttons
|
// Sending the process main menu
|
||||||
$this->start(robot: $robot, new: false);
|
$this->start(robot: $robot, new: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -950,10 +961,10 @@ final class create extends menu
|
|||||||
$this->menuText(
|
$this->menuText(
|
||||||
text: implode(
|
text: implode(
|
||||||
"\n\n",
|
"\n\n",
|
||||||
[
|
array_filter([
|
||||||
"📡 *$localization->project_create_integrations_title*",
|
"📡 *$localization->project_create_integrations_title*",
|
||||||
$localization->project_create_integrations_description,
|
$localization->project_create_integrations_description,
|
||||||
]
|
])
|
||||||
),
|
),
|
||||||
opt: [
|
opt: [
|
||||||
'parse_mode' => mode::MARKDOWN
|
'parse_mode' => mode::MARKDOWN
|
||||||
@@ -1120,29 +1131,133 @@ 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 integration
|
// Initializing the user input message
|
||||||
$integration = project_integration::{$robot->callbackQuery()->data};
|
$message = $robot->message();
|
||||||
|
|
||||||
if (isset($this->integrations[$integration->name])) {
|
// Initializing the user input message text
|
||||||
// Enabled
|
$text = $message?->text;
|
||||||
|
|
||||||
// Disabling
|
// Initializing the message data
|
||||||
unset($this->integrations[$integration->name]);
|
$data = $robot->callbackQuery()?->data;
|
||||||
|
|
||||||
|
if (!empty($text) && $data !== 'set') {
|
||||||
|
// Not empty text
|
||||||
|
|
||||||
|
// Initializing the message filters
|
||||||
|
$minimum = 2;
|
||||||
|
$maximum = 5;
|
||||||
|
|
||||||
|
// Writing the user input message into the messages registry
|
||||||
|
$this->messages[] = $message;
|
||||||
|
|
||||||
|
// Initializing the text length
|
||||||
|
$length = mb_strlen($text);
|
||||||
|
|
||||||
|
if ($length >= $minimum) {
|
||||||
|
// More than minimum amount of symbols
|
||||||
|
|
||||||
|
// Sanitizing
|
||||||
|
$float = filter_var($text, FILTER_SANITIZE_NUMBER_FLOAT);
|
||||||
|
|
||||||
|
if (filter_var($float, FILTER_VALIDATE_FLOAT)) {
|
||||||
|
// Number
|
||||||
|
|
||||||
|
// Writing the cost
|
||||||
|
$this->cost = (float) $float;
|
||||||
|
|
||||||
|
try {
|
||||||
|
foreach ($this->messages as $message) {
|
||||||
|
// Iterating over messages registry
|
||||||
|
|
||||||
|
// Deleting the message
|
||||||
|
$message->delete();
|
||||||
|
|
||||||
|
// Waiting just for rofls
|
||||||
|
usleep(200);
|
||||||
|
}
|
||||||
|
} catch (exception $exception) {
|
||||||
|
// Sending into the errors output buffer
|
||||||
|
error_log($exception->getMessage());
|
||||||
|
} finally {
|
||||||
|
// Deinitializing the messages registry
|
||||||
|
$this->messages = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sending the process main menu
|
||||||
|
$this->start(robot: $robot, new: false);
|
||||||
|
} else {
|
||||||
|
// Not a number
|
||||||
|
|
||||||
|
// Sending the message
|
||||||
|
$this->messages[] = $robot->sendMessage(
|
||||||
|
text: implode(
|
||||||
|
"\n\n",
|
||||||
|
array_filter(
|
||||||
|
[
|
||||||
|
"⚠️ $localization->project_create_request_cost_error_not_a_number",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
),
|
||||||
|
parse_mode: mode::MARKDOWN,
|
||||||
|
disable_notification: true,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Waiting for the user input
|
||||||
|
$this->next('cost');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Less or equal than minimum amount of symbols
|
||||||
|
|
||||||
|
// Sending the message
|
||||||
|
$this->messages[] = $robot->sendMessage(
|
||||||
|
text: implode(
|
||||||
|
"\n\n",
|
||||||
|
array_filter(
|
||||||
|
[
|
||||||
|
sprintf(
|
||||||
|
"⚠️ $localization->project_create_request_cost_error_distance",
|
||||||
|
$minimum,
|
||||||
|
$maximum
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
),
|
||||||
|
parse_mode: mode::MARKDOWN,
|
||||||
|
disable_notification: true,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Waiting for the user input
|
||||||
|
$this->next('cost');
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Disabled
|
// Empty text
|
||||||
|
|
||||||
// Enabling
|
// Sending the message and reinitializing the messages registry
|
||||||
$this->integrations[$integration->name] = $integration;
|
$this->messages = [
|
||||||
};
|
$robot->sendMessage(
|
||||||
|
text: implode(
|
||||||
|
"\n\n",
|
||||||
|
array_filter(
|
||||||
|
[
|
||||||
|
"✏️ *$localization->project_create_request_cost_title*",
|
||||||
|
$localization->project_create_request_cost_description,
|
||||||
|
sprintf(
|
||||||
|
$localization->project_create_request_cost_default,
|
||||||
|
PROJECT_CREATE_COST_HOUR_DEFAULT,
|
||||||
|
CURRENCY_DEFAULT->symbol() ?? ''
|
||||||
|
),
|
||||||
|
"⚠️ $localization->project_create_request_cost_warning"
|
||||||
|
]
|
||||||
|
)
|
||||||
|
),
|
||||||
|
parse_mode: mode::MARKDOWN,
|
||||||
|
disable_notification: true,
|
||||||
|
)
|
||||||
|
];
|
||||||
|
|
||||||
// Sending the popup notification
|
// Waiting for the user input
|
||||||
$robot->answerCallbackQuery(
|
$this->next('cost');
|
||||||
text: $localization['project_integrations_' . (isset($this->integrations[$integration->name]) ? 'enabled' : 'disabled')],
|
}
|
||||||
show_alert: false
|
|
||||||
);
|
|
||||||
|
|
||||||
// Deleting the message buttons
|
|
||||||
$this->integrations(robot: $robot);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1303,16 +1418,18 @@ final class create extends menu
|
|||||||
// Generating the message text
|
// Generating the message text
|
||||||
$text = implode(
|
$text = implode(
|
||||||
"\n\n",
|
"\n\n",
|
||||||
[
|
array_filter(
|
||||||
'*' . unmarkdown(sprintf("💸 $localization->project_request_title", $sex ?? 0)) . '*',
|
[
|
||||||
<<<TXT
|
'*' . unmarkdown(sprintf("💸 $localization->project_request_title", $sex ?? 0)) . '*',
|
||||||
|
<<<TXT
|
||||||
*$localization->project_request_architecture:* $architecture
|
*$localization->project_request_architecture:* $architecture
|
||||||
*$localization->project_request_purpose:* $purpose
|
*$localization->project_request_purpose:* $purpose
|
||||||
TXT,
|
TXT,
|
||||||
<<<TXT
|
<<<TXT
|
||||||
*$localization->project_request_hours:* $hours
|
*$localization->project_request_hours:* $hours
|
||||||
TXT
|
TXT
|
||||||
]
|
]
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Initializing the keyboard
|
// Initializing the keyboard
|
||||||
|
|||||||
Reference in New Issue
Block a user