package main import ( "fmt" "log" "net/http" "time" "gitea.dmz.rs/txrpe/event-bot/chatbot" "github.com/apognu/gocal" ) func main() { resp, err := http.Get("https://dmz.rs/events.ical") if err != nil { // handle err // todo add log return } defer resp.Body.Close() cal := gocal.NewParser(resp.Body) start, end := time.Now(), time.Now().Add(24*time.Hour) cal.Start = &start cal.End = &end cal.Parse() if len(cal.Events) == 0 { // Maybe change this to some kind of logs fmt.Printf("No events today :(") return } e := cal.Events[0] message := fmt.Sprint("Veceras u decentrali:\n", e.Summary, "\n", e.URL, "\n", e.Location, " ", e.Start.Format(time.Kitchen)) nkbot, err := chatbot.NewEventBot() if err != nil { log.Fatal(err) } nkbot.SendMessage(message) }