All pastes #589692 Raw Edit

Someone

public text v1 · immutable
#589692 ·published 2007-06-26 03:57 UTC
rendered paste body
#Respuestas v1.0 by G.L.A
package require http
set agent "Mozilla"


bind pub - !decime tedigo
bind pub - hola hola
bind pub - buenas buenas
bind pub - !sarcasmo sarcasmo
bind pub - !dolar valor


proc tedigo {nick uhost hand chan arg} {

 global agent
	if {[llength $arg]==0} {
		
	} else {
		set query "http://www.google.com.ar/search?btnI=&q="
		for { set index 0 } { $index<[llength $arg] } { incr index } {
			set query "$query[lindex $arg $index]"
			if {$index<[llength $arg]-1} then {
				set query "$query+"
			}
		}
		#putserv "PRIVMSG $channel :$query"
                set token [http::config -useragent $agent]
		set token [http::geturl $query]
		puts stderr ""
		upvar #0 $token state
		set max 0
		foreach {name value} $state(meta) {
			if {[regexp -nocase ^location$ $name]} {
				set newurl [string trim $value]
			}
		}
	}

  if {[lindex $arg 0] != ""} {
    set partes [split $arg " "]
    set pregunta [lindex $partes 0]

    switch -exact -- $pregunta { 
    web {putserv "PRIVMSG $chan :\002$pregunta\002 -> http://gnulinuxargentina.com.ar"} 
    foro {putserv "PRIVMSG $chan :\002$pregunta\002 -> http://gnulinuxargentina.com.ar/foro/index.php" } 
    wiki {putserv "PRIVMSG $chan :\002$pregunta\002 -> http://www.gnulinuxargentina.com.ar/wiki/index.php/Portada"} 
    puto {putserv "PRIVMSG $chan :\002$pregunta\002!!!, yo te digo, pero me parece raro que te guste que te digan asi"}
    
#Agregas las respuestas estaticas asi:
# <pregunta> {putserv "PRIVMSG $chan :\002$pregunta\002 -> <respuesta>"}

    default {putserv "PRIVMSG $chan :No se de que me hablas pero google si ---> $newurl"}


 } } else {
    	
	putserv "PRIVMSG $nick Ayuda:"
	putserv "PRIVMSG $nick : !decime wiki"
	putserv "PRIVMSG $nick : !decime foro"
	putserv "PRIVMSG $nick : !decime  web"
	#Y tenes que agregar aca la ayuda
 
        }
}


proc hola {nick uhost hand chan arg} {

 if {[lindex $arg 0] == ""} {
    putserv "PRIVMSG $chan :Hola manola, digo hola $nick"    
 } 

if {[lindex $arg 0] == "titoB"} {
    putserv "PRIVMSG $chan :Hola manola, digo hola $nick"    
 } 

}


proc buenas {nick uhost hand chan arg} {

 if {[lindex $arg 0] == ""} {
    putserv "PRIVMSG $chan :como va $nick ?"   
 } 

if {[lindex $arg 0] == "titoB"} {
    putserv "PRIVMSG $chan :como va $nick ?"   
 } 

}


proc sarcasmo {nick uhost hand chan arg} {
  if {[lindex $arg 0] != ""} {
    set partes [split $arg " "]
    set pregunta [lindex $partes 0]

    putserv "PRIVMSG $chan :<sarcasmo>$pregunta</sarcasmo>"

  } else {
    	putserv "PRIVMSG $nick : Ayuda:"
	putserv "PRIVMSG $nick : !sarcasmo <mensaje sarcastico>"
  }
}


proc valor {nick uhost hand chan arg} {

		global agent

		set direc "http://www.midolar.com.ar/dolar.xml"

		#putserv "PRIVMSG $channel :$query"
                set token [http::config -useragent $agent]
		set token [http::geturl $direc]
		puts stderr ""
		upvar #0 $token state
		set contador 0
	
		#foreach name  $state(body) {putserv "PRIVMSG $chan :prueba $name  "}

		#for {set contador 1} {$contador < 27} {incr contador 1}
		#{
		#incr contador
		#set salida [lindex $state(body) $contador]
		#putserv "PRIVMSG $chan :prueba $salida"
		#}
		set salida [lindex $state(body) 25]
		set venta [string range $salida 13 17]			
		putserv "PRIVMSG $chan :Compra: $venta"		

		set salida [lindex $state(body) 26]
		set compra [string range $salida 12 16]		
		putserv "PRIVMSG $chan :Venta: $compra"	
}