chore: build

This commit is contained in:
2026-06-12 13:33:07 +02:00
parent 20da2a560f
commit 7f09400e79
8 changed files with 18 additions and 181 deletions
+16 -22
View File
@@ -9,6 +9,18 @@ import (
"time"
)
// sendTelegramNotif envoie via le bot principal, puis lbtelegram (BOT1/BOT2) en fallback.
func sendTelegramNotif(chatID int64, text string) {
if err := services.TelegramBot.SendMessage(chatID, text); err != nil {
log.Printf("⚠️ [NOTIF] bot principal échoué: %v — fallback lbtelegram", err)
if services.LBTelegram != nil && services.LBTelegram.IsConfigured() {
if err2 := services.LBTelegram.SendNotification(chatID, text); err2 != nil {
log.Printf("⚠️ [NOTIF] lbtelegram aussi échoué: %v", err2)
}
}
}
}
func (d *Database) NotifyClient(username string, commandID int, notifType, message string) error {
notifKey := fmt.Sprintf("notifications:%s", username)
@@ -26,11 +38,7 @@ func (d *Database) NotifyClient(username string, commandID int, notifType, messa
if services.TelegramBot != nil && services.TelegramBot.IsNotificationsEnabled() {
if chatID, ok, err := d.GetClientTelegramChatID(username); err == nil && ok {
go func(id int64, msg string) {
if err := services.TelegramBot.SendNotif(id, fmt.Sprintf("🔔 <b>Notification</b>\n\n%s", msg)); err != nil {
log.Printf("⚠️ [NOTIF] notification client échouée pour %s: %v", username, err)
}
}(chatID, message)
go sendTelegramNotif(chatID, fmt.Sprintf("🔔 <b>Notification</b>\n\n%s", message))
}
}
@@ -56,11 +64,7 @@ func (d *Database) NotifyLivreur(username string, commandID int, notifType, mess
if services.TelegramBot != nil && services.TelegramBot.IsNotificationsEnabled() {
if chatID, ok, err := d.GetUserTelegramChatID(username); err == nil && ok {
go func(id int64, msg string) {
if err := services.TelegramBot.SendNotif(id, fmt.Sprintf("🔔 <b>Notification</b>\n\n%s", msg)); err != nil {
log.Printf("⚠️ [NOTIF] notification livreur échouée pour %s: %v", username, err)
}
}(chatID, message)
go sendTelegramNotif(chatID, fmt.Sprintf("🔔 <b>Notification</b>\n\n%s", message))
}
}
@@ -98,12 +102,7 @@ func (d *Database) NotifyAllAdminCabine(commandID int, clientUsername, deliveryA
if services.TelegramBot != nil && services.TelegramBot.IsNotificationsEnabled() {
if chatID, ok, err := d.GetUserTelegramChatID(u.Username); err == nil && ok {
capturedChatID := chatID
capturedMsg := msg
go func(id int64, m string) {
if err := services.TelegramBot.SendNotif(id, fmt.Sprintf("🔔 <b>Nouvelle commande</b>\n\n%s", m)); err != nil {
log.Printf("⚠️ [NOTIF] notification admin/cabine échouée: %v", err)
}
}(capturedChatID, capturedMsg)
go sendTelegramNotif(capturedChatID, fmt.Sprintf("🔔 <b>Nouvelle commande</b>\n\n%s", msg))
}
}
count++
@@ -141,12 +140,7 @@ func (d *Database) NotifyAllAdminCabineAlert(alertID int, livreurUsername, alert
if services.TelegramBot != nil && services.TelegramBot.IsNotificationsEnabled() {
if chatID, ok, err := d.GetUserTelegramChatID(u.Username); err == nil && ok {
capturedChatID := chatID
capturedBody := body
go func(id int64, m string) {
if err := services.TelegramBot.SendNotif(id, fmt.Sprintf("🚨 <b>Alerte livreur</b>\n\n%s", m)); err != nil {
log.Printf("⚠️ [NOTIF] notification alerte échouée: %v", err)
}
}(capturedChatID, capturedBody)
go sendTelegramNotif(capturedChatID, fmt.Sprintf("🚨 <b>Alerte livreur</b>\n\n%s", body))
}
}
count++