diff --git a/job.go b/job.go index f007286..af0def0 100644 --- a/job.go +++ b/job.go @@ -1350,19 +1350,31 @@ func jobGetHammerTime(j Job) { logOnError(err, "jobGetHammerTime : getMsgParsingRule") cwm, err := parseSubTypeMessageTimeAck(msg, rule.re) - if (cwm.TimeOfDay == `🌞Morning` && cwm.Weather == `🌧`) || (cwm.TimeOfDay == `🌙Evening` && cwm.Weather == `🌤`) || (cwm.TimeOfDay == `🌙Night` && cwm.Weather == `☀`) { - c := TGCommand{ - Type: commandSendMsg, - Text: `Perfect weather for the next 2 hours.`, - ToChatID64: cfg.Bot.Mainchat, - ParseMode: cmdParseModeHTML, + out := `` + if hammerTimeNow(cwm.TimeOfDay, cwm.Weather) { + if hammerTimeNext(cwm.TimeOfDay, cwm.WeatherNext) || + hammerTimeNext(cwm.TimeOfDay, cwm.Weather) { + out = `Perfect weather for the next 2 hours, possibly 4.` + } else { + out = `Perfect weather only for the next 2 hours.` } - TGCmdQueue <- c - fmt.Printf("Perfect weather for the next 2 hours : %s / %s\n", cwm.TimeOfDay, cwm.Weather) } else { - fmt.Printf("Poor weather for the next 2 hours : %s / %s\n", cwm.TimeOfDay, cwm.Weather) + if hammerTimeNext(cwm.TimeOfDay, cwm.WeatherNext) || + hammerTimeNext(cwm.TimeOfDay, cwm.Weather) { + out = `Perfect weather maybe in 2 hours.` + } else { + out = `No perfect weather in sight for the next 4 hours.` + } } + c := TGCommand{ + Type: commandSendMsg, + Text: out, + ToChatID64: cfg.Bot.Mainchat, + ParseMode: cmdParseModeHTML, + } + TGCmdQueue <- c + err = setJobDone(j.ID64) logOnError(err, "jobGetHammerTime : setJobDone") diff --git a/utils.go b/utils.go index 996399e..c4182a1 100644 --- a/utils.go +++ b/utils.go @@ -84,3 +84,25 @@ func RndInt64() int64 { RndMux.Unlock() return i } + +func hammerTimeNow(time string, weather string) bool { + if time == `🌞Morning` && weather == `🌧` || + time == `🌙Evening` && weather == `🌤` || + time == `🌙Night` && weather == `☀` { + return true + } else { + return false + } + +} + +func hammerTimeNext(time string, weather string) bool { + if time == `🌙Night` && weather == `🌧` || + time == `🌞Day` && weather == `🌤` || + time == `🌙Evening` && weather == `☀` { + return true + } else { + return false + } + +}