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.

[SOLVED] help with "repeat.tcl v1.1 (9 April 1999)"

Support & discussion of released scripts, and announcements of new releases.
Post Reply
v
virtanen
Voice
Posts: 8
Joined: Thu Jan 25, 2007 9:15 am

[SOLVED] help with "repeat.tcl v1.1 (9 April 1999)"

Post by virtanen »

Hi everyone!

I really need help with this script...
It does what it does well but there are few thingsa it does not do:
1) it does not ignore ops and voices
-> so it bans them too if they repeat :(
2) then banmask is very bad for big channels!
-> *!*@banmask -> it bans all people from maybe same vhost (bouncers etc). It should be something like blaa@*.blaa.blop

Can anyone help me fast please?

Sincerely Yours
virtanen
Last edited by virtanen on Fri Jan 26, 2007 8:16 am, edited 1 time in total.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

There are a lot of anti-repeat scripts out there, try to use another one. Alternatively, you can try and contact the script's author.
v
virtanen
Voice
Posts: 8
Joined: Thu Jan 25, 2007 9:15 am

Post by virtanen »

I tried few weeks ago, but he hasn't anserwed yet.
And i have tried all repeat scripts from here and all of them has some problems with banning ops, banning masks or those warning, kick, ban situations :(

It's neither I'm so rookie with this tcl codes or they just dont fit me =)
- virtanen -
Suomi - Finland
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

I may suggest AllProtection. It has what you want along with a lot of other features.

I am still sure that there is a script that suites your specification in the Tcl archive (I remember using one myself in past times).
v
virtanen
Voice
Posts: 8
Joined: Thu Jan 25, 2007 9:15 am

Post by virtanen »

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

Thank You for Your fast replies and sorry my noobishm :)

PS. Is there any short code that I can add to that norepeat script what ignores ops? I handled the banmask but nothing else :*(
- virtanen -
Suomi - Finland
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

ap:repeatl is for lines:secs and ap:repeatc is for repeated characters (so the first feature is what you want).

You can add to the proc where the kick occurs:

Code: Select all

if {[isvoice $nick $chan] || [isop $nick $chan]} {return 0}
to exempt ops and voices.
v
virtanen
Voice
Posts: 8
Joined: Thu Jan 25, 2007 9:15 am

Post by virtanen »

did add and got 2 error msg:
"Tcl error [norepeats_pubm]: wrong # args: no script following "{$norepeats(banonrepeat)}" argument"

and when i changed the place

"Tcl error [norepeats_pubm]: extra characters after close-quote"


I'm really sorry to bother You but what did I do wrong :) I put that code to proc where the ban and kick is but it gives me errors :(
- virtanen -
Suomi - Finland
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

That error has nothing to do with the added line.

Why don't you paste the code (the original, bugless code) and let us help you.
v
virtanen
Voice
Posts: 8
Joined: Thu Jan 25, 2007 9:15 am

Post by virtanen »

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"
and I have changed the ban mask to

Code: Select all

"*!*[lindex [split $host "@"] 0]*@[lindex [split $host "@"] 1]"
that shouldn't make the problem.

And there is not now the line You told me to put if i want to extempt ops and voices. Sorry this slownes :( Just learning how to use this forum :)
- virtanen -
Suomi - Finland
v
virtanen
Voice
Posts: 8
Joined: Thu Jan 25, 2007 9:15 am

Post by virtanen »

I think i got it =) $host just has to change to $uhost
DUMB ME! :oops:

EDIT:

THANK YOU VERY MUCH FOR YOUR HELP AND TIME!
- virtanen -
Suomi - Finland
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Code: Select all

proc norepeats_pubm {nick uhost hand chan text} {
  global botnick norepeats
  # add
  if {[isvoice $nick $chan] || [isop $nick $chan]} {return 0}
and

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}
v
virtanen
Voice
Posts: 8
Joined: Thu Jan 25, 2007 9:15 am

Post by virtanen »

I put it one or two lines upper and it did work.
I really want to thank you for your time and help.
I couldn't finnish this myself.
Thanks you from freeeeeezing Finland :)
- virtanen -
Suomi - Finland
s
strikelight2
Voice
Posts: 5
Joined: Tue Jan 02, 2007 12:33 am
Contact:

Post by strikelight2 »

Fyi, there is a newer version of the script you are using over at www.tclscript.com (v1.3) from Nov'02, which exempts ops that are not in the bot's userlist as you want.
Post Reply