Hmm that repeat script is only for repeating some chars? Or do I understand wrong? I need script which for example bans for repeating "asdaasfh" two times in 3 secs#
## 6 ## Text repeating.
#
# use .chanset #channel ap:repeatl <repeats>:<seconds> (in DCC, 0:0 to disable)
# Set default rate here:
lappend ap:udefs {ap:repeatl 0:0}
## Text repeating Kick on how many consecutive repeated letters?
## Example: if this is set to 5 then the bot will kick any user who types (example):
# Hellooooo (5 consecutive o's)
# Hello!!!!!!!!! (5 and more consecutive ! marks)
## Use .chanset #channel ap:repeatc <number-of-letters> (in DCC, 0 to disable)
# Set default value here:
lappend ap:udefs {ap:repeatc 0}
# Text repeating punishment method:
set repeatf(pmeth) 3
# Text repeating ban type.
set repeatf(btype) 3
# Text repeating ban time in minutes. (0 for no ban time)
set repeatf(btime) 15
Code: Select all
if {[isvoice $nick $chan] || [isop $nick $chan]} {return 0}
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) 15
# 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
"*!*[lindex [split $host "@"] 0]*@[lindex [split $host "@"] 1]"
Code: Select all
proc norepeats_pubm {nick uhost hand chan text} {
global botnick norepeats
# add
if {[isvoice $nick $chan] || [isop $nick $chan]} {return 0}
Code: Select all
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
}
# add
if {[isvoice $nick $dest] || [isop $nick $dest]} {return 0}