############################# # # # Tcl Eval commande public. # # # ############################# namespace eval ::tcleval { # Nous vérifions si ya le package requis pour le msgcat. Vous pouvez vérifier en PL avec la commande : .tcl info patchlevel package require msgcat # Nous mettons la langue de msgcat en français. ::msgcat::mclocale fr # Commandes chars Exemple "." ou "!" Ce qui donnera par exemple : .tcl/!tcl set cmds(char) "!" # Les messages msgcat. ::msgcat::mcset fr tc1 "\002TCL ->\002" ::msgcat::mcset fr tc2 "\002Done.\002" # Le code TCL. bind pub o "$::tcleval::cmds(char)tcl" [namespace current]::tcl proc tcl {nick host hand chan arg} { set rep "" set arg [split $arg " "] if {[lindex $arg 0]=="-exec"} { set repeat [lindex $arg 1] if {![string is digit $repeat] || $repeat==""} { set rep "invalid -exec argument \"$repeat\"" set repeat 0 } set arg [lrange $arg 2 end] } else { set repeat 1 } set arg [join $arg] for {set x 0; set t [clock microseconds]} {$x<$repeat} {incr x} { catch [list uplevel 0 $arg] rep } set t2 [clock microseconds] set time [expr ($t2-$t)] set interact [expr $time/($repeat/1.0)] set time [format %.3f [expr round($time)/1000.0]] foreach r [split $rep \n] { if {$r!=""} { putserv "PRIVMSG $chan :[::msgcat::mc tc1] $r" } } putserv "PRIVMSG $chan :[::msgcat::mc tc2] $time Millisecondes ($interact µs/i)" } } putlog "\0034TCL public chargé.\0034"