This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

problem with a norepeat tcl

Old posts that have not been replied to for several years.
Locked
D
Dreaman

problem with a norepeat tcl

Post by Dreaman »

I have installed norepeat tcl but have problems for op and voice.The bot ban also the op,t is possible to protect the +o and the +f flag?
thanks






## CONFIGURATION ##


# Default repeat rate flood
# <how many repeats>:<in how many seconds>
set norepeats(default) 6:60

# 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) 1

# 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"
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

hmm funneh coding...
anyway..

Code: Select all

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 }
if u want to protect just those who are op in a channel but without the o flag then just add

Code: Select all

[isop $nick $chan]
so that it looks like this:

Code: Select all

if {![isop $botnick $chan] || [isop $nick $chan] || [mymatchattr $hand f|#f $chan] || ([norepeats_rate $chan] == "0:0")} { return }
the f flag should already be matched, and if u want to add the o flag just make another [mymatcattr $hand.... just replace the f with o :)
Elen sila lúmenn' omentielvo
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Note, you are using a command called mymatchattr.

This is not a standard eggdrop command.
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

it is a proc in there called mymatchattr somewhere, but I would suggest u just forget about it and use the regular matchattr instead..
Elen sila lúmenn' omentielvo
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

The mymatchattr procedure provided is superior and also provides a standard matching attribute system for eggdrop versions 1.1.5 and higher.
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

As is available where.

It doesn't come with eggdrop as standard.

As such, I made the comment based on this fact. If it was included, I wouldn't need to point it out.

Otherwise, it's just a whole new mess for him to locate.
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

ppslim wrote:As is available where.

It doesn't come with eggdrop as standard.

As such, I made the comment based on this fact. If it was included, I wouldn't need to point it out.

Otherwise, it's just a whole new mess for him to locate.
As is available in the code he initially posted.

*fixes your glasses* 8)
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

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.
D
Dreaman

Post by Dreaman »

ok I have resolved thanks for the help :)
Locked