mIRC Home    About    Download    Register    News    Help

Print Thread
#133836 26/10/05 12:40 AM
Joined: Oct 2005
Posts: 28
G
gliX Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Oct 2005
Posts: 28
Found a snippet for an irc weatherbot via sockets. when i say -weather 22003 it says "Zip code not specified" for some reason. Or it says:

Quote:
* /elseif: invalid format (line 55, script.ini)
-
* /if: invalid format (line 55, script.ini)


Here's what was on line 55

Quote:
if (<A HREF="/" CLASS="breadCrumb">Home</a> > <B>Local Forecast for * (*)</b> iswm


Here's the snippet:

Quote:
on *:text:-weather *:#:{
set %weather.channel $chan
weather $2
}

alias weather {
if (!$1) {
msg %weather.channel No zip code specified.
unset %weather.channel
}
else {
if (!$regex($1,\d{5})) {
msg %weather.channel Incorrect zip code format.
unset %weather.channel
}
else {
if ($sock(weather)) sockclose weather
sockopen weather www.w3.weather.com 80
sockmark weather $1
}
}
}

alias -l nohtml { var %tmp, %ignore = $regsub($1-,/(<[^>]+>)/g,$chr(32),%tmp) | return

%tmp }

alias convert {
if ($1 == $null) return $null
else {
if ($1 !isnum) return $null
else {
if ($prop == f2c) return $round($calc(($1 - 32) * 5 / 9),1)
if ($prop == c2f) return $round($calc(($1 * 9 / 5) + 32),1)
if ($prop == m2k) return $round($calc($1 * 1.61),1)
if ($prop == k2m) return $round($calc($1 * (1 / 1.61)),1)
}
}
}

on *:sockopen:weather:{
var %zip = $sock($sockname).mark
sockwrite -n $sockname GET /weather/local/ $+ %zip HTTP/1.1
sockwrite -n $sockname Host: www.w3.weather.com
sockwrite -n $sockname Connection: keep-alive
sockwrite -n $sockname
}

on *:sockread:weather:{
if ($sockerr > 0) return
:nextread
sockread %temp
if ($sockbr == 0) return
if (%temp == $null) var %temp = -
if (<A HREF="/" CLASS="breadCrumb">Home</a> > <B>Local Forecast for * (*)</b> iswm

%temp) {
var %temp = $nohtml($gettok(%temp,8-,32))
sockmark $sockname $sock($sockname).mark $+ $chr(255) $+ $gettok(%temp,1,40)
}
if (<TD VALIGN=MIDDLE ALIGN=CENTER CLASS=obsInfo2 WIDTH=50%><B

CLASS=obsTempTextA>*°F</b></td></tr> iswm %temp) {
var %temp = $nohtml(%temp)
sockmark $sockname $sock($sockname).mark $+ $chr(255) $+ $gettok(%temp,1,38)
}
if (<TR><TD VALIGN=TOP ALIGN=CENTER CLASS=obsInfo2><B CLASS=obsTextA>*</b></td> iswm

%temp) {
sockmark $sockname $sock($sockname).mark $+ $chr(255) $+ $nohtml(%temp)
}
if (<TD VALIGN=TOP ALIGN=CENTER CLASS=obsInfo2> <B CLASS=obsTextA>Feels

Like<BR>*°F</b></td></tr> iswm %temp) {
var %temp = $nohtml(%temp)
sockmark $sockname $sock($sockname).mark $+ $chr(255) $+ $gettok(%temp,1,38)
}
if (%temp == <TR><TD ALIGN=LEFT VALIGN=TOP CLASS=obsInfo1>Humidity:</td>) {
sockread %temp
sockmark $sockname $sock($sockname).mark $+ $chr(255) $+ $nohtml(%temp)
}
if (%temp == <TR><TD ALIGN=LEFT VALIGN=TOP CLASS=obsInfo1>Visibility:</td>) {
sockread %temp
sockmark $sockname $sock($sockname).mark $+ $chr(255) $+ $nohtml(%temp)
}
if (%temp == <TR><TD ALIGN=LEFT VALIGN=TOP CLASS=obsInfo1>Wind:</td>) {
sockread %temp
sockmark $sockname $sock($sockname).mark $+ $chr(255) $+

$gettok($nohtml(%temp),1,38)
}
if (*reported at</a>* iswm %temp) {
sockmark $sockname $sock($sockname).mark $+ $chr(255) $+

$nohtml($gettok(%temp,9-,44))
}
if (%temp == </html>) {
tokenize 255 $sock($sockname).mark
msg %weather.channel [^B] $+ $2 $+ [^B] ( $+ $1 $+ ): $3 $+ $chr(176) $+ F/ $+

$convert($3).f2c $+ $chr(176) $+ C ( $+ $5 $+ $chr(176) $+ F/ $+

$convert($gettok($5,3,32)).f2c $+ $chr(176) $+ C) - [^B] $+ Condition $+ [^B]: $4 - [^B] $+

Humiditiy $+ [^B]: $6 - [^B] $+ Visibility $+ [^B]: $7 ( $+ $convert($gettok($7,1,32)).m2k $+ km)

- [^B] $+ Wind $+ [^B]: $8 (Last Updated: $9 $+ )
unset %weather.channel
sockclose $sockname
return
}
goto nextread
}


Any ideas on getting it to work? Thanks.

Last edited by gliX; 26/10/05 12:43 AM.
#133837 26/10/05 01:49 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Code:
if (&lt;A HREF="/" CLASS="breadCrumb"&gt;Home&lt;/a&gt; &gt; &lt;B&gt;Local Forecast for * (*)&lt;/b&gt; iswm 

%temp) { 

That should all be on one line:

Code:
if (&lt;A HREF="/" CLASS="breadCrumb"&gt;Home&lt;/a&gt; &gt; &lt;B&gt;Local Forecast for * (*)&lt;/b&gt; iswm %temp) { 


Also, there *appears* to be an extra > in there before the <B>... I'm not going to look through the site's source to find out, though.

Note that I have a nice weather script that I made as well -- http://www.arrowweb.com/jeremy/IRCWeather.html . Or, my main script page of http://www.KakkoiiTranslations.net/mircscripts/ .

I do need to make an update for it thanks to the website the data is from having changed their site a bit. But, I believe the only thing that isn't working right now is the wind direction.


Invision Support
#Invision on irc.irchighway.net
#133838 26/10/05 08:15 PM
Joined: Oct 2005
Posts: 28
G
gliX Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Oct 2005
Posts: 28
Good script, but it doesn't work properly. No matter what zip I entered in for !weather zip, it only showed the weather for Fort Belvoir, Virginia. Also, how can I change the font color? I opened the setup box and changed it to black but its still in green when i say !weather. Thanks

#133839 26/10/05 08:20 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Hm... someone else mentioned a problem, too. I'll see about reuploading it... maybe somehow an old copy got uploaded that didn't include the fixes for the new site... hmm...

As for changing the colors, that should work fine... I'll check that as well.


Invision Support
#Invision on irc.irchighway.net
#133840 26/10/05 09:10 PM
Joined: Oct 2005
Posts: 28
G
gliX Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Oct 2005
Posts: 28
ok thanks. just a suggestion, but u should try using weather.com

Last edited by gliX; 26/10/05 09:39 PM.
#133841 26/10/05 11:47 PM
Joined: Oct 2005
Posts: 28
G
gliX Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Oct 2005
Posts: 28
hmm its probably the site weatherunderground, cause whatever zip or city/state i enter it returns a different one

#133842 27/10/05 01:13 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
I didn't have a chance last night to look through it. I do know that it works fine on my bot and on a friend's bot.

Anyhow, I prefer weatherunderground for data. The site is much easier to deal with.


Invision Support
#Invision on irc.irchighway.net
#133843 27/10/05 08:19 PM
Joined: Oct 2005
Posts: 28
G
gliX Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Oct 2005
Posts: 28
i think weatherunderground doesnt have every zip code, they just use one area for many zip codes, so the weather it gives isnt very accurate. do u know where i can find a weather.com bot? by the way, i like ur dictionary bot its nice

Last edited by gliX; 27/10/05 08:23 PM.
#133844 27/10/05 08:44 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Heh... It's as accurate as a site that offers "every zip code". Where does weather data come from? Does every zip code have a weather station or an airport or some other location that gathers data? Of course not. Just because a site says the real city's name when looking up a zip code does not mean that it is getting data from that exact city. It gets the data from the closest place that has data. Sites that don't use the exact city name allow you to see exactly where the data is coming from. This allows you to see how far away the data is from where you're looking.

If that's all you were doing when you were getting the same weather data, was to look at all the zip codes in a small area, then it's normal. Try !weather 12345... You should get a place in New York.


Invision Support
#Invision on irc.irchighway.net
#133845 27/10/05 08:55 PM
Joined: Oct 2005
Posts: 28
G
gliX Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Oct 2005
Posts: 28
Well people in my channel tried about 10 zips from all of VA and it returned the fort bel. place

#133846 28/10/05 01:38 AM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
There are 35 locations in Virginia with weather data. If you want to see where they are, go to the web site and just search for Virginia. You'll see the list.


Invision Support
#Invision on irc.irchighway.net
#133847 28/10/05 01:57 AM
Joined: Oct 2005
Posts: 28
G
gliX Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Oct 2005
Posts: 28
I loaded the same script from a different site that uses weatherunderground and on that one the cityname works..so maybe u were right about uploading an old version..

#133848 28/10/05 12:52 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Ok. I'll repack and reupload the script tonight. You can verify that it does work by visiting the channel in my signature. The weather is from Slurms, so if you see that bot there, you can try it and see how it's working for you.


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard