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_description' => "Расчитайте ориентировочное время разработки, затем выберите разработчиков и получите стоимость\n\nПосле расчётов можно будет отправить проект в заказ разработчикам и приложить ТЗ, либо краткое описание задачи\n\nМы погружаемся в проекты полностью, поэтому стараемся не распыляться - от степени нагрузки меняется коэффициент стоимости!", */
|
||||
'project_create_description' => "Задайте параметры и получите ориентировочное время разработки, затем выберите разработчиков и получите стоимость их работы\n\n_После расчётов можно отправить проект в заказ и приложить ТЗ, либо описание задачи_",
|
||||
'project_create_description' => "Установите параметры и получите ориентировочное время разработки\n\n_После расчётов можно отправить проект в заказ приложив ТЗ, либо описание задачи_",
|
||||
'project_create_cost_description' => "Стоимость и сроки выполнения предоставлены для планирования и *не являются публичной офертой*",
|
||||
'project_create_time' => 'Время разработки',
|
||||
'project_create_time_hours' => 'ч',
|
||||
'project_create_time_hours_from' => 'от',
|
||||
'project_create_time_days' => 'дн',
|
||||
'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_cost_per_hour' => 'Час',
|
||||
'project_create_button_request' => 'Заказать',
|
||||
@@ -47,7 +53,7 @@ return [
|
||||
'project_create_button_purpose_selected' => 'Назнач.',
|
||||
|
||||
'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_selected' => 'Интеграции',
|
||||
|
||||
|
||||
@@ -78,6 +78,15 @@ final class create extends menu
|
||||
*/
|
||||
public int|float $cost = PROJECT_CREATE_COST_HOUR_DEFAULT ?? 0;
|
||||
|
||||
/**
|
||||
* Messages
|
||||
*
|
||||
* Registry of messages for cleaning
|
||||
*
|
||||
* @var array $messages
|
||||
*/
|
||||
public array $messages = [];
|
||||
|
||||
/**
|
||||
* Start
|
||||
*
|
||||
@@ -515,8 +524,8 @@ final class create extends menu
|
||||
// Writing the project buttons
|
||||
$this->addButtonRow(
|
||||
button::make(
|
||||
text: '⚖️ ' . "$localization->project_create_button_cost_per_hour: $this->cost" . $account->currency->symbol(),
|
||||
callback_data: '@cost'
|
||||
text: '🛠 ' . "$localization->project_create_button_cost_per_hour: $this->cost" . $account->currency->symbol(),
|
||||
callback_data: 'set@cost'
|
||||
),
|
||||
button::make(
|
||||
text: "📦 $localization->project_create_button_request",
|
||||
@@ -529,8 +538,8 @@ final class create extends menu
|
||||
// Writing the project cost per hour button
|
||||
$this->addButtonRow(
|
||||
button::make(
|
||||
text: '⚖️ ' . $localization->project_create_button_cost_per_hour,
|
||||
callback_data: '@cost'
|
||||
text: '🛠 ' . $localization->project_create_button_cost_per_hour,
|
||||
callback_data: 'set@cost'
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -551,7 +560,7 @@ final class create extends menu
|
||||
*/
|
||||
public function continue(telegram $robot): void
|
||||
{
|
||||
// Continuing the process
|
||||
// Sending the process main menu
|
||||
$this->start(robot: $robot, new: false);
|
||||
}
|
||||
|
||||
@@ -580,10 +589,12 @@ final class create extends menu
|
||||
$this->menuText(
|
||||
text: implode(
|
||||
"\n\n",
|
||||
array_filter(
|
||||
[
|
||||
"⚙️ *$localization->project_create_architectures_title*",
|
||||
$localization->project_create_architectures_description,
|
||||
]
|
||||
)
|
||||
),
|
||||
opt: [
|
||||
'parse_mode' => mode::MARKDOWN
|
||||
@@ -732,7 +743,7 @@ final class create extends menu
|
||||
// Deleting the message buttons
|
||||
$this->clearButtons();
|
||||
|
||||
// Deleting the message buttons
|
||||
// Sending the process main menu
|
||||
$this->start(robot: $robot, new: false);
|
||||
}
|
||||
|
||||
@@ -760,10 +771,10 @@ final class create extends menu
|
||||
$this->menuText(
|
||||
text: implode(
|
||||
"\n\n",
|
||||
[
|
||||
array_filter([
|
||||
"🛠 *$localization->project_create_purposes_title*",
|
||||
$localization->project_create_purposes_description,
|
||||
]
|
||||
])
|
||||
),
|
||||
opt: [
|
||||
'parse_mode' => mode::MARKDOWN
|
||||
@@ -922,7 +933,7 @@ final class create extends menu
|
||||
// Deleting the message buttons
|
||||
$this->clearButtons();
|
||||
|
||||
// Deleting the message buttons
|
||||
// Sending the process main menu
|
||||
$this->start(robot: $robot, new: false);
|
||||
}
|
||||
|
||||
@@ -950,10 +961,10 @@ final class create extends menu
|
||||
$this->menuText(
|
||||
text: implode(
|
||||
"\n\n",
|
||||
[
|
||||
array_filter([
|
||||
"📡 *$localization->project_create_integrations_title*",
|
||||
$localization->project_create_integrations_description,
|
||||
]
|
||||
])
|
||||
),
|
||||
opt: [
|
||||
'parse_mode' => mode::MARKDOWN
|
||||
@@ -1120,29 +1131,133 @@ final class create extends menu
|
||||
// Initializing the account localization
|
||||
$localization = $robot->get('localization') ?? new localization($language);
|
||||
|
||||
// Initializing the integration
|
||||
$integration = project_integration::{$robot->callbackQuery()->data};
|
||||
// Initializing the user input message
|
||||
$message = $robot->message();
|
||||
|
||||
if (isset($this->integrations[$integration->name])) {
|
||||
// Enabled
|
||||
// Initializing the user input message text
|
||||
$text = $message?->text;
|
||||
|
||||
// Disabling
|
||||
unset($this->integrations[$integration->name]);
|
||||
// Initializing the message data
|
||||
$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 {
|
||||
// Disabled
|
||||
// Not a number
|
||||
|
||||
// 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
|
||||
// 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,
|
||||
);
|
||||
|
||||
// Deleting the message buttons
|
||||
$this->integrations(robot: $robot);
|
||||
// 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 {
|
||||
// Empty text
|
||||
|
||||
// Sending the message and reinitializing the messages registry
|
||||
$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,
|
||||
)
|
||||
];
|
||||
|
||||
// Waiting for the user input
|
||||
$this->next('cost');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1303,6 +1418,7 @@ final class create extends menu
|
||||
// Generating the message text
|
||||
$text = implode(
|
||||
"\n\n",
|
||||
array_filter(
|
||||
[
|
||||
'*' . unmarkdown(sprintf("💸 $localization->project_request_title", $sex ?? 0)) . '*',
|
||||
<<<TXT
|
||||
@@ -1313,6 +1429,7 @@ final class create extends menu
|
||||
*$localization->project_request_hours:* $hours
|
||||
TXT
|
||||
]
|
||||
)
|
||||
);
|
||||
|
||||
// Initializing the keyboard
|
||||
|
||||
Reference in New Issue
Block a user