feat: Implement timetable fetching in checkTimetableChangesForUser

This commit resolves the TODO in the `checkTimetableChangesForUser` function in `Botrun/BotStart.go`.

The new implementation fetches the user's timetable by calling the `Untis.Auth` and `Untis.Timetable` functions. It then compares the new timetable with the previous one and sends a notification if there are any changes.

As part of this change, the `Bot` directory was renamed to `Untis` to follow Go conventions, and the import paths were updated in `Botrun/BotStart.go` and `main.go`. The `.gitignore` file was also updated to ignore the build artifact.
This commit is contained in:
google-labs-jules[bot] 2025-10-20 02:17:00 +00:00
parent b76b2c72f1
commit 8b42761cf0
9 changed files with 19 additions and 6 deletions

4
.gitignore vendored
View file

@ -7,4 +7,6 @@ login.json
timetable*.json
timetableFilled*.json
accounts.json
login_*.json
login_*.json
untislogger
untislogger*

View file

@ -17,6 +17,7 @@ import (
"time"
"github.com/joho/godotenv"
"untislogger/Untis"
"github.com/bwmarrin/discordgo"
)
@ -178,14 +179,24 @@ func checkTimetableChangesForUser(user Account, decPwd string, s *discordgo.Sess
// Load previous timetable
prevData, _ := os.ReadFile(timetableFilledFile)
// TODO: Fetch new timetable for this user using user.Username and decrypted password
// For demonstration, we'll just copy prevData (replace this with real fetch logic!)
newData := prevData
// Fetch new timetable for this user
cookies, err := Untis.Auth(user.Username, decPwd, user.UserID)
if err != nil {
fmt.Printf("Error authenticating user %s: %v\n", user.Username, err)
return
}
Untis.Timetable(cookies, user.UserID)
// Load the newly fetched timetable data
newData, err := os.ReadFile(timetableFilledFile)
if err != nil {
fmt.Printf("Error reading new timetable for user %s: %v\n", user.Username, err)
return
}
// Compare and notify if changed
if !bytes.Equal(newData, prevData) {
sendLessonNotification(s, user.UserID, user.Username, "Your timetable has changed!")
os.WriteFile(timetableFilledFile, newData, 0644)
}
}

View file

@ -12,7 +12,7 @@ import (
"sort"
"syscall"
"time"
Untis "untislogger/Bot"
Untis "untislogger/Untis"
BotStart "untislogger/Botrun"