matrix-development-lauge/main.go

50 lines
1020 B
Go
Executable File

package main
import (
"log"
"strings"
"time"
_ "github.com/mattn/go-sqlite3"
"roese.dev/matrix-development-lauge/modules/config"
"roese.dev/matrix-development-lauge/modules/database"
"roese.dev/matrix-development-lauge/pages"
)
func init() {
config.LoadConfig()
database.InitDatabase()
}
func main() {
ticker := time.NewTicker(time.Minute)
cfg := config.Cfg
for _ = range ticker.C {
dt := time.Now()
hour := dt.Format("15")
minute := dt.Format("04")
for _, page := range cfg.Pages {
for _, updateTime := range page.UpdateTime {
updateTimeSplit := strings.Split(updateTime, ":")
if page.Page == "school" {
if hour == updateTimeSplit[0] && minute == updateTimeSplit[1] {
pages.School()
log.Println("request", page.Page, updateTime, dt)
}
} else if page.Page == "melsungen" {
if hour == updateTimeSplit[0] && minute == updateTimeSplit[1] {
pages.MelsungenNews()
log.Println("request", page.Page, updateTime, dt)
}
}
}
}
}
}