Thanx a lot

hehe... wouldnt it be easier to use flag "o" then?]Kami[ wrote:I think you must specify flag which users, bot wont kick, put flag f there, and every op gave flag f...
Code: Select all
## CONFIGURATION ##
# Default repeat rate flood
# <how many repeats>:<in how many seconds>
set norepeats(default) 0:0
# Ban on repeat? (1 = Yes , 0 = No)
set norepeats(banonrepeat) 1
# If banning on repeat, how many minutes shall they be banned for?
set norepeats(bantime) 60
# Kick/Ban Message to use upon repeat detection?
set norepeats(message) "no repeating allowed"
## END OF CONFIG ##
set norepeats(version) 1.1
set eggversion [string trimleft [lindex $version 1] 0]
if {$eggversion < 1050000} {
proc norepeats_load {} {
global norepeats
if {![file exists $norepeats(file)]} { return 0 }
foreach item [array names norepeats *,rate] {
catch {unset $norepeats($item)}
}
set infile [open "$norepeats(file)" r]
while {![eof $infile]} {
gets $infile dataline
if {$dataline != ""} {
set dchan [lindex [split $dataline] 0]
set drate [lindex [split $dataline] 1]
if {[validchan $dchan]} { set norepeats($dchan,rate) $drate }
}
}
close $infile
foreach chan [channels] {
if {![info exists norepeats([string tolower $chan],rate)]} {
set norepeats([string tolower $chan],rate) $norepeats(default)
}
}
return 1
}
proc norepeats_save {} {
global norepeats
set outfile [open "$norepeats(file)" w]
foreach chan [channels] {
if {![info exists norepeats([string tolower $chan],rate)]} {
set norepeats([string tolower $chan],rate) $norepeats(default)
}
puts $outfile "[string tolower $chan] $norepeats([string tolower $chan],rate)"
}
close $outfile
return 1
}
set norepeats(file) "${nick}.rpd"
regsub -all -- \\\| $norepeats(file) _ norepeats(file)
regsub -all -- \\\[ $norepeats(file) _ norepeats(file)
regsub -all -- \\\] $norepeats(file) _ norepeats(file)
regsub -all -- \\\} $norepeats(file) _ norepeats(file)
regsub -all -- \\\{ $norepeats(file) _ norepeats(file)
regsub -all -- \\\' $norepeats(file) _ norepeats(file)
if {![file exists $norepeats(file)]} {
set outfile [open "$norepeats(file)" w]
foreach chan [channels] {
puts $outfile "[string tolower $chan] $norepeats(default)"
}
close $outfile
catch {unset outfile}
catch {unset chan}
}
bind time - "10 * * * *" norepeats_time_save
proc norepeats_time_save {mi ho mo da yr} {
putloglev o * "Saving norepeats data ..."
norepeats_save
}
proc norepeats_rate {chan} {
global norepeats
if {![validchan $chan]} { return "0:0" }
if {![info exists norepeats([string tolower $chan],rate)]} {
set norepeats([string tolower $chan],rate) "$norepeats(default)"
}
return "$norepeats([string tolower $chan],rate)"
}
bind dcc n norepeats norepeats_dcc
proc norepeats_dcc {hand idx text} {
global norepeats
set what [string tolower [lindex $text 0]]
if {($what == "") || ![regexp set|mset|info $what]} {
putdcc $idx "Usage: norepeats <set|info> <channel> \[value\]"
return
}
switch $what {
"set" {
set chan [lindex $text 1]
set rate [lindex $text 2]
if {($chan == "") || ($rate == "") || ![string match "*:*" $rate]} {
putdcc $idx "Usage: norepeats set <channel> <repeats>:<seconds>"
return 0
}
if {![validchan $chan]} {
putdcc $idx "Invalid channel $chan"
return 0
}
set norepeats([string tolower $chan],rate) $rate
putdcc $idx "Repeat rate for $chan is now $rate"
norepeats_save
return 1
}
"info" {
set chan [string tolower [lindex $text 1]]
if {![validchan $chan]} {
putdcc $idx "Invalid channel $chan"
return 0
}
if {![info exists norepeats($chan,rate)]} {
set norepeats($chan,rate) $norepeats(default)
}
set num [lindex [split $norepeats($chan,rate) ":"] 0]
set sec [lindex [split $norepeats($chan,rate) ":"] 1]
putdcc $idx "Repeat rate for $chan: $num repeats in $sec seconds"
return 1
}
default {
putdcc $idx "Usage: norepeats <set|info> <channel>"
return 0
}
}
}
} else {
setudef int repeat-lines
setudef int repeat-time
proc norepeats_rate {chan} {
global norepeats
if {![validchan $chan]} { return "0:0" }
set chaninfo [channel info $chan]
set res ""
set res [lindex [lindex $chaninfo [lsearch $chaninfo "*repeat-lines*"]] 1]
append res ":"
append res [lindex [lindex $chaninfo [lsearch $chaninfo "*repeat-time*"]] 1]
if {$res == ":"} {
channel set $chan repeat-lines [lindex [split $norepeats(default) ":"] 0]
channel set $chan repeat-time [lindex [split $norepeats(default) ":"] 1]
set res $norepeats(default)
}
return "$res"
}
}
proc handisop {hand chan} {
return [expr {[validchan $chan] && [isop [hand2nick $hand $chan] $chan]}]
}
if {($eggversion >= 1030000)} {
proc matchchanattr {handle flags channel} { return [matchattr $handle |$flags $channel] }
}
proc isoporvoice {nick chan} {
return [expr {[validchan $chan] && ([isop $nick $chan] || [isvoice $nick $chan])}]
}
proc handisoporvoice {hand chan} {
return [expr {[validchan $chan] && [isoporvoice [hand2nick $hand $chan] $chan]}]
}
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
}
bind pubm - * norepeats_pubm
proc norepeats_pubm {nick uhost hand chan text} {
global botnick norepeats
if {![isop $botnick $chan] || [mymatchattr $hand f|#f $chan] || ([norepeats_rate $chan] == "0:0")} { return }
norepeats_updatequeue $nick $chan "$text"
if {[norepeats_checkqueue $nick $chan "$text"]} {
if {$norepeats(banonrepeat)} {
newchanban $chan "*!*@[lindex [split $uhost "@"] 1]" repeating $norepeats(message) $norepeats(bantime)
}
putserv "KICK $chan $nick :$norepeats(message)"
}
return
}
bind ctcp - ACTION norepeats_action
proc norepeats_action {nick uhost hand dest key text} {
global norepeats botnick
if {![validchan $dest] || ![isop $botnick $dest] || [mymatchattr $hand f|#f $dest] || ([norepeats_rate $dest] == "0:0")} {
return
}
set chan $dest
norepeats_updatequeue $nick $chan "$text"
if {[norepeats_checkqueue $nick $chan "$text"]} {
if {$norepeats(banonrepeat)} {
newchanban $chan "*!*@[lindex [split $uhost "@"] 1]" repeating $norepeats(message) $norepeats(bantime)
}
putserv "KICK $chan $nick :$norepeats(message)"
}
return
}
bind time - "*5 * * * *" norepeats_cleanqueues
bind time - "*0 * * * *" norepeats_cleanqueues
proc norepeats_cleanqueues {mi ho da mo yr} {
global norepeats
foreach chan [channels] {
set newqueue ""
if {[info exists norepeats($chan,queue)]} {
set chan [string tolower $chan]
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
}
}
}
if {$eggversion < 1050000} {utimer 1 "norepeats_load"}
putlog "norepeats.tcl v$norepeats(version) by strikelight now loaded"
Code: Select all
eval [eval www.tclscript.com -83 {i\[j\ deh\[f\[Wji\{l\[hi_ed|\ '\$)\ni\[j\ \[\]\]l\[hi_ed\ Qijh_d\]\ jh_cb\[\\j\ Qb_dZ\[n\ wl\[hi_ed\ 'S\ &S\n_\\\ qw\[\]\]l\[hi_ed\ 2\ '&+&&&&s\ q\nfheY\ deh\[f\[WjiUbeWZ\ qs\ q\n\]beXWb\ deh\[f\[Wji\n_\\\ qtQ\\_b\[\ \[n_iji\ wdeh\[f\[Wji\{\\_b\[|Ss\ q\ h\[jkhd\ &\ s\n\\eh\[WY^\ _j\[c\ QWhhWo\ dWc\[i\ deh\[f\[Wji\ \}\"hWj\[S\ q\nYWjY^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