Aide pour mon TCL Google
#1
Allo je voudrais que quand je tape !google blabla.. je voudrais qu'il me dise aumoin 5 lien a place de juste 1.
alors toute marche bien mes bon..

TCL
#######Google######
package require http
 
bind pub - !google pub:google
bind pub - !g pub:google
#bind pub m !debug pub:debug
 
set agent "Mozilla"

# Tryb Debug. "1", Domyslnie: "0".
# !debug on/off 
 
set debug "0"
 
proc pub:debug { nick uhost handle channel arg } {
 global debug
	if {[llength $arg]==0} {
		if { $debug == "0" } {
		putserv "PRIVMSG $channel :\002\[NOTICE\]\002 debug\002"
		} else {
		putserv "PRIVMSG $channel :\002\[NOTICE\]\002 debug\002"
		}
	} else {
		if { $arg == "on" } {
			set debug "0"
			putserv "PRIVMSG $channel :\002\[NOTICE\]\002 debug\002"
		} elseif { $arg == "off" } {
			set debug "0"
			putserv "PRIVMSG $channel :\002\[NOTICE\]\002 debug\002"
		}
	}
}
 
proc pub:google { nick uhost handle channel arg } {
 global agent
 global debug
	if {[llength $arg]==0} {
		putserv "PRIVMSG $channel :La syntaxe: !Google <recherche> Ou !G ..."
	} else {
		set query "http://www.google.ca/custom?hl=pl&q=$arg&ie=ISO-8859-2"
		set query [string map {" " "+"} $query]
		putserv "PRIVMSG $channel :\002\[GOOGLE\]\002 Recherche -> $arg"
                set token [http::config -useragent $agent]
		set token [http::geturl $query]
		set token [http::geturl $query]; regexp -nocase {(.*)} [http::data $token] -> title; http::cleanup $token;
		set token [http::geturl $query]; regexp -nocase {<a href="([^"]+)" class=l[^>]*>} [http::data $token] -> newurl; http::cleanup $token;
		set title [string map {"<em>" "\002*"} $title]
		set title [string map {"</em>" "*\002"} $title]
		set title [string map {"–" "-"} $title]
		set title [string map {"—" "--"} $title]
		set title [string map {"" "-"} $title]
#### ZAKOME, W UTF-8!
		set title [encoding convertfrom utf-8 $title] 
#####
		 regexp {class=l[^>]*>([^>]*)</a>} $title -> title2
			if {$debug==1} {
				putserv "PRIVMSG $channel :\002\[DEBUG\]\002 \$query = $query"
				if { [info exists title2] } {
					putserv "PRIVMSG $channel :\002\[DEBUG\]\002 \$title2 = $title2"
				} else { 
					putserv "PRIVMSG $channel :\002\[DEBUG\]\002 \$title2 = \002debug!\002"
				}
				if { [info exists newurl] } {
				putserv "PRIVMSG $channel :\002\[DEBUG\]\002 \$newurl = $newurl" 
				} else {
				putserv "PRIVMSG $channel :\002\[DEBUG\]\002 \$newurl = \002debug!\002" 
				}
			} else {
				if { [info exists title2] && [info exists newurl] } {
				putserv "PRIVMSG $channel :\002\[GOOGLE\]\002 $title2 -> $newurl"
				} else {
				putserv "PRIVMSG $channel :\002\[GOOGLE\]\002 Next ;<"
				}
			}
	}
}
 
putlog "Google 1.0 by Erreur loaded"


Répondre Avertir
#2
Utilise les balises [tcl ] et [tcl /]
Répondre
#3
je comprend pas quesque tu veux dire ?
moi je parle quand je tape sa je veux plus de lien qui me donne EX:


18:30 ? @Erreur ¦ !google mIRC
18:30 Keep ¦ [GOOGLE] Recherche -> mIRC
18:30 Keep ¦ [GOOGLE] *mIRC*: Download *mIRC* -> http://www.mirc.com/get.html
Répondre Avertir
#4
ZWeR a écrit :je comprend pas quesque tu veux dire ?
heretoc parlait d'entourer ton code (dans ton post) par les balises tcl, ce que j'ai fait pour toi.
ZWeR a écrit :moi je parle quand je tape sa je veux plus de lien qui me donne EX:
18:30 ? @Erreur ¦ !google mIRC
18:30 Keep ¦ [GOOGLE] Recherche -> mIRC
18:30 Keep ¦ [GOOGLE] *mIRC*: Download *mIRC* -> http://www.mirc.com/get.html
On avait bien compris.
Il te manque un -all dans tes regexp afin d'avoir tous les liens et pas seulement le premier
Répondre


Atteindre :


Utilisateur(s) parcourant ce sujet : 1 visiteur(s)
Tchat 100% gratuit -Discutez en toute liberté