Hmm...creasy wrote:There is also the issue of no results or multiple results found. In the 1st case the bot doesn't respond at all, while in the 2nd instead of a list of possible hits it returnsAny ideas on how to fix this?Code: Select all
High/Low: Unavailable; Wind: Calm
Code: Select all
if {[info exists html(tempf)] && [info exists html(tempc)]} {
set input [string map "{%w3%} {${alternate_sep}[ibold "Temperature:"] [i2fac $html(tempf) $html(tempc)]}" $input]
} else {
set input [string map "{%w3%} {}" $input]
}
Code: Select all
if {[info exists html(tempf)] && [info exists html(tempc)]} {
set input [string map "{%w3%} {${alternate_sep}[ibold "Temperature:"] [i2fac $html(tempc) $html(tempf)]}" $input]
} else {
set input [string map "{%w3%} {}" $input]
}
Code: Select all
regexp -nocase {"°(.*?)"} $html - deg
but the regexp doesn't match the correct line so you get that error.<span class="wx-data" data-station="KOHCLEVE26" data-variable="temperature">
<span class="wx-value">17.5</span>
<span class="wx-unit">°C</span>
</span>
So the best way to fix this is to replace:<bot> [07:06:56] incith:weather-2.9e: <cez/#foo> !weather 44118
<bot> [07:06:58] got temperature 17.5 F
Code: Select all
regexp -nocase {"temperature": (.*?),} $html - temp
regexp -nocase {<span class="wx-unit">°(.*?)</span>} $html - deg
Code: Select all
regexp -nocase {data-variable="temperature"><span class="wx-value">(.*?)</span><span class="wx-unit">°(.*?)</span>} $html - temp deg
Code: Select all
# TEMPERATURE
if {[regexp -nocase {data-variable="temperature">} $html]} {
regexp -nocase {"temperature": (.*?),} $html - temp
regexp -nocase {"°(.*?)"} $html - deg
putlog "got temperature $temp $deg"
if {[string match "*F*" $deg)]} {
set output(tempf) $temp
set output(tempc) [format "%.${incith::weather::granularity}f" [expr {5.0/9.0*($output(tempf) - 32.0)}]]
if {[string match *\.* $output(tempc)]} {
set c [split $output(tempc) .]
set ot1 [lindex $c 0]
set ot2 [string trim [lindex $c 1] " 0"]
if {[string length $ot2]} { set output(tempc) "${ot1}.${ot2}" } { set output(tempc) $ot1 }
}
} else {
set output(tempc) $temp
set output(tempf) [format "%.${incith::weather::granularity}f" [expr {9.0/5.0*$output(tempc) + 32.0}]]
if {[string match *\.* $output(tempf)]} {
set c [split $output(tempf) .]
set ot1 [lindex $c 0]
set ot2 [string trim [lindex $c 1] " 0"]
if {[string length $ot2]} { set output(tempf) "${ot1}.${ot2}" } { set output(tempf) $ot1 }
}
}
}
if {[info exists output(tempf)]} {
set templength [string length $output(tempf)]
if {$templength > 20} {
putlog "length fubar"
set output(error) "Something is fubar! :)"
return [array get output]
}
}
Code: Select all
# TEMPERATURE
if {[regexp -nocase {data-variable="temperature">} $html]} {
regexp -nocase {"temperature": (.*?),} $html - temp
regexp -nocase {"°(.*?)"} $html - deg
putlog "got temperature $temp $deg"
# temperature is in Fahrenheit
if {[string equal $deg "C"]} {
set output(tempf) $temp
set output(tempc) [format "%.1f" [expr {($temp - 32) / 1.8}]]
} else {
# temperature is in Celsius
set output(tempc) $temp
set output(tempf) [format "%.2f" [expr {$temp * 1.8 + 32 }]]
}
}
Code: Select all
[00:04:00] <~signz> !w
[00:04:02] <+Trump> Failed to connect.
Code: Select all
[00:02:26] <~signz> !tweet sorry4spam
[00:02:27] <%Trump> OAuth failed: (???) protocol not supported ( internal error )
[00:02:31] <~signz> !tweet sorry4spam
[00:02:31] <%Trump> OAuth failed: (???) protocol not supported ( internal error )
<insert rehash from partyline>
[00:03:11] <~signz> !tweet sorry4spam
[00:03:12] <%Trump> Tweet created: http://twitter.com/newdsrp ( 747188448499474433@newdsrp - 1s ago via #level )
[00:04:00] <~signz> !w
[00:04:02] <+Trump> Failed to connect.
[00:04:06] <~signz> !tweet sorry4spam!
[00:04:07] <%Trump> OAuth failed: (???) protocol not supported ( internal error )
[00:04:19] <~signz> .crehash
[00:04:19] -Trump- Rehashing ... -= DONE =-
[00:04:21] <~signz> !tweet sorry4spam!
[00:04:23] <%Trump> Tweet created: http://twitter.com/newdsrp ( 747188743669485570@newdsrp - 0s ago via #level )
Sorry, creasy. I'm just now getting back to this. Yes, it turns out that I really am having the same issue with the 'High/Low' field. Unavailable. I'm not sure what I was looking at when I first responded to this. I'm surprised that nobody else mentioned this.creasy wrote:There is also the issue of no results or multiple results found. In the 1st case the bot doesn't respond at all, while in the 2nd instead of a list of possible hits it returnsAny ideas on how to fix this?Code: Select all
High/Low: Unavailable; Wind: Calm