<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forum.eggheads.org/app.php/feed/topic/18008" />

	<title>egghelp/eggheads community</title>
	<subtitle>Discussion of eggdrop bots, shell accounts and tcl scripts.</subtitle>
	<link href="https://forum.eggheads.org/index.php" />
	<updated>2010-09-19T11:12:14-04:00</updated>

	<author><name><![CDATA[egghelp/eggheads community]]></name></author>
	<id>https://forum.eggheads.org/app.php/feed/topic/18008</id>

		<entry>
		<author><name><![CDATA[Torrevado]]></name></author>
		<updated>2010-09-19T11:12:14-04:00</updated>

		<published>2010-09-19T11:12:14-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=94445#p94445</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=94445#p94445"/>
		<title type="html"><![CDATA[world time / weather tcl Requests]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=94445#p94445"><![CDATA[
You should try <a href="http://hm2k.googlecode.com/svn/trunk/code/tcl/weather.tcl" class="postlink">weather</a> and <a href="http://hm2k.googlecode.com/svn/trunk/code/tcl/worldtime.tcl" class="postlink">worldtime</a> tcl's by hm2k<br><br><br>Weather:<div class="codebox"><p>Code: </p><pre><code># weather.tcl -- 2.0.3##   Returns the current weather for the city or postcode using the iGoogle#    API for weather.## Copyright (c) 2010 HM2K## Name: Weather Lookup# Author: HM2K &lt;irc@hm2k.org&gt;# License: http://www.freebsd.org/copyright/freebsd-license.html# Link: http://www.hm2k.com/posts/weather-tcl# Tags: weather, lookup, google, api# Updated: 02-Jun-2010####Usage# &gt; .wz london# &lt;Bot&gt; HM2K, * Weather: London, England: Mostly Cloudy, 8ºC Humidity: 87% Wind:#        W at 9 mph####Revisions# 2.0.3 - better requirement checking and better file header# 2.0.2 - now returns temperature in C or F, depending on what you define.# 2.0.1 - fixed weather.tcl $info(problem) -&gt; $data(problem) (tnx Pixelz)# 2.0   - a complete rewrite using google's api to gather the weather info# 1.x   - based on a script by Ycarus####Todo# 2.1 Switch to Yahoo's Weather API### Settingsset wz(ver) "2.0.3"; #current version of this fileset wz(lang) "en"; #languageset wz(cmd) ".wz"; #public command triggerset wz(dcccmd) "wz"; #dcc command triggerset wz(prefix) "* Weather:"; #output prefixset wz(temp) "C"; # temperature scale [C/F]set wz(output) "\002%s:\002 %s, %sº$wz(temp) %s %s"; #format for the outputset wz(problem) "Problem:";set wz(errormsg) "Error: No information could be found for";set wz(usage) "Usage: $wz(cmd) &lt;city|postcode,country&gt;";set wz(ua) "MSIE 6.0"; #simulate a browser's user agent, ie: Mozillaset wz(url) "http://www.google.com/ig/api"; #url### Package Definitionpackage require eggdrop 1.6;  #see http://geteggdrop.com/package require Tcl 8.2.3;    #see http://tinyurl.com/6kvu2nif {[catch {package require html} err]} {  putlog "[info script] error: $err";  putlog "[info script] error: http is required, see http://wiki.tcl.tk/1475";}if {[catch {package require htmlparse} err]} {  putlog "[info script] error: $err";  putlog "[info script] error: Tcllib is required, see http://wiki.tcl.tk/12099";}### Bindsbind pub - $wz(cmd) pub:wz;bind dcc -|- $wz(dcccmd) dcc:wz;### Proceduresproc pub:wz { nick uhost handle channel arg } {global wz;set arg [split $arg];if {[llength $arg]==0} { putserv "NOTICE $nick :$wz(usage)"; return; }set result [wz:get $arg];putserv "PRIVMSG $channel :$nick, $wz(prefix) $result";}proc dcc:wz {ha idx arg} {  global wz;  set arg [split $arg];if {[llength $arg]==0} { putdcc $idx $wz(usage); return; }set result [wz:get $arg];  putdcc $idx $result; }proc wz:get { arg } {  global wz;  set query [::http::formatQuery weather $arg hl $wz(lang)];  #set url [format $wz(url) $arg $wz(lang)];    set http [::http::config -useragent $wz(ua) -urlencoding "utf-8"];  set http [::http::geturl $wz(url)?$query];  set data [::http::data $http];  set data [::htmlparse::mapEscapes $data];  #set data [wz:parse $data "forecast_information"][wz:parse $data "current_conditions"];    if {[string tolower $wz(temp)] == "f"} {    set temp "temp_f";  } else {    set temp "temp_c";  }    set info(city) [wz:parsedata $data city];  set info(condition) [wz:parsedata $data condition];  set info(temp) [wz:parsedata $data $temp];  set info(humidity) [wz:parsedata $data humidity];  set info(wind) [wz:parsedata $data wind_condition];  set info(problem) [wz:parsedata $data problem_cause];    if {([info exists info(problem)]) &amp;&amp; ($info(problem) ne "")} {    return "$wz(problem) $info(problem)";  }  if {([info exists info(city)]) &amp;&amp; ($info(city) == "")} {    return "$wz(errormsg) $arg";  }  return [format $wz(output) $info(city) $info(condition) $info(temp) $info(humidity) $info(wind)];}proc wz:parse { data arg } {  set arg [string tolower $arg];  set matched "";  set result "";  regexp "&lt;$arg&gt;(.+?)&lt;/$arg&gt;" $data matched result;  return $result;}proc wz:parsedata { data arg } {  set arg [string tolower $arg];  set matched "";  set result "";  regexp "&lt;$arg data=\"(\[^\"\]+)\"/&gt;" $data matched result;  return $result;}### Loadedputlog "weather.tcl $wz(ver) loaded";#EOF</code></pre></div>Worldtime:<div class="codebox"><p>Code: </p><pre><code>#worldtime.tcl v2.3.2 *BETA* by HM2K &lt;irc@hm2k.org&gt; (Updated: 25/05/10)#@see http://www.hm2k.com/posts/worldtime-tcl### Usage Example ####&gt; .tz london#&lt;Bot&gt; HM2K, The time in Westminster, London, UK is Fri Feb 13 23:31:30 2009 (GMT+1000)### History ####v2.3.2 - expanded GMT offset; added curly braces for expr#v2.3.1 - fixed memory leaks; fixed unmatched results#v2.3   - uses Google to retreive geo and timezone information;#         instead of the system zoneinfo database, which was unreliable.#         more portable, works on any platform, including Windows.#v2.2.3 - added timezone offset to output string#v2.2.2 - added time offset, for a bizarre situation#v2.2.1 - a few bug fixes, now finds correct zoneinfo dir#v2.2   - replaced old TIME method with HTP method#v2.1   - now uses the TIME protocol to get accurate unixtime#v2.0   - new and improved, using system zoneinfo#v1.3   - based on a script by Murf, using worldtimeserver.com### Settings ###set tz(ver) "2.3.2 *BETA*"; # current version of this fileset tz(cmd) ".tz"; # public command triggerset tz(dcccmd) "tz"; # dcc command triggerset tz(output) "The time in \002%s\002 is %s (%s)"; # format for the outputset tz(dateformat) "%a %b %d %I:%M:%S %p %Y"; # format for the clock (wiki.tcl.tk/1810)set tz(usage) "Usage: $tz(cmd) &lt;location&gt;"; # usage resultset tz(noresult) "Unable to find a match."; # no result resultset tz(gettime) 1; # when on, will get time from time server, instead of systemset tz(timeserver) "www.google.com"; # should be any good remote web serverset tz(offset) 0; # seconds, eg: 3600 for plus 1 hour or -3600 for minusset tz(utc) "GMT"; # name given to UTCset tz(geourl) "http://maps.google.com/maps/api/geocode/xml"; # url for Google GeoCode lookupset tz(tzurl) "http://www.google.com/ig/timezone"; # url for Google's TimeZone lookup### Required Packages ###package require eggdrop 1.6;  #see http://geteggdrop.com/package require Tcl 8.2.3;    #see http://tinyurl.com/6kvu2npackage require http;         #see http://tinyurl.com/38ma4reif {[catch {package require htmlparse} err]} {  putlog "[info script] error: $error";  putlog "[info script] error: Tcllib is required, see http://tcllib.sf.net/";}### Binds ###bind pub - $tz(cmd) pub:tz;bind dcc -|- $tz(dcccmd) dcc:tz;### Public Functions ###proc pub:tz { nick uhost handle channel arg } {global tz;if {[llength $arg]==0} { putserv "NOTICE $nick :$tz(usage)"; return; }set result [tz:get $arg];if {$result eq ""} { set result $tz(noresult); }putserv "PRIVMSG $channel :$nick, $result";}### DCC Functions ###proc dcc:tz {ha idx arg} {  global tz;if {[llength $arg]==0} { putdcc $idx $tz(usage); return; }set result [tz:get $arg];if {$result eq ""} { set result $tz(noresult); }  putdcc $idx $result; }### Functions ###proc tz:get { arg } {  global tz;    #set the time  set time "";  if {$tz(gettime)} { set time [tz:gethtp $tz(timeserver)]; }  if {$time eq ""} { set time [clock seconds]; }    #offset place holder  set offset 0;  #set geo location info  set geoinfo [tz:getgeo $arg];    #no results  if {$geoinfo eq {}} { return; }  #set timezone name  set arg [lrange $geoinfo 2 end];  #set timezone info  set tzinfo [tz:gettz [lrange $geoinfo 0 1]];  #no results  if {$tzinfo eq {}} { return; }    #get gmt offset in seconds (including dst)  set offset [expr {[lindex $tzinfo 0]+[lindex $tzinfo 1]}];    #add timezone data to current gmt time (+offset)  set time [expr {$time+$offset/1000+$tz(offset)}];  #format the unixtime seconds to human readable time  set time [clock format $time -format $tz(dateformat)];    #make offset human readable  set offset [expr {$offset/3600}];  if {$offset == 0} { set offset "$tz(utc)"; } elseif {$offset &gt; 0} { set offset "$tz(utc)+$offset"; } else { set offset "$tz(utc)$offset"; }  #format and return  return [format $tz(output) $arg $time $offset];}proc tz:gethtp {args} { #?server? ?port?  if {[llength $args] &gt; 0} { set server [lindex $args 0]; } else { set server "www.google.com"; }  if {[llength $args] &gt; 1} { set port [lindex $args 1]; } else { set port 80; }  set s [socket $server $port];  puts $s "HEAD / HTTP/1.0\n";  flush $s;  while {[gets $s l] &gt;= 0} {    if {[regexp {Date: (.+?) GMT$} $l -&gt; date]} {      close $s;      return [clock scan $date];    }  }}proc tz:getdata { arg } {  if {[string length $arg]&lt;1} { return; }  set http [::http::geturl $arg];  set data [::http::data $http];  set data [::htmlparse::mapEscapes $data];  set data [string trim $data];  set data [join $data " "];  ::http::cleanup $http;  return $data;}proc tz:xmlparse { data arg } {  if {[string length $arg]&lt;1} { return; }  set arg [string tolower $arg];  set matched "";  set result "";  regexp "&lt;$arg&gt;(.+?)&lt;/$arg&gt;" $data matched result;  return $result;}proc tz:jsonparse { data arg } {  if {[string length $arg]&lt;1} { return; }  set matched "";  set result "";  regexp "'$arg':(\[^,\}\]+)" $data matched result;  return $result;}proc tz:getgeo { arg } {  global tz;  set arg [::http::formatQuery address $arg sensor "false"];  set data [tz:getdata $tz(geourl)?$arg];  if {[regexp "&lt;html&gt;.+" $data]} { return; }  if {$data eq {}} { return; }  #parse info  set info(lat) [tz:xmlparse $data "lat"];  set info(lng) [tz:xmlparse $data "lng"];  set info(addr) [tz:xmlparse $data "formatted_address"];  return "$info(lat) $info(lng) $info(addr)";}proc tz:gettz { arg } {  global tz;  if {[string length $arg]&lt;1} { return; }  set arg [::http::formatQuery lat [lindex $arg 0] lng [lindex $arg 1]];  set data [tz:getdata $tz(tzurl)?$arg];  if {[regexp "&lt;html&gt;.+" $data]} { return; }  if {$data eq {}} { return; }  set info(offset) [tz:jsonparse $data "rawOffset"];  set info(dst) [tz:jsonparse $data "dstOffset"];  return "$info(offset) $info(dst)";}### Loaded ###putlog "worldtime.tcl $tz(ver) loaded"#EOF</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8047">Torrevado</a> — Sun Sep 19, 2010 11:12 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2010-09-14T10:44:35-04:00</updated>

		<published>2010-09-14T10:44:35-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=94376#p94376</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=94376#p94376"/>
		<title type="html"><![CDATA[world time / weather tcl Requests]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=94376#p94376"><![CDATA[
hi <br>i need weather / time tcl like this<br><div class="codebox"><p>Code: </p><pre><code>2:57:07am / * &lt;iRoc&gt; !weather Dhaka2:57:16am / * * iB0T Dhaka, Bangladesh: Partly Cloudy and 82°F(28°C)2:40:10am / * &lt;iRoc&gt; !time Jessore2:40:13am / * &lt;iB0T&gt; Jessore, Bangladesh: September 14, 2:40 AM BDT</code></pre></div>Ty<p>Statistics: Posted by Guest — Tue Sep 14, 2010 10:44 am</p><hr />
]]></content>
	</entry>
	</feed>
