This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Problem meteo.tcl

Support & discussion of released scripts, and announcements of new releases.
Post Reply
K
Kaa
Voice
Posts: 10
Joined: Wed Oct 31, 2007 8:02 am
Location: Italy

Problem meteo.tcl

Post by Kaa »

Code: Select all

 meteo-0.2.tcl for eggdrop (05/11/2002)
# by elf- at #egghelp on AzzurraNet (irc.azzurra.org)
#
# per attivare lo script è necessario impostare il flag +meteo al canale (.chanset #chan +meteo)
set meteo_version 0.2

bind pub - !meteo meteo:request
setudef flag meteo

package require http
http::config -useragent "Mozilla/1.0"

proc meteo:request { nick uhost hand chan arg } {
	if { [ lsearch -exact [ channel info $chan ] "+meteo" ] == -1 } { return }
	putlog "METEO :: request \"!meteo $arg\" from $nick!$uhost on $chan"
	if { $arg == "" || $arg == "help" } {
		 putserv "privmsg $chan :\002\0034-\0035-\00314M\002eteo HELP\002\0035:\002\00314 Visualizza tempo e temperature minime/massime\
		 di una città. Uso: \002!meteo città\002"
		 return
	} elseif { [ string length $arg ] < 3 } {
		putserv "privmsg $chan :\002\0034-\0035-\00314M\002eteo\002\0035:\002\00314 La città *non* può essere inferiore ai 3 caratteri."
		return
	}
	regsub -all -- " " $arg "%20" args
	set url "http://meteo.ansa.it/ricerca.asp?cerca=$args"
	set http [ http::geturl $url ]
	upvar #0 $http state
	foreach { name value } $state(meta) {
		if { [ regexp -nocase -- ^location$ $name ] } {	set url "http://meteo.ansa.it/$value" }
	}
 	set http [ http::geturl $url ]
	set html [ http::data $http ]
	foreach line [ split $html "\n" ] {
		if { [ regexp -nocase -- {<td height\=\"20\" bgcolor\=.*<a href\=\"(.*)\" class\=\"menu\">(.*)</a></td>}\
		$line all rif citta ] } {
			if { [ regexp -nocase -- .*${arg}.* $citta ] } {
				regsub -- {amp;} $rif "" rif
				set url "http://meteo.ansa.it/$rif"
				break
			}
		}
	}
	set flag 0
	set min_max {}
	set http [ http::geturl $url ]
	set html [ http::data $http ]
	foreach line [ split $html "\n" ] {
		if { [ regexp -nocase -- {\"><a href\=\"(.*)\" class\=\"menu\">(.*)</a></td>$}	$line all rif citta ] } {
			if { [ regexp -nocase -- .*${arg}.* $citta ] } { set flag 1 }
		} elseif { [ regexp -- {\s+(.?\d+)</div>} $line all minmax ] && ( $flag == 1 ) } {
			lappend min_max $minmax
		} elseif { [ regexp -- {\s+<div ALIGN\=\"right\"><img SRC\=\"images\/simbolipiccoli.*ALT\=\"(.*)\"></div>}\
		$line all tempo ] && ( $flag == 1 ) } {
			break
		} elseif { [ regexp -- {<small><small> (.+)</small></small></font></td><td align\=\"right\">}\
		$line all regione ] } { continue }
	}
	if { [ info exists regione ] && [ info exists citta ] } {
		if { [ llength $min_max ] == 2 } {
			putserv "privmsg $chan \002\0034-\0035-\00314M\002eteo $regione\002\0035:\002\00314 A \002$citta\002 il tempo è\
			[ string tolower $tempo], minima [ lindex $min_max 0 ] massima [ lindex $min_max 1 ]"
		} else {
			putserv "privmsg $chan :\002\0034-\0035-\00314M\002eteo $regione\002\0035:\002\00314 A \002$citta\002 il tempo è\
			[ string tolower $tempo]"
		}
	} else {
		putserv "privmsg $chan :\002\0034-\0035-\00314M\002eteo\002\0035:\002\00314 \037$arg\037 città non trovata."
	}
}

putlog "METEO :: version $meteo_version loaded"
I have problems with this tcl. I get no response from the tcl and even errors in pl. The author has disappeared. Can you help me to run the tcl? Thanks.
Post Reply