| View previous topic :: View next topic |
| Author |
Message |
mtnvortest Voice
Joined: 04 Mar 2016 Posts: 6
|
Posted: Thu Mar 24, 2016 4:46 pm Post subject: |
|
|
Yeah, they switched it back to https.
After taking another look at creasy's previous post, I found that I did not have the third line of code set correctly in the script...the SSL settings under the browser.
Thanks, creasy. |
|
| Back to top |
|
 |
simboy1234 Voice
Joined: 16 May 2015 Posts: 5
|
Posted: Tue Mar 29, 2016 4:07 pm Post subject: |
|
|
after installing tcltls-devel package : input from mtnvortest
changing http to https : input from shadrach
adding SSL settings under browser : input from creasy
and adding the below 2 lines to the begining of the scripts
package require http
package require tls
it works fine now. |
|
| Back to top |
|
 |
mtnvortest Voice
Joined: 04 Mar 2016 Posts: 6
|
Posted: Sat Apr 09, 2016 11:59 pm Post subject: |
|
|
| 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 returns
| Code: | | High/Low: Unavailable; Wind: Calm |
Any ideas on how to fix this? |
Hmm...
Sorry creasy, I don't seem to be experiencing this same issue. If I do, and think of something to fix it, I will surely let you know. |
|
| Back to top |
|
 |
creasy Voice
Joined: 05 Mar 2016 Posts: 24
|
Posted: Sun Apr 10, 2016 3:39 am Post subject: |
|
|
| What responses do you get in those cases? |
|
| Back to top |
|
 |
rjpearce Voice
Joined: 27 Mar 2006 Posts: 5
|
|
| Back to top |
|
 |
daffodil Voice
Joined: 29 May 2016 Posts: 3 Location: Cleveland, Ohio, USA
|
Posted: Sun May 29, 2016 1:55 pm Post subject: Thanks!!! First weather script that works :) |
|
|
Congrats on making (or updating as the case may be) the first weather script for eggdrops that I've gotten to work in the last few days!
I am not sure if these are current bugs or not but thought I would share anyway:
1. Current weather returns a number showing as degrees Fahrenheit but looks like it is actually degrees Celsius, then because that number thought to be F is converted to C, it ends up even lower, thus showing a cold forecast when there isn't. I'm trying to locate the problem in the script but I don't know TCL. Humidity is correct.
2. Forecast doesn't work for USA locations but seems to work fine for others. Showing accurate temperatures and units.
I am excited to have finally found a weather script that works. Hope we can make it even better!
daffodil |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Sun May 29, 2016 2:25 pm Post subject: |
|
|
In DCC Chat/Telnet with the bot when issuing a forecast is should show you there a line like 'got temperature x C/F' or something similar. What's the x value compared to the output in the channel? _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
daffodil Voice
Joined: 29 May 2016 Posts: 3 Location: Cleveland, Ohio, USA
|
Posted: Sun May 29, 2016 2:26 pm Post subject: |
|
|
| They are the same. It said 26.2 F in telnet and 26.2 F on IRC but it is more like 26.2 C here (or it was this morning). |
|
| Back to top |
|
 |
SignZ Voice
Joined: 17 Jun 2010 Posts: 18
|
Posted: Mon May 30, 2016 3:51 pm Post subject: |
|
|
Just had the same problem, simply fixed it by changing something in this part:
| Code: |
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]
}
|
to:
| Code: |
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]
}
|
|
|
| Back to top |
|
 |
daffodil Voice
Joined: 29 May 2016 Posts: 3 Location: Cleveland, Ohio, USA
|
Posted: Mon May 30, 2016 6:19 pm Post subject: |
|
|
SignZ,
Tried that but no dice. Got this output:
daffodil !weather 44118
daffy-bot daffodil's weather request; Cleveland, Ohio (41.50445938/-81.54995728); Local Time: 6:16 PM (May 30, 2016); Updated: 17 seconds ago; Conditions: cld; Temperature: -2.8°F (26.9°C); Feels-like: 27°F (-2.8°C); High/Low: Unavailable; Humidity: 43%; Wind: East at 0.9 MPH (1.4 KPH)
All it did was swap location of the numbers and while 26.9 C is the real temp at the moment, the F number is WAY off. So it fixed one thing but made the other even more off than it was.
I wonder why current weather doesn't work but forecast is spot on. |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Tue May 31, 2016 1:12 am Post subject: |
|
|
Actually no. If you want to change from default xx°F (xx°C) to xx°C (xx°F) then just change the variable celcius_first to 1.
The culprit for your problem is:
| Code: |
regexp -nocase {"°(.*?)"} $html - deg
|
cos the site serves me temperature is in C:
| Quote: |
<span class="wx-data" data-station="KOHCLEVE26" data-variable="temperature">
<span class="wx-value">17.5</span>
<span class="wx-unit">°C</span>
</span>
|
but the regexp doesn't match the correct line so you get that error.
| Quote: |
<bot> [07:06:56] incith:weather-2.9e: <cez/#foo> !weather 44118
<bot> [07:06:58] got temperature 17.5 F
|
So the best way to fix this is to replace:
| Code: |
regexp -nocase {"temperature": (.*?),} $html - temp
regexp -nocase {<span class="wx-unit">°(.*?)</span>} $html - deg
|
with:
| Code: |
regexp -nocase {data-variable="temperature"><span class="wx-value">(.*?)</span><span class="wx-unit">°(.*?)</span>} $html - temp deg
|
I honestly don't understand what the author wanted to achieve here:
| Code: |
# 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]
}
}
|
but, if the end result was to have xx.x°C and xx.xx°F then this can be simplified a lot with:
| Code: |
# 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 }]]
}
}
|
and so on with the others (feels like, dew point and so on). The only downside is that I didn't take granularity into consideration, but seems to be a useless variable anyway since I wanted anyway to see xx.x°C and xx.xx°F. _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
SignZ Voice
Joined: 17 Jun 2010 Posts: 18
|
Posted: Sun Jun 26, 2016 6:10 pm Post subject: |
|
|
Really weird things happening..
First (100% related), whenever I try using the script (the modified one by rjpearce), I get a "Failed to connect" error, as can be seen here:
| Code: | [00:04:00] <~signz> !w
[00:04:02] <+Trump> Failed to connect. |
There's absolutely nothing in my logs though, so I'm not really sure what's happening (or rather not happening).
Secondly (about 50% related to this script and 50% to speechy's twitter script):
| Code: | [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 ) |
Not only does the weather script not seem to work, it also kinda breaks speechy's twitter script (at least for me, for some reason). |
|
| Back to top |
|
 |
mtnvortest Voice
Joined: 04 Mar 2016 Posts: 6
|
Posted: Tue Aug 16, 2016 5:27 pm Post subject: |
|
|
| 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 returns
| Code: | | High/Low: Unavailable; Wind: Calm |
Any ideas on how to fix this? |
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. |
|
| Back to top |
|
 |
planetb Voice
Joined: 21 Jan 2011 Posts: 6
|
Posted: Sun May 21, 2017 11:29 am Post subject: |
|
|
| Looks like the last released version broke sometime recently. I have not done any troubleshooting yet, but maybe this afternoon If I get some time. |
|
| Back to top |
|
 |
simboy1234 Voice
Joined: 16 May 2015 Posts: 5
|
Posted: Tue May 23, 2017 5:22 am Post subject: |
|
|
Yes seems to be broken
.[12:17:20] incith:weather-2.9c: <Simboy/#pwn> !weather doha, qatar
[12:17:22] got temperature 37.6 F
[12:17:22] Tcl error [incith::weather::weather_handler]: can't read "cond": no such variable |
|
| Back to top |
|
 |
|