Compare commits
No commits in common. "stable" and "1.3.0" have entirely different histories.
|
@ -1,5 +1,3 @@
|
||||||
# Telegram chat-robot for task registering
|
# Telegram-robot for registering for tasks
|
||||||
|
|
||||||
Chat-robot Telegram for accepting applications for employees from [mirzaev/ebala](https://git.mirzaev.sexy/mirzaev/ebala)
|
Synchronizes accounts with the site, displays a list of published applications with a selection by date, and also register to tasks
|
||||||
|
|
||||||
**DEVELOPMENT COMPLETED. PROJECT CLOSED.**
|
|
|
@ -346,43 +346,37 @@ function request_confirmed(Context $ctx): void
|
||||||
// Прочитана запрашиваемая заявка
|
// Прочитана запрашиваемая заявка
|
||||||
|
|
||||||
// Инициализация инстанции task в базе данных (выбранного задания)
|
// Инициализация инстанции task в базе данных (выбранного задания)
|
||||||
$task = collection::search($arangodb->session, sprintf("FOR d IN task FILTER d._key == '%s' && d.published == true && d.completed != true && worker == null RETURN d", $_key));
|
$task = collection::search($arangodb->session, sprintf("FOR d IN task FILTER d._key == '%s' && d.published == true && d.completed != true RETURN d", $_key));
|
||||||
|
|
||||||
if ($task instanceof _document) {
|
if ($worker ??= worker($account->getId())) {
|
||||||
// Найдена заявка (подразумевается, что не занята)
|
// Найден сотрудник
|
||||||
|
|
||||||
if ($worker ??= worker($account->getId())) {
|
// Запись идентификатора нового сотрудника
|
||||||
// Найден сотрудник
|
$task->worker = $worker->id;
|
||||||
|
|
||||||
// Запись идентификатора нового сотрудника
|
// Снятие с публикации
|
||||||
$task->worker = $worker->id;
|
$task->published = false;
|
||||||
|
|
||||||
// Снятие с публикации
|
if (document::update($arangodb->session, $task)) {
|
||||||
$task->published = false;
|
// Записано обновление в базу данных
|
||||||
|
|
||||||
if (document::update($arangodb->session, $task)) {
|
$ctx->getChatDataItem("request_all")->then(function ($requests = []) use ($ctx) {
|
||||||
// Записано обновление в базу данных
|
// Удаление сообщений связанных с запросом
|
||||||
|
foreach ($requests ?? [] as $_message) $ctx->deleteMessage($_message->getChat()->getId(), $_message->getMessageId());
|
||||||
|
});
|
||||||
|
$ctx->setChatDataItem("request_all", []);
|
||||||
|
|
||||||
$ctx->getChatDataItem("request_all")->then(function ($requests = []) use ($ctx) {
|
$ctx->getChatDataItem("request_confirmation")->then(function ($message) use ($ctx) {
|
||||||
// Удаление сообщений связанных с запросом
|
$ctx->deleteMessage($message->getChat()->getId(), $message->getMessageId());
|
||||||
foreach ($requests ?? [] as $_message) $ctx->deleteMessage($_message->getChat()->getId(), $_message->getMessageId());
|
});
|
||||||
});
|
$ctx->setChatDataItem("request_confirmation_target", null);
|
||||||
$ctx->setChatDataItem("request_all", []);
|
|
||||||
|
|
||||||
$ctx->getChatDataItem("request_confirmation")->then(function ($message) use ($ctx) {
|
$ctx->sendMessage("✅ *Вы зарегистрировались на заявку:* \#$_key", ['reply_markup' => ['remove_keyboard' => true]])->then(function () use ($ctx) {
|
||||||
$ctx->deleteMessage($message->getChat()->getId(), $message->getMessageId());
|
|
||||||
});
|
|
||||||
$ctx->setChatDataItem("request_confirmation_target", null);
|
|
||||||
|
|
||||||
$ctx->sendMessage("✅ *Вы зарегистрировались на заявку:* \#$_key", ['reply_markup' => ['remove_keyboard' => true]])->then(function () use ($ctx) {
|
|
||||||
generateMenu($ctx);
|
|
||||||
});
|
|
||||||
|
|
||||||
// End of the process
|
|
||||||
$ctx->endConversation();
|
|
||||||
} else $ctx->sendMessage("❎ *Не удалось принять заявку:* \#$_key", ['reply_markup' => ['remove_keyboard' => true]])->then(function () use ($ctx) {
|
|
||||||
generateMenu($ctx);
|
generateMenu($ctx);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// End of the process
|
||||||
|
$ctx->endConversation();
|
||||||
} else $ctx->sendMessage("❎ *Не удалось принять заявку:* \#$_key", ['reply_markup' => ['remove_keyboard' => true]])->then(function () use ($ctx) {
|
} else $ctx->sendMessage("❎ *Не удалось принять заявку:* \#$_key", ['reply_markup' => ['remove_keyboard' => true]])->then(function () use ($ctx) {
|
||||||
generateMenu($ctx);
|
generateMenu($ctx);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Telegram-robot
|
Description=Telegram-robot
|
||||||
|
|
||||||
Wants=network.target
|
|
||||||
After=syslog.target network-online.target
|
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecStart=sudo -u www-data /usr/bin/php /var/www/spetsresurs-telegram-registry-requests/mirzaev/spetsresurs/telegram/registry/requests/system/public/robot.php
|
ExecStart=sudo -u www-data /usr/bin/php /var/www/spetsresurs-telegram-registry-requests/mirzaev/spetsresurs/telegram/registry/requests/system/public/robot.php
|
||||||
PIDFile=/var/run/php/telegram-robot.pid
|
PIDFile=/var/run/php/telegram-robot.pid
|
||||||
|
@ -11,6 +8,3 @@ RemainAfterExit=no
|
||||||
RuntimeMaxSec=3600s
|
RuntimeMaxSec=3600s
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=5s
|
RestartSec=5s
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
|
|
Reference in New Issue