Other Telegram bot fixes
This commit is contained in:
parent
f3adbb34bd
commit
447107bef6
|
@ -166,7 +166,7 @@ function job_send_notification_if_manual_mode() {
|
|||
foreach ($profiles as $profile) {
|
||||
$notified_users[] = $profiles["id"];
|
||||
$stato = $profile["available"] ? "disponibile" : "non disponibile";
|
||||
sendTelegramNotificationToUser("⚠️ Attenzione! La tua disponibilità non segue la programmazione oraria.\nAttualmente sei {$stato}.\nScrivi \"/programma\" se vuoi ripristinare la programmazione.", $profile["id"]);
|
||||
sendTelegramNotificationToUser("⚠️ Attenzione! La tua disponibilità <b>non segue la programmazione oraria</b>.\nAttualmente sei <b>{$stato}</b>.\nScrivi \"/programma\" se vuoi ripristinare la programmazione.", $profile["id"]);
|
||||
}
|
||||
$output = $notified_users;
|
||||
$output_status = "ok";
|
||||
|
|
|
@ -196,7 +196,8 @@ function telegramBotRouter() {
|
|||
global $Bot, $availability;
|
||||
requireBotLogin($message);
|
||||
if(count(explode(" ", $message->text)) > 3) return;
|
||||
$availability->change_manual_mode(0);
|
||||
$userId = getUserIdByMessage($message);
|
||||
$availability->change_manual_mode(0, $userId);
|
||||
$Bot->sendMessage($message->from->id, "Programmazione oraria <b>abilitata</b>.\nPer disabilitarla (e tornare in modalità manuale), cambiare la disponbilità usando i comandi \"/attiva\" e \"/disattiva\"");
|
||||
});
|
||||
|
||||
|
@ -205,11 +206,11 @@ function telegramBotRouter() {
|
|||
requireBotLogin($message);
|
||||
if(count(explode(" ", $message->text)) > 2) return;
|
||||
$available_users_count = $db->selectValue("SELECT COUNT(id) FROM `".DB_PREFIX."_profiles` WHERE `available` = 1 AND `hidden` = 0");
|
||||
if($available_users_count === 5) {
|
||||
if($available_users_count >= 5) {
|
||||
$message->reply("✅ Distaccamento operativo con squadra completa");
|
||||
} else if($available_users_count === 2) {
|
||||
} else if($available_users_count >= 2) {
|
||||
$message->reply("🧯 Distaccamento operativo per supporto");
|
||||
} else if($available_users_count === 1) {
|
||||
} else if($available_users_count >= 0) {
|
||||
$message->reply("⚠️ Distaccamento non operativo");
|
||||
}
|
||||
});
|
||||
|
|
|
@ -261,15 +261,16 @@ class Availability {
|
|||
$this->users = $users;
|
||||
}
|
||||
|
||||
public function change_manual_mode($manual_mode) {
|
||||
public function change_manual_mode($manual_mode, $user_id = null) {
|
||||
global $db, $users;
|
||||
if(is_null($user_id)) $user_id = $users->auth->getUserId();
|
||||
$db->update(
|
||||
DB_PREFIX."_profiles",
|
||||
[
|
||||
"manual_mode" => $manual_mode
|
||||
],
|
||||
[
|
||||
"id" => $users->auth->getUserId()
|
||||
"id" => $user_id
|
||||
]
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue