package main import ( "strconv" "strings" "time" ) // jeden ersten donnerstag und dritten dienstag func getNextTopic() topic { date := time.Now() var output topic for i := 0; i < 31; i++ { newDate := stringSplit(date.AddDate(0, 0, 1*i).Format(time.UnixDate), " ") if newDate[0] == "Thu" || newDate[0] == "Tue" { dayA, errA := strconv.Atoi(newDate[2]) errorPanic(errA) dayB, errB := strconv.Atoi(newDate[2]) errorPanic(errB) if ifFloatRange(float64(dayA)/7, 0, 1, false, true) || (ifFloatRange(float64(dayB)/7, 2, 3, false, true) && newDate[0] == "Tue") { output.date = date.AddDate(0, 0, 1*i).Format("02.01.2006") output.days = i break } } } return output } func getRoomState() status { var err error body := httpGetBody("https://status.ctdo.de/api/simple/v2") bodyString := string(body) temp := []string{} bodyString = strings.ReplaceAll(bodyString, "{", "") bodyString = strings.ReplaceAll(bodyString, "}", "") Temp := strings.Split(bodyString, ",") for _, element := range Temp { TEmp := strings.Split(element, ":") temp = append(temp, TEmp[1]) } roomState := new(status) roomState.state = temp[0] == "true" roomState.power, err = strconv.ParseInt(temp[2], 0, 64) errorPanic(err) return *roomState }