generated from mirzaev/pot-php-telegram
cost filters and deleting
This commit is contained in:
@@ -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' => 'Заказать',
|
||||||
|
|||||||
@@ -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,48 +1163,97 @@ final class create extends menu
|
|||||||
// Number
|
// Number
|
||||||
|
|
||||||
// Writing the cost
|
// Writing the cost
|
||||||
$this->cost = (float)$float;
|
$this->cost = (float) $float;
|
||||||
|
|
||||||
foreach ($this->messages as $message) {
|
try {
|
||||||
// Iterating over messages registry
|
foreach ($this->messages as $message) {
|
||||||
|
// 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
|
||||||
|
$this->messages = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deinitializing the messages registry
|
|
||||||
$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 = [
|
||||||
text: implode(
|
$robot->sendMessage(
|
||||||
"\n\n",
|
text: implode(
|
||||||
array_filter(
|
"\n\n",
|
||||||
[
|
array_filter(
|
||||||
"✏️ *$localization->project_create_request_cost_title*",
|
[
|
||||||
$localization->project_create_request_cost_description,
|
"✏️ *$localization->project_create_request_cost_title*",
|
||||||
sprintf(
|
$localization->project_create_request_cost_description,
|
||||||
$localization->project_create_request_cost_default,
|
sprintf(
|
||||||
PROJECT_CREATE_COST_HOUR_DEFAULT,
|
$localization->project_create_request_cost_default,
|
||||||
CURRENCY_DEFAULT->symbol() ?? ''
|
PROJECT_CREATE_COST_HOUR_DEFAULT,
|
||||||
),
|
CURRENCY_DEFAULT->symbol() ?? ''
|
||||||
"⚠️ $localization->project_create_request_cost_warning"
|
),
|
||||||
]
|
"⚠️ $localization->project_create_request_cost_warning"
|
||||||
)
|
]
|
||||||
),
|
)
|
||||||
parse_mode: mode::MARKDOWN,
|
),
|
||||||
disable_notification: true,
|
parse_mode: mode::MARKDOWN,
|
||||||
);
|
disable_notification: true,
|
||||||
|
)
|
||||||
|
];
|
||||||
|
|
||||||
// Waiting for the user input
|
// Waiting for the user input
|
||||||
$this->next('cost');
|
$this->next('cost');
|
||||||
|
|||||||
Reference in New Issue
Block a user