This commit is contained in:
Jannover5000r 2025-10-27 13:33:38 +01:00
parent fef2ec79b8
commit 573f8fff0a
2 changed files with 12 additions and 7 deletions

19
main.go
View file

@ -12,6 +12,7 @@ import (
"sort" "sort"
"syscall" "syscall"
"time" "time"
Untis "untislogger/Untis" Untis "untislogger/Untis"
BotStart "untislogger/Botrun" BotStart "untislogger/Botrun"
@ -52,9 +53,9 @@ func init() {
func main() { func main() {
godotenv.Load(".env") godotenv.Load(".env")
//Untis.Main() //starting API calls function| happens in schedule func // Untis.Main() //starting API calls function| happens in schedule func
//Run() // Run()
//Starts logging the timetable for each new Lesson and logs changes // Starts logging the timetable for each new Lesson and logs changes
go BotStart.Start() go BotStart.Start()
scheduleTimetableUpdate() scheduleTimetableUpdate()
@ -62,12 +63,13 @@ func main() {
signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM) signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)
log.Println("Program is running. Press Ctrl+C to stop.") log.Println("Program is running. Press Ctrl+C to stop.")
//Start logging // Start logging
//Run() // Run()
// Block until we receive a signal // Block until we receive a signal
<-sigChan <-sigChan
log.Println("Shutting down...") log.Println("Shutting down...")
} }
func scheduleTimetableUpdate() { func scheduleTimetableUpdate() {
prevData := make(map[string][]byte) prevData := make(map[string][]byte)
@ -219,6 +221,7 @@ func NextRoomForTime(roomByStartTime map[string]string, current string) (string,
} }
return "", "", false return "", "", false
} }
func NextSubjectForTime(subjectByStartTime map[string]string, current string) (string, bool) { func NextSubjectForTime(subjectByStartTime map[string]string, current string) (string, bool) {
layout := "15:04" layout := "15:04"
now, err := time.Parse(layout, current) now, err := time.Parse(layout, current)
@ -243,8 +246,8 @@ func NextSubjectForTime(subjectByStartTime map[string]string, current string) (s
} }
return "", false return "", false
} }
func NextCodeForTime(codeByStartTime map[string]string, current string) (string, bool) {
func NextCodeForTime(codeByStartTime map[string]string, current string) (string, bool) {
layout := "15:04" layout := "15:04"
now, err := time.Parse(layout, current) now, err := time.Parse(layout, current)
if err != nil { if err != nil {
@ -267,8 +270,8 @@ func NextCodeForTime(codeByStartTime map[string]string, current string) (string,
} }
} }
return "", false return "", false
} }
func MapTimeToRoom(path string) (map[string]string, error) { func MapTimeToRoom(path string) (map[string]string, error) {
data, err := os.ReadFile(path) data, err := os.ReadFile(path)
if err != nil { if err != nil {
@ -287,6 +290,7 @@ func MapTimeToRoom(path string) (map[string]string, error) {
} }
return roomByStartTime, nil return roomByStartTime, nil
} }
func MapTimeToCode(path string) (map[string]string, error) { func MapTimeToCode(path string) (map[string]string, error) {
data, err := os.ReadFile(path) data, err := os.ReadFile(path)
if err != nil { if err != nil {
@ -307,6 +311,7 @@ func MapTimeToCode(path string) (map[string]string, error) {
} }
return codeByStartTime, nil return codeByStartTime, nil
} }
func MapTimeToSubject(path string) (map[string]string, error) { func MapTimeToSubject(path string) (map[string]string, error) {
data, err := os.ReadFile(path) data, err := os.ReadFile(path)
if err != nil { if err != nil {

Binary file not shown.