Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bind pubm - "*\[*" chooseproc
- #bind pubm - "*\[\ \]*" chooseproc
- proc myRand { min max } {
- set maxFactor [expr [expr $max + 1] - $min]
- set value [expr int([expr rand() * 100])]
- set value [expr [expr $value % $maxFactor] + $min]
- return $value
- }
- proc chooseproc {nick host hand chan rest} {
- set reglist [regexp -all -inline -- {(.*?) \[?\]} $rest]
- if {[llength $reglist] <= 2 } {
- putlog "list too short"
- return;
- }
- putlog $reglist
- set choose_list [list]
- foreach match $reglist {
- regsub {^\ } $match "" match
- regsub {\[\ \]} $match "" match
- if { [string first "\[" $match] != -1 } { continue; }
- set choose_list [linsert $choose_list end $match]
- }
- set choosen [lindex $choose_list [myRand 0 [llength $choose_list]-1]]
- set lst [list]
- set fin false
- foreach element $choose_list {
- #putlog "element: $element"
- if {$element == $choosen && !$fin } {
- append element " \[x\]"
- set fin true
- } else {
- append element " \[ \]"
- }
- set lst [linsert $lst end $element]
- }
- putserv "PRIVMSG $chan :[join $lst " "]"
- }
Add Comment
Please, Sign In to add comment