proc mymatchattr {hand flags {chan ""}} {
if {[regsub -all {[^&|().a-zA-Z0-9@+#-]} $flags {} f]} {
putloglev o * "error: (matchattr): illegal character in flags: $flags"
return 0
}
regsub -all -- {[|&]} $f {&&} f
regsub -all -- {#-} $f {-#} f
regsub -all -- {-} $f {!} f
regsub -all -- {#?[a-zA-Z0-9]} $f {(&)} f
regsub -all -- {\(#([a-zA-Z0-9])\)} $f {[matchchanattr $hand \1 $chan]} f
regsub -all -- {\(([a-zA-Z0-9])\)} $f {[matchattr $hand \1]} f
regsub -all -- {\.} $f {1} f
regsub -all -- {@} $f {[handisop $hand $chan]} f
regsub -all -- {\+} $f {[handisoporvoice $hand $chan]} f
return [expr $f]
}
proc norepeats_cleanqueue {chan} {
global norepeats
set chan [string tolower $chan]
if {![info exists norepeats($chan,queue)]} { set norepeats($chan,queue) "" }
set newqueue ""
set rate [norepeats_rate $chan]
set time [lindex [split $rate ":"] 1]
foreach item $norepeats($chan,queue) {
set when [lindex $item 3]
if {[expr [clock seconds] - $when] <= $time} {
lappend newqueue $item
}
}
set norepeats($chan,queue) $newqueue
}
proc norepeats_updatequeue {nick chan text} {
global norepeats
set nick [string tolower $nick]
set chan [string tolower $chan]
set text [string tolower $text]
set rate [norepeats_rate $chan]
if {$rate == "0:0"} { return }
if {![info exists norepeats($chan,queue)]} { set norepeats($chan,queue) "" }
set patt ""
set pattt ""
set nickt $nick
regsub -all -- \\\\ $nickt \\\\\\\\ nickt
regsub -all -- \\\[ $nickt \\\\\[ nickt
regsub -all -- \\\] $nickt \\\\\] nickt
regsub -all -- \\\} $nickt \\\\\} nickt
regsub -all -- \\\{ $nickt \\\\\{ nickt
lappend patt $nick
lappend pattt $nickt
lappend patt $text
lappend pattt $text
set fnd [lsearch $norepeats($chan,queue) "$pattt *"]
if {$fnd == -1} {
lappend patt "1"
lappend patt "[clock seconds]"
lappend norepeats($chan,queue) $patt
norepeats_cleanqueue $chan
return
}
set item [lindex $norepeats($chan,queue) $fnd]
set times [lindex $item 2]
incr times
set first [lindex $item 3]
lappend patt $times
lappend patt $first
set norepeats($chan,queue) [lreplace $norepeats($chan,queue) $fnd $fnd $patt]
norepeats_cleanqueue $chan
return
}
# nick text times first
proc norepeats_checkqueue {nick chan text} {
global norepeats
set now [clock seconds]
set nick [string tolower $nick]
set chan [string tolower $chan]
set text "[string tolower $text]"
if {![info exists norepeats($chan,queue)]} { set norepeats($chan,queue) "" }
set patt ""
regsub -all -- \\\\ $nick \\\\\\\\ nick
regsub -all -- \\\[ $nick \\\\\[ nick
regsub -all -- \\\] $nick \\\\\] nick
regsub -all -- \\\} $nick \\\\\} nick
regsub -all -- \\\{ $nick \\\\\{ nick
lappend patt $nick
lappend patt $text
set rate [norepeats_rate $chan]
set num [lindex [split $rate ":"] 0]
set time [lindex [split $rate ":"] 1]
if {$rate == "0:0"} { return 0 }
set fnd [lsearch $norepeats($chan,queue) "$patt *"]
if {$fnd == -1} { return 0 }
set item [lindex $norepeats($chan,queue) $fnd]
set times [lindex $item 2]
set first [lindex $item 3]
if {$times < $num} { return 0 }
if {[expr $now - $first] > $time} { return 0 }
return 1
}
One tips his hat to you. Your right, I must be blind. Well, rather, I didn't even read the code, I never do when there is no forum formatting to it, due to the mess thats displayed.
In this situation, I would sugest that you mymatchattr, as the code formatting requires it.