weather.tcl

Update: This script is now part of the eggtcl project.

Today, after I decided to hang out in #eggtcl on EFnet, someone asked the following:

<daILLeST> anyine know of a weather tcl that actually works? All the ones I find are outdated, or in another language…

I decided it was time that I updated my old weather.tcl based on a script by Ycarus for eggdrop bots.

Before, many scripts used weather underground (wunderground.com) to gather their feed.

I believe this is because there were many existing TCL based software that used this site to gather their data via telnet.

Telnet access to their server stopped working correctly, so scripts began using their http site to gather data. This too eventually stopped working as once they changed their site, the scripts could no longer parse the html for the data.

Enter Google.

Google has a weather API that they use for their “iGoogle“, which is very handy.

Although it appears to be undocumented by Google, working with the API is easy enough…

http://www.google.com/ig/api?weather=london&hl=en

The query string contains a “weather” parameter, which is generally city or postcode and the “hl” parameter which is the language.

This will return an XML formatted result for the city of “London, England”.

We can then parse the data we want from this and return it accordingly.

So, put it all together, a bit of TCL care (get it?), and we’re done…

It works well, and returns a result similar to this:

> .wz london
<Bot> HM2K, * Weather: London, England: Mostly Cloudy, 8ºC Humidity: 87% Wind: W at 9 mph

Hope you find this useful.

What I may do next time…

Since Google’s Weather API is completely officially undocumented it’s worth noting that in future it may be wise to use Yahoo’s weather API, which is fully and officially documented.

About admin

Website Administrator
This entry was posted in Internet and tagged , , , , , , . Bookmark the permalink.

8 Responses to weather.tcl

  1. Harold says:

    i’m looking for instructions on installing weather.tcl to eggdrop and other tcls such as weather426.tcl . i’m new to this here and wanting to learn how.
    any instruction cmds will be appricated

  2. Wil says:

    There is no way to have it said in fahrenheit and not celcius?

  3. kuya says:

    set wz(temp) “C”; # temperature scale [C/F]
    very simple to change from C to F

  4. nev says:

    How does it display C + F ?

  5. krash says:

    i’m told
    Unknown option -urlencoding, must be: -accept, -proxyfilter, -proxyhost, -proxyport, -useragent when trynig .wz city. what s

  6. michiel says:

    How do i go about this tcllib on windows?

    I tried just adding htmlparse in my scripts but that needs stack struct cmdline, but i wouldnt know where to put them since i cant load those.

    I’m at a dead end it seems.

  7. michiel says:

    apparantly you can fix that by putting the directories of the needed modules in /lib/tcl8.5/

    but it doesnt respond and i don’t see any logs of it

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>