update weather forecast
This commit is contained in:
parent
ec245d5ba5
commit
58d8d13888
24
job.go
24
job.go
@ -1350,18 +1350,30 @@ func jobGetHammerTime(j Job) {
|
|||||||
logOnError(err, "jobGetHammerTime : getMsgParsingRule")
|
logOnError(err, "jobGetHammerTime : getMsgParsingRule")
|
||||||
cwm, err := parseSubTypeMessageTimeAck(msg, rule.re)
|
cwm, err := parseSubTypeMessageTimeAck(msg, rule.re)
|
||||||
|
|
||||||
if (cwm.TimeOfDay == `🌞Morning` && cwm.Weather == `🌧`) || (cwm.TimeOfDay == `🌙Evening` && cwm.Weather == `🌤`) || (cwm.TimeOfDay == `🌙Night` && cwm.Weather == `☀`) {
|
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.`
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
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{
|
c := TGCommand{
|
||||||
Type: commandSendMsg,
|
Type: commandSendMsg,
|
||||||
Text: `Perfect weather for the next 2 hours.`,
|
Text: out,
|
||||||
ToChatID64: cfg.Bot.Mainchat,
|
ToChatID64: cfg.Bot.Mainchat,
|
||||||
ParseMode: cmdParseModeHTML,
|
ParseMode: cmdParseModeHTML,
|
||||||
}
|
}
|
||||||
TGCmdQueue <- c
|
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = setJobDone(j.ID64)
|
err = setJobDone(j.ID64)
|
||||||
logOnError(err, "jobGetHammerTime : setJobDone")
|
logOnError(err, "jobGetHammerTime : setJobDone")
|
||||||
|
22
utils.go
22
utils.go
@ -84,3 +84,25 @@ func RndInt64() int64 {
|
|||||||
RndMux.Unlock()
|
RndMux.Unlock()
|
||||||
return i
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user