This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

incith:weather (2.8p) (Dec. 18th, 2008)

Support & discussion of released scripts, and announcements of new releases.
Post Reply
m
mtnvortest
Voice
Posts: 6
Joined: Fri Mar 04, 2016 11:43 am

Post by mtnvortest »

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.
s
simboy1234
Voice
Posts: 5
Joined: Sat May 16, 2015 2:06 pm

Post by simboy1234 »

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.
m
mtnvortest
Voice
Posts: 6
Joined: Fri Mar 04, 2016 11:43 am

Post by mtnvortest »

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: Select all

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.
c
creasy
Voice
Posts: 24
Joined: Sat Mar 05, 2016 4:21 am

Post by creasy »

What responses do you get in those cases?
r
rjpearce
Voice
Posts: 5
Joined: Mon Mar 27, 2006 8:36 am

Post by rjpearce »

A big thank you to everyone who is contributing to keeping this script going.

To try and help the community I have setup a Github repository so we can track changes and get patches much more easily. It might also be helpful for tracking issues: https://github.com/rjpearce/incith-weather

I have rolled up the recent patches and added them under a new release 2.9e. https://github.com/rjpearce/incith-weat ... s/tag/2.9e

The original 2.9d can be found here:
https://github.com/rjpearce/incith-weat ... s/tag/2.9d

I will be contacting incith directly and asking for his blessing.

More than happy to give anyone direct push access, just ping me on Github.
d
daffodil
Voice
Posts: 3
Joined: Sun May 29, 2016 1:51 pm
Location: Cleveland, Ohio, USA

Thanks!!! First weather script that works :)

Post by daffodil »

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
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

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.
d
daffodil
Voice
Posts: 3
Joined: Sun May 29, 2016 1:51 pm
Location: Cleveland, Ohio, USA

Post by daffodil »

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).
S
SignZ
Voice
Posts: 18
Joined: Thu Jun 17, 2010 3:52 pm

Post by SignZ »

Just had the same problem, simply fixed it by changing something in this part:

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]
        }
to:

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]
        }
d
daffodil
Voice
Posts: 3
Joined: Sun May 29, 2016 1:51 pm
Location: Cleveland, Ohio, USA

Post by daffodil »

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.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

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: Select all

regexp -nocase {"°(.*?)"} $html - deg
cos the site serves me temperature is in C:
<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.
<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: Select all

regexp -nocase {"temperature": (.*?),} $html - temp
regexp -nocase {<span class="wx-unit">°(.*?)</span>} $html - deg
with:

Code: Select all

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: 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]
        }
      }
but, if the end result was to have xx.x°C and xx.xx°F then this can be simplified a lot with:

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 }]]
		}
	}
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.
S
SignZ
Voice
Posts: 18
Joined: Thu Jun 17, 2010 3:52 pm

Post by SignZ »

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: Select all

[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: 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 )
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).
m
mtnvortest
Voice
Posts: 6
Joined: Fri Mar 04, 2016 11:43 am

Post by mtnvortest »

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: Select all

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.
p
planetb
Voice
Posts: 6
Joined: Fri Jan 21, 2011 7:10 pm

Post by planetb »

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.
s
simboy1234
Voice
Posts: 5
Joined: Sat May 16, 2015 2:06 pm

Post by simboy1234 »

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
Post Reply