update weather forecast
This commit is contained in:
parent
ec245d5ba5
commit
58d8d13888
30
job.go
30
job.go
@ -1350,19 +1350,31 @@ 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 := ``
|
||||||
c := TGCommand{
|
if hammerTimeNow(cwm.TimeOfDay, cwm.Weather) {
|
||||||
Type: commandSendMsg,
|
if hammerTimeNext(cwm.TimeOfDay, cwm.WeatherNext) ||
|
||||||
Text: `Perfect weather for the next 2 hours.`,
|
hammerTimeNext(cwm.TimeOfDay, cwm.Weather) {
|
||||||
ToChatID64: cfg.Bot.Mainchat,
|
out = `Perfect weather for the next 2 hours, possibly 4.`
|
||||||
ParseMode: cmdParseModeHTML,
|
} 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 {
|
} 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)
|
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