weather.tcl

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…

  • Download weather.tcl

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.

Related posts:

  1. worldtime.tcl Sometimes you need to know the time somewhere else in...
  2. Universal Currency Converter TCL for Eggdrop This is a currency converter written in TCL for Eggdrop,...

4 Comments »

  1. Harold said,

    January 24, 2010 @ 10:47 pm

    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 said,

    January 27, 2010 @ 10:17 am

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

  3. hm2k said,

    January 28, 2010 @ 5:59 pm

    @Harold http://www.egghelp.org/enhance.htm#tclscripts

    @Will http://code.google.com/p/hm2k/source/diff?spec=svn115&r=115&format=side&path=/trunk/code/tcl/weather.tcl

  4. kuya said,

    July 4, 2010 @ 8:43 pm

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

RSS feed for comments on this post · TrackBack URL

Leave a Comment