# cuál debería ser la longitud máxima de la contraseña :
set maxpass "30"
bind pub -|- "!pass" generate:pass
proc generate:pass {nick uhost hand chan text} {
if {[string is space [lindex [split $text] 0]]} {
puthelp "privmsg $chan : Uso: $::lastbind <cuántos dígitos debe tener la contraseña>"
return 0
} elseif {![string is digit -strict [lindex [split $text] 0]]} {
puthelp "privmsg $chan :Uso indebido... debería haberse ingresado como un número..."
return 0
} elseif {[lindex [split $text] 0] > $::maxpass} {
puthelp "privmsg $chan :Maximum la longitud de la contraseña es␂ $::maxpass ␂limitada..."
return 0
} else {
putserv "privmsg $chan ␂␃7Clave␂␃: [random:pass [lindex [split $text] 0]]"
}
return
}
# http://wiki.tcl.tk/3757
proc random:pass {length {chars "ABC#$%&Ññ.,/*+-=)([¡¿?!]DEFGHIJKLMNOPQRSTUVWXYZabcdefghiijklmnopqrstuvwxyz0123456789"}} {
set range [expr {[string length $chars]-1}]
set txt ""
for {set i 0} {$i < $length} {incr i} {
set pos [expr {int(rand()*$range)}]
append txt [string range $chars $pos $pos]
}
return $txt
}
putlog "=== Generador de pass ==="