quiet hours
This commit is contained in:
21
main.go
21
main.go
@ -76,7 +76,28 @@ func getRandomReminderMessage(task Task) string {
|
|||||||
return fmt.Sprintf(reminderMessages[randomIndex], task.Content)
|
return fmt.Sprintf(reminderMessages[randomIndex], task.Content)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isQuietHours() bool {
|
||||||
|
// Get current time in CET timezone
|
||||||
|
cet, err := time.LoadLocation("Europe/Paris") // Paris is in CET
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Ошибка загрузки таймзоны:", err)
|
||||||
|
return false // If we can't determine the time, assume it's not quiet hours
|
||||||
|
}
|
||||||
|
|
||||||
|
now := time.Now().In(cet)
|
||||||
|
hour := now.Hour()
|
||||||
|
|
||||||
|
// Quiet hours are from 23:00 to 08:00
|
||||||
|
return hour >= 23 || hour < 8
|
||||||
|
}
|
||||||
|
|
||||||
func spamCheck() {
|
func spamCheck() {
|
||||||
|
// Don't send messages during quiet hours
|
||||||
|
if isQuietHours() {
|
||||||
|
log.Println("[INFO] Тихий час (23:00-08:00 CET). Уведомления отключены.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
tasks := getOverdueTasks()
|
tasks := getOverdueTasks()
|
||||||
for _, task := range tasks {
|
for _, task := range tasks {
|
||||||
if !overdueTasks[task.ID] {
|
if !overdueTasks[task.ID] {
|
||||||
|
|||||||
Reference in New Issue
Block a user