cost filters and deleting

This commit is contained in:
2026-03-04 22:46:47 +05:00
parent 4839f950e5
commit 4fdcae74be
2 changed files with 88 additions and 33 deletions

View File

@@ -33,9 +33,11 @@ return [
'project_create_time_days' => 'дн', 'project_create_time_days' => 'дн',
'project_create_cost' => 'Стоимость', 'project_create_cost' => 'Стоимость',
'project_create_request_cost_title' => 'Стоимость разработки', 'project_create_request_cost_title' => 'Стоимость разработки',
'project_create_request_cost_description' => 'Введите своё предложение по *оплате за 1 час* разработки, оно будет расмотрено всей командой', 'project_create_request_cost_description' => 'Введите предложение по *оплате за 1 час* разработки',
'project_create_request_cost_default' => '*`%d%s`* \- средняя стоимость с учётом *компетенции*, совокупного опыта, *уникальных* разработок\. Цена уже включает\: *наши сервера*, документирование кода, *передачу кода*, ведение репозитория, *техподдержку* и репутационные гарантии', 'project_create_request_cost_default' => '*`%d%s`* \- средняя стоимость с учётом *компетенции*, совокупного опыта, *уникальных* разработок\. Цена уже включает\: *наши сервера*, документирование кода, *передачу кода*, ведение репозитория, *техподдержку* и репутационные гарантии',
'project_create_request_cost_warning' => '_Если цена на наш взгляд окажется *недостаточной*, мы выставим *справедливое* и *конкурентное* встречное предложение с детальной *аргументацией*_', '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' => 'Заказать',

View File

@@ -1143,14 +1143,18 @@ final class create extends menu
if (!empty($text) && $data !== 'set') { if (!empty($text) && $data !== 'set') {
// Not empty text // Not empty text
// Initializing the message filters
$minimum = 2;
$maximum = 5;
// Writing the user input message into the messages registry // Writing the user input message into the messages registry
$this->messages[] = $message; $this->messages[] = $message;
// Initializing the text length // Initializing the text length
$length = mb_strlen($text); $length = mb_strlen($text);
if ($length > 0) { if ($length >= $minimum) {
// More than 2 symbols text // More than minimum amount of symbols
// Sanitizing // Sanitizing
$float = filter_var($text, FILTER_SANITIZE_NUMBER_FLOAT); $float = filter_var($text, FILTER_SANITIZE_NUMBER_FLOAT);
@@ -1159,30 +1163,78 @@ final class create extends menu
// Number // Number
// Writing the cost // Writing the cost
$this->cost = (float)$float; $this->cost = (float) $float;
try {
foreach ($this->messages as $message) { foreach ($this->messages as $message) {
// Iterating over messages registry // Iterating over messages registry
// Deleting the message // Deleting the message
$message->delete(); $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 // Deinitializing the messages registry
$this->messages = []; $this->messages = [];
}
// Sending the process main menu // Sending the process main menu
$this->start(robot: $robot, new: false); $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 { } else {
// Less or equal than 2 symbols text // 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 {
// Empty text // Empty text
// Sending the message // Sending the message and reinitializing the messages registry
$this->messages[] = $robot->sendMessage( $this->messages = [
$robot->sendMessage(
text: implode( text: implode(
"\n\n", "\n\n",
array_filter( array_filter(
@@ -1200,7 +1252,8 @@ final class create extends menu
), ),
parse_mode: mode::MARKDOWN, parse_mode: mode::MARKDOWN,
disable_notification: true, disable_notification: true,
); )
];
// Waiting for the user input // Waiting for the user input
$this->next('cost'); $this->next('cost');