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.

anti repeat from multi host/ip

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Crap. Replace:

Code: Select all

putkick [join [lrange $nlist 0 6] ","] "repeat flood" 
with:

Code: Select all

putkick $chan [join [lrange $nlist 0 6] ","] "repeat flood" 
Why is Chanserv in the list? :roll: Should we add an exception list or somethng?
Once the game is over, the king and the pawn go back in the same box.
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

this is what i have so far

Code: Select all

# multi-host-repeat.tcl v1.0 by SpiKe^^, closely based on
# repeat.tcl v1.1 (9 April 1999) by slennox <slenny@ozemail.com.au>

# Repeat flood, kick-ban on repeats:seconds #
set rp_bflood 3:10

# Repeat flood kick-ban reason #
set rp_breason "repeat flood"

# Length of time in minutes to ban Repeat flooders #
set rp_btime 1

# After a valid Repeat flood, script will continue to #
# kick-ban offenders for an additional 'x' seconds    #
set rp_blinger 10

# END OF SETTINGS # Don't edit below unless you know what you're doing #

bind pubm - * rp_pubmsg

set rp_bflood [split $rp_bflood :]

proc rp_pubmsg {nick uhost hand chan text} {
  global rp_bcount rp_bflood rp_breason rp_btime rp_blinger
  set uhost [string tolower $nick!$uhost]
  set chan [string tolower $chan]
  set text [string map [list \017 ""] [stripcodes abcgru $text]]
  set text [string tolower $text]
  if {[isbotnick $nick]} {  return 0  }
  if {[matchattr $hand f|f $chan]} {  return 0  }
  set utnow [unixtime]
  set target [lindex $rp_bflood 0]

  if {[info exists rp_bcount($chan:$text)]} {
    set uhlist [lassign $rp_bcount($chan:$text) cnt ut]
    set utend [expr {$ut + [lindex $rp_bflood 1]}]
    set expire [expr {$utend + $rp_blinger}]
    if {$cnt < $target} {
      if {$utnow > $utend} {  unset rp_bcount($chan:$text)  }
    } elseif {$utnow > $expire} {  unset rp_bcount($chan:$text)  }
  }

  if {![info exists rp_bcount($chan:$text)]} {
    set rp_bcount($chan:$text) [list 1 $utnow $uhost]
    return 0
  }

  if {$utnow <= $utend} {
    incr cnt
    if {[lsearch $uhlist $uhost] == "-1"} {  lappend uhlist $uhost  }
    set rp_bcount($chan:$text) [linsert $uhlist 0 $cnt $ut]
    if {$cnt < $target} {  return 0  }
    if {$cnt == $target} {  rp_dobans $chan $uhlist
    } else {  rp_dobans $chan [list $uhost]  }
  } elseif {$cnt >= $target} {  rp_dobans $chan [list $uhost]  }

  return 0
}

proc rp_dobans {chan uhlist} {
   # if the bot isn't OP there's no point to continue
   if {![botisop $chan]} return
   set blist ""
   set klist ""

   # loop through uhosts
   foreach uhost $uhlist {

      # filter out any duplicates
      if {[lsearch $blist $uhost] != -1} continue

      # set the ban mask as you want
      scan $uhost {%[^@]@%s} user host

      # save the list with masks to ban
      lappend blist "*!*@$host"

      # save the list with masks to get nicks from later on cos we will destroy the $blist
      lappend klist $uhost
   }

   # push 6 ban masks (or change to match how many bans per line the server you are on allows) at a time until the list is empty
   while {[llength $blist] != 0} {
      puthelp "MODE $chan +bbbbbb [join [lrange $blist 0 6] " "]"
      set blist [lrange $blist 6 end]
   }
      
   # from the given uhosts we ban make a list of nicks to kick and again filter out duplicates
   set nlist ""
   set userlist [lreplace [chanlist $chan] 0 0]
   foreach u [split $userlist] {
      set uhost [getchanhost $user $chan]
      scan $uhost {%[^@]@%s} user host
      if {[lsearch $klist $uhost] != -1} continue
      lappend nlist $u
   }

   # use putkick to do 6 kicks per a single line sent to server
   while {[llength $nlist] != 0} {
      putkick [join [lrange $nlist 0 6] ","] "repeat flood"
      set nlist [lrange $nlist 6 end]
   }
} 
proc rp_breset {} {
  global rp_bcount rp_bflood rp_blinger
  set utnow [unixtime]
  set target [lindex $rp_bflood 0]

  foreach {key val} [array get rp_bcount] {
    lassign $val cnt ut
    set utend [expr {$ut + [lindex $rp_bflood 1]}]
    set expire [expr {$utend + $rp_blinger}]
    if {$cnt < $target} {
      if {$utnow > $utend} {  unset rp_bcount($key)  }
    } elseif {$utnow > $expire} {  unset rp_bcount($key)  }
  }

  utimer 30 [list rp_breset]
}

if {![info exists rp_running]} {
  utimer 30 [list rp_breset]
  set rp_running 1
}

putlog "Loaded multi-host-repeat.tcl v1.0 by SpiKe^^" 
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

See my previous post that I edited while you where posting. :roll:

Oh, you can remove my comments line cos added them there to allow anyone easily follow the logic I had in mind.
Once the game is over, the king and the pawn go back in the same box.
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

i used that in the code if i did it correct
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

this is what i have atm
for some reason ir kicks me 2 and i didnt even flood

Code: Select all

# multi-host-repeat.tcl v1.0 by SpiKe^^, closely based on
# repeat.tcl v1.1 (9 April 1999) by slennox <slenny@ozemail.com.au>

# Repeat flood, kick-ban on repeats:seconds #
set rp_bflood 3:10

# Repeat flood kick-ban reason #
set rp_breason "repeat flood"

# Length of time in minutes to ban Repeat flooders #
set rp_btime 1

# After a valid Repeat flood, script will continue to #
# kick-ban offenders for an additional 'x' seconds    #
set rp_blinger 10

# END OF SETTINGS # Don't edit below unless you know what you're doing #

bind pubm - * rp_pubmsg

set rp_bflood [split $rp_bflood :]

proc rp_pubmsg {nick uhost hand chan text} {
  global rp_bcount rp_bflood rp_breason rp_btime rp_blinger
  set uhost [string tolower $nick!$uhost]
  set chan [string tolower $chan]
  set text [string map [list \017 ""] [stripcodes abcgru $text]]
  set text [string tolower $text]
  if {[isbotnick $nick]} {  return 0  }
  if {[matchattr $hand f|f $chan]} {  return 0  }
  set utnow [unixtime]
  set target [lindex $rp_bflood 0]

  if {[info exists rp_bcount($chan:$text)]} {
    set uhlist [lassign $rp_bcount($chan:$text) cnt ut]
    set utend [expr {$ut + [lindex $rp_bflood 1]}]
    set expire [expr {$utend + $rp_blinger}]
    if {$cnt < $target} {
      if {$utnow > $utend} {  unset rp_bcount($chan:$text)  }
    } elseif {$utnow > $expire} {  unset rp_bcount($chan:$text)  }
  }

  if {![info exists rp_bcount($chan:$text)]} {
    set rp_bcount($chan:$text) [list 1 $utnow $uhost]
    return 0
  }

  if {$utnow <= $utend} {
    incr cnt
    if {[lsearch $uhlist $uhost] == "-1"} {  lappend uhlist $uhost  }
    set rp_bcount($chan:$text) [linsert $uhlist 0 $cnt $ut]
    if {$cnt < $target} {  return 0  }
    if {$cnt == $target} {  rp_dobans $chan $uhlist
    } else {  rp_dobans $chan [list $uhost]  }
  } elseif {$cnt >= $target} {  rp_dobans $chan [list $uhost]  }

  return 0
}

proc rp_dobans {chan uhlist} {
   # if the bot isn't OP there's no point to continue
   if {![botisop $chan]} return
   set blist ""
   set klist ""

   # loop through uhosts
   foreach uhost $uhlist {

      # filter out any duplicates
      if {[lsearch $blist $uhost] != -1} continue

      # set the ban mask as you want
      scan $uhost {%[^@]@%s} user host

      # save the list with masks to ban
      lappend blist "*!*@$host"

      # save the list with masks to get nicks from later on cos we will destroy the $blist
      lappend klist $uhost
   }

   # push 6 ban masks (or change to match how many bans per line the server you are on allows) at a time until the list is empty
   while {[llength $blist] != 0} {
      puthelp "MODE $chan +bbbbbb [join [lrange $blist 0 6] " "]"
      set blist [lrange $blist 6 end]
   }
      
   # from the given uhosts we ban make a list of nicks to kick and again filter out duplicates
   set nlist ""
   set userlist [lreplace [chanlist $chan] 0 0]
   foreach u [split $userlist] {
      set uhost [getchanhost $user $chan]
      scan $uhost {%[^@]@%s} user host
      if {[lsearch $klist $uhost] != -1} continue
      lappend nlist $u
   }

   # use putkick to do 6 kicks per a single line sent to server
   while {[llength $nlist] != 0} {
      putkick $chan [join [lrange $nlist 0 6] ","] "repeat flood" 
      set nlist [lrange $nlist 6 end]
   }
} 
proc rp_breset {} {
  global rp_bcount rp_bflood rp_blinger
  set utnow [unixtime]
  set target [lindex $rp_bflood 0]

  foreach {key val} [array get rp_bcount] {
    lassign $val cnt ut
    set utend [expr {$ut + [lindex $rp_bflood 1]}]
    set expire [expr {$utend + $rp_blinger}]
    if {$cnt < $target} {
      if {$utnow > $utend} {  unset rp_bcount($key)  }
    } elseif {$utnow > $expire} {  unset rp_bcount($key)  }
  }

  utimer 30 [list rp_breset]
}

if {![info exists rp_running]} {
  utimer 30 [list rp_breset]
  set rp_running 1
}

putlog "Loaded multi-host-repeat.tcl v1.0 by SpiKe^^" 
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

it seems to ban everyone in the channel and it doesnt send instant its queud
wich takes it for ever to finish banning and kicking
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

At least dose it push 6 bans per line? How about kicks?

Need to test this out. :roll:

Well, it uses puthelp that's a slower queue. Switch to putquick if needed. The kick also goes with a slower queue to have multiple kicks in the same line, but if needed can switch to putquick and have a single kick per line, but I wouldn't opt for this too, but rather quickly moderate the channel to stop the flooding and remove the moderation after finished with the kicks.

Haven't looked at the code Spike did to follow his logic, so I get all nicks in channel and see if they are banned and kick them no matter if they flooded or not.
Last edited by caesar on Wed Mar 25, 2015 9:25 am, edited 1 time in total.
Once the game is over, the king and the pawn go back in the same box.
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

no it doesnt push modes in one line
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

If you are on Dalnet then from what I see in the documentation I guess it should be a single b, so replace the +bbbbbb with a single one +b. From:

Code: Select all

puthelp "MODE $chan +bbbbbb [join [lrange $blist 0 6] " "]" 
to

Code: Select all

puthelp "MODE $chan +b [join [lrange $blist 0 6] " "]" 
if that still doesn't work then I guess +b+b+b+b+b+b will. Just test with your IRC client to do:

Code: Select all

/mode #channel +b *!*@one *!*@two *!*@three *!*@four *!*@five *!*@six
and see if you set all 6 bans in one line. If not try with multiple +b like I said above.
Last edited by caesar on Wed Mar 25, 2015 9:34 am, edited 1 time in total.
Once the game is over, the king and the pawn go back in the same box.
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

im on a inspircd server wich has 15 mode settings in 1 line max
doesnt eggdrop support like mircs $modespl wich gets it from server
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

It may be worth mentioning, the uhosts in uhlist are like this: nick!user@host
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

all that remains is:

- for it to excempt !~@%& from beeing effected
- no queu ( send instant to server )
- send modes as much as possible in one line ( i tried pushmode but pt sends 4 modes per line )
- and to lock channel (temporary)

if this could be integrated its perfect for my needs and would be apreciated
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

- no queu ( send instant to server )
This will have your bot removed from the network for flooding.
wtf is everyones issue with a reasonable queueing of lines to the server?
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

as i mentioned its running on my own network and its opered and has no limits

cause waiting like minutes for it to finish kicking and banning is annoying for the rest of the users in the channel
s
simo
Revered One
Posts: 1108
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

tnx SpiKe^^ and caesar for the fine job much apreciated
Post Reply