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")
|
||||
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")
|
||||
|
||||
|
22
utils.go
22
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
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user