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.

Fixing this repeat script to work on a channel

Old posts that have not been replied to for several years.
Locked
s
stevegarbz
Op
Posts: 104
Joined: Sat Dec 04, 2004 7:25 pm

Fixing this repeat script to work on a channel

Post by stevegarbz »

Code: Select all

# Number of repeats before kicking
set repeatkick 3
# In how many seconds
set repeattime 15
# Kick msg
set repeatmsg "You have gotten banned for repeating more than 3 lines in 15 seconds. 20 Minute Ban"
# Also ban?
set repeatban 1
# How long the ban should last (in minutes)
set repeatbantime 20


# Don't edit below unless you know what you're doing
bind pubm - * repeat_pubm
bind ctcp - ACTION repeat_action
bind nick - * repeat_nick

proc repeat_pubm {nick uhost hand chan text} {
  if {[matchattr $nick mo|mo $chan] || [isop $nick $chan] || [isvoice $nick $chan] || [matchattr $nick o|o $chan]} {return 0}
  global repeat_last repeat_num repeatkick repeatmsg repeatban repeatbantime
  if [info exists repeat_last([set n [string tolower $nick]])] {
    if {[string compare [string tolower $repeat_last($n)] \
        [string tolower $text]] == 0} {
      if {[incr repeat_num($n)] >= ${repeatkick}} {
        if {$repeatban} {
          set banmask "*!*[string range $uhost [string first "@" $uhost] end]"
          newchanban $chan $banmask repeat $repeatmsg $repeatbantime
        }
        putserv "KICK $chan $nick :$repeatmsg"
        unset repeat_last($n)
        unset repeat_num($n)
      }
      return
    }
  }
  set repeat_num($n) 1
  set repeat_last($n) $text
}

proc repeat_action {nick uhost hand dest keyword text} {
  if {[matchattr $nick mo|mo $dest] || [isop $nick $dest] || [isvoice $nick $dest] || [matchattr $nick o|o $dest]} {return 0} 
  global botnick altnick repeat_last repeat_num repeatkick repeatmsg repeatban repeatbantime
  if [info exists repeat_last([set n [string tolower $nick]])] {
    if {[string compare [string tolower $repeat_last($n)] \
        [string tolower $text]] == 0} {
      if {[incr repeat_num($n)] >= ${repeatkick}} {
        if {$repeatban} {
          set banmask "*!*[string range $uhost [string first "@" $uhost] end]"
          newchanban $dest $banmask repeat $repeatmsg $repeatbantime
        }
        putserv "KICK $dest $nick :$repeatmsg"
        unset repeat_last($n)
        unset repeat_num($n)
      }
      return
    }
  }
  set repeat_num($n) 1
  set repeat_last($n) $text
}

proc repeat_nick {nick uhost hand chan newnick} {
  if {[matchattr $nick mo|mo $chan] || [isop $nick $chan] || [isvoice $nick $chan] || [matchattr $nick o|o $chan]} {return 0}
  global repeat_last repeat_num
  catch {set repeat_last([set nn [string tolower $newnick]]) \
         $repeat_last([set on [string tolower $nick]])}
  catch {unset repeat_last($on)}
  catch {set repeat_num($nn) $repeat_num($on)}
  catch {unset repeat_num($on)}
}

proc repeat_timr {} {
  global repeat_last repeattime
  catch {unset repeat_last}
  catch {unset repeat_num}
  utimer $repeattime repeat_timr
}

if ![regexp repeat_timr [utimers]] {     # thanks to jaym
  utimer $repeattime repeat_timr
}

putlog "Repeat flood by es loaded."
How would I define certain channels for this script to load on?
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

add

Code: Select all

setudef flag repeats
in the script, perhaps under the "bind nick" line.
then replace

Code: Select all

if {[matchattr $nick mo|mo $chan] || [isop $nick $chan] || [isvoice $nick $chan] || [matchattr $nick o|o $chan]} {return 0}
with

Code: Select all

if {[matchattr $nick mo|mo $chan] || [isop $nick $chan] || [isvoice $nick $chan] || [matchattr $nick o|o $chan] || ![channel get $chan repeats]} {return 0}
now all you have to do is .chanset #channel +repeats in order to enable this script on a channel.

btw, you should've posted this in the Script Support & Releases forum.
s
stevegarbz
Op
Posts: 104
Joined: Sat Dec 04, 2004 7:25 pm

Post by stevegarbz »

Thank you :) I love you.
Locked