Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 1.79 KB | None | 0 0
  1. #############################
  2. #                           #
  3. # Tcl Eval commande public. #
  4. #                           #
  5. #############################
  6. namespace eval ::tcleval {
  7.    
  8.     # Nous vérifions si ya le package requis pour le msgcat.
  9.     package require msgcat
  10.     # Nous mettons la langue de msgcat en français.
  11.     ::msgcat::mclocale fr
  12.     # Commandes chars Exemple "." ou "!" Ce qui donnera par exemple : .tcl/!tcl
  13.     set cmds(char) "!"
  14.      # Les messages msgcat.
  15.      ::msgcat::mcset fr tc1 "\002TCL ->\002"
  16.      ::msgcat::mcset fr tc2 "\002Done.\002"
  17.      
  18.      # Le code TCL.
  19.      bind pub o "$::tcleval::cmds(char)tcl" [namespace current]::tcl
  20.       proc tcl {nick host hand chan arg} {
  21.         set rep ""
  22.         set arg [split $arg " "]
  23.         if {[lindex $arg 0]=="-exec"} {
  24.             set repeat [lindex $arg 1]
  25.             if {![string is digit $repeat] || $repeat==""} {
  26.                 set rep "invalid -exec argument \"$repeat\""
  27.                 set repeat 0
  28.             }
  29.             set arg [lrange $arg 2 end]
  30.             } else {
  31.                 set repeat 1
  32.             }
  33.             set arg [join $arg]
  34.             for {set x 0; set t [clock microseconds]} {$x<$repeat} {incr x} {
  35.                 catch [list uplevel 0 $arg] rep
  36.             }
  37.             set t2 [clock microseconds]
  38.             set time [expr ($t2-$t)]
  39.             set interact [expr $time/($repeat/1.0)]
  40.             set time [format %.3f [expr round($time)/1000.0]]
  41.             foreach r [split $rep \n] {
  42.                 if {$r!=""} {
  43.                     putserv "PRIVMSG $chan :[::msgcat::mc tc1] $r"
  44.                 }
  45.             }
  46.             putserv "PRIVMSG $chan :[::msgcat::mc tc2] $time Millisecondes ($interact µs/i)"
  47.       }
  48. }
  49. putlog "\0034TCL public chargé.\0034"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement