Temp timezone fix #11

Merged
Jannover5000r merged 22 commits from temp-timezoneFix into main 2026-08-23 00:02:29 +02:00
Showing only changes of commit 3bf0158260 - Show all commits

72
main.go
View file

@ -222,20 +222,20 @@ func scheduleTimetableUpdate() {
changes = append(changes, fmt.Sprintf("Room changed for %s: %s → %s", subject, oldRoom, newRoom)) changes = append(changes, fmt.Sprintf("Room changed for %s: %s → %s", subject, oldRoom, newRoom))
} }
for _, e := range currentEntries { for _, e := range currentEntries {
key := lessonKey(e) key := lessonKey(e)
currMap[key] = e currMap[key] = e
// Create timeslot key (date + startTime + endTime) // Create timeslot key (date + startTime + endTime)
timeslotKey := e.Date + "|" + e.StartTime + "|" + e.EndTime timeslotKey := e.Date + "|" + e.StartTime + "|" + e.EndTime
currTimeslotMap[timeslotKey] = e currTimeslotMap[timeslotKey] = e
} }
for _, e := range prevEntries { for _, e := range prevEntries {
key := lessonKey(e) key := lessonKey(e)
prevMap[key] = e prevMap[key] = e
// Create timeslot key (date + startTime + endTime) // Create timeslot key (date + startTime + endTime)
timeslotKey := e.Date + "|" + e.StartTime + "|" + e.EndTime timeslotKey := e.Date + "|" + e.StartTime + "|" + e.EndTime
prevTimeslotMap[timeslotKey] = e prevTimeslotMap[timeslotKey] = e
} }
// Code/status change? // Code/status change?
if prev.Code != curr.Code { if prev.Code != curr.Code {
@ -615,31 +615,33 @@ func sendDiscordWebhook(subject string, room string, nextTime string, Status str
} }
func sendUpdateDiscordWebhookWithDetails(changes []string) { func sendUpdateDiscordWebhookWithDetails(changes []string) {
log.Println("Sending detailed Discord webhook notification...") if BotStart.WebHook {
log.Println("Sending detailed Discord webhook notification...")
message := "**Timetable Update**\n\n" + strings.Join(changes, "\n") message := "**Timetable Update**\n\n" + strings.Join(changes, "\n")
payload := DiscordWebhookPayload{ payload := DiscordWebhookPayload{
Content: message, Content: message,
} }
jsonData, err := json.Marshal(payload) jsonData, err := json.Marshal(payload)
if err != nil { if err != nil {
log.Printf("Error marshaling webhook payload: %v", err) log.Printf("Error marshaling webhook payload: %v", err)
return return
} }
resp, err := http.Post(discordWebhookURL, "application/json", bytes.NewBuffer(jsonData)) resp, err := http.Post(discordWebhookURL, "application/json", bytes.NewBuffer(jsonData))
if err != nil { if err != nil {
log.Printf("Error sending Discord webhook: %v", err) log.Printf("Error sending Discord webhook: %v", err)
return return
} }
defer resp.Body.Close() defer resp.Body.Close()
if resp.StatusCode >= 200 && resp.StatusCode < 300 { if resp.StatusCode >= 200 && resp.StatusCode < 300 {
log.Println("Detailed Discord webhook sent successfully") log.Println("Detailed Discord webhook sent successfully")
} else { } else {
body, _ := ioutil.ReadAll(resp.Body) body, _ := ioutil.ReadAll(resp.Body)
log.Printf("Discord webhook failed with status %d: %s", resp.StatusCode, string(body)) log.Printf("Discord webhook failed with status %d: %s", resp.StatusCode, string(body))
}
} }
} }