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:
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.
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…
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:
User, * 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.