works? #5
1 changed files with 14 additions and 3 deletions
17
main.go
17
main.go
|
|
@ -70,6 +70,17 @@ func main() {
|
||||||
log.Println("Shutting down...")
|
log.Println("Shutting down...")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isScheduledTime(now time.Time) bool {
|
||||||
|
scheduled := []string{"07:45", "08:35", "09:35", "10:25", "11:25", "12:15", "13:45", "14:25"}
|
||||||
|
current := now.Format("15:04")
|
||||||
|
for _, t := range scheduled {
|
||||||
|
if t == current {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func scheduleTimetableUpdate() {
|
func scheduleTimetableUpdate() {
|
||||||
prevData := make(map[string][]byte)
|
prevData := make(map[string][]byte)
|
||||||
|
|
||||||
|
|
@ -100,7 +111,7 @@ func scheduleTimetableUpdate() {
|
||||||
// Check for changes
|
// Check for changes
|
||||||
timetableFile := fmt.Sprintf("timetableFilled_%s.json", acc.UserID)
|
timetableFile := fmt.Sprintf("timetableFilled_%s.json", acc.UserID)
|
||||||
if acc.UserID == "default" {
|
if acc.UserID == "default" {
|
||||||
timetableFile = "timetableFilled.json"
|
timetableFile = "timetableFilled_default.json"
|
||||||
}
|
}
|
||||||
data, err := os.ReadFile(timetableFile)
|
data, err := os.ReadFile(timetableFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -150,8 +161,8 @@ func scheduleTimetableUpdate() {
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
func Run(userID string, forTime string) {
|
func Run(userID string) {
|
||||||
timetableFile := "timetableFilled.json"
|
timetableFile := "timetableFilled_default.json"
|
||||||
if userID != "default" {
|
if userID != "default" {
|
||||||
timetableFile = fmt.Sprintf("timetableFilled_%s.json", userID)
|
timetableFile = fmt.Sprintf("timetableFilled_%s.json", userID)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue