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.

Enforce Ban

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
i
i.m.offline
Halfop
Posts: 74
Joined: Thu Mar 02, 2006 11:47 am

Enforce Ban

Post by i.m.offline »

Hello Friends, I have this code which enforce bans. I would request if some1 can add something like:
Script shouldn't kick users if the ban mask matchs more than x number of users to prevent masskick. Thanks in advance.

Code: Select all


bind mode - "* +b" enforcebans 

proc enforcebans {nick uhost hand chan mc ban} { 
  if {![botisop $chan]} {return}
  if {![string match -nocase [string map {"\\" "\\\\" "\[" "\\["} $ban] $::botname]} { 
    foreach n [chanlist $chan] { 
      if {[string match -nocase [string map {"\\" "\\\\" "\[" "\\["} $ban] $n![getchanhost $n $chan]]} { 
        putkick $chan $n "1Banned 4-> $ban 4<- 1By4 $nick - 7,14::: i_m_0off9line :::" 
      } 
    } 
    } else { 
    pushmode $chan -o $nick 
  } 
}
i
i.m.offline
Halfop
Posts: 74
Joined: Thu Mar 02, 2006 11:47 am

Post by i.m.offline »

Strange 83 views and not even single help :( can some1 please help in this regards. thx
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Code: Select all

set enforce(max) "5"
set enforce(rsn) "Banned %ban by %nick"

proc enforcebans {nick uhost hand chan mc ban} {
  global enforce
  if {![botisop $chan]} {return}
  if {![string match -nocase [string map {"\\" "\\\\" "\[" "\\["} $ban] $::botname]} {
    foreach n [chanlist $chan] {
      if {[string match -nocase [string map {"\\" "\\\\" "\[" "\\["} $ban] $n![getchanhost $n $chan]]} {
        lappend list $n
      }
    }
    if {[llength $list] > $enforce(max)} return
    putkick $chan [join $list {,}] [subst $enforce(rsn)]
    } else {
    pushmode $chan -o $nick
  }
}
Give this a try.. not tested.. :|

Edit: Seems that I've also forgoten to add some variables used in the script.. Fixed now, also, not tested.
Last edited by caesar on Thu Sep 14, 2006 3:10 pm, edited 1 time in total.
Once the game is over, the king and the pawn go back in the same box.
i
i.m.offline
Halfop
Posts: 74
Joined: Thu Mar 02, 2006 11:47 am

Post by i.m.offline »

if {[llength $list] > $enforce(max)} return <---- is it (max) where I shall define maximum number of bans?

something like:

if {[llength $list] > $enforce( 8 )} return (with no space)
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

Code: Select all

set enforce(max) 8

proc enforcebans {nick uhost hand chan mc ban} {
  global enforce
  if {![botisop $chan]} {return}
  if {![string match -nocase [string map {"\\" "\\\\" "\[" "\\["} $ban] $::botname]} {
    foreach n [chanlist $chan] {
      if {[string match -nocase [string map {"\\" "\\\\" "\[" "\\["} $ban] $n![getchanhost $n $chan]]} {
        lappend list $user
      }
    }
    if {[llength $list] > $enforce(max)} return
    putkick $chan [join $list {,}] $enforce(rsn)
    } else {
    pushmode $chan -o $nick
  }
} 
i
i.m.offline
Halfop
Posts: 74
Joined: Thu Mar 02, 2006 11:47 am

Post by i.m.offline »

ohh thanks, so sweet of u guys :D
will give a try and get back. thx

Tried both the codes, but they both r showing error:
1Tcl error [enforcebans]: can't read "user": no such variable
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

My bad, forgot to change from:

Code: Select all

lappend list $user 
to this:

Code: Select all

lappend list $n
Also fixed my previous code.
Once the game is over, the king and the pawn go back in the same box.
i
i.m.offline
Halfop
Posts: 74
Joined: Thu Mar 02, 2006 11:47 am

Post by i.m.offline »

thx a lot for update caesar

It still seems to have some bugs. i.e.:

1. It doesn't release the ban or deop the nick who sets the ban more than max.

2. if ban mask doesn't exceed the limit - on kick msg it shows like "3(Banned %ban by %nick)" instead of banned mask or nick who banned.

Thx in advance.
r
r0t3n
Owner
Posts: 507
Joined: Tue May 31, 2005 6:56 pm
Location: UK

Post by r0t3n »

Change:

Code: Select all

if {[llength $list] > $enforce(max)} return
  putkick $chan [join $list {,}] $enforce(rsn)
    } else {
  pushmode $chan -o $nick
} 
To:

Code: Select all

if {[llength $list] > $enforce(max)} {
  pushmode $chan -ob $nick $ban
} else {
  putkick $chan [join $list ,] :[string map { %ban $ban %nick $nick } $enforce(rsn)]
}
r0t3n @ #r0t3n @ Quakenet
i
i.m.offline
Halfop
Posts: 74
Joined: Thu Mar 02, 2006 11:47 am

Post by i.m.offline »

after making changes as suggested by tosser, it gives error like
(file "scripts/enforcebans.tcl" line 4)
& disconnects the bot

I realize there was one "}" missing, which I added at the end of code and tried, but it doesn't react at all.

Maybe "}" should be placed elsewhere. Please suggest. if I m wrong.

Thx for all ur afforts n try in advance. :)
r
r0t3n
Owner
Posts: 507
Joined: Tue May 31, 2005 6:56 pm
Location: UK

Post by r0t3n »

Code: Select all

bind mode - "* +b" enforcebans

set enforce(max) "8"
set enforce(kmsg) "Banned %ban by %nick"

proc enforcebans {nick uhost hand chan mc ban} {
  global enforce botname
  if {![botisop $chan]} { return }
  set ban [string map {"\\" "\\\\" "\[" "\\["} $ban]
  if {[string match -nocase $ban $botname]} { return }
  set list ""
  foreach user [chanlist $chan] {
    if {[string match -nocase $ban $user![getchanhost $user $chan]]} {
      lappend list $user
    }
  }
  if {[llength $list] > $enforce(max)} {
    putserv "MODE $chan -ob $nick $ban"
  } else {
    if {[llength $list] <= "3"} {
      putkick $chan [join $list ,] :[string map {"%ban" "$ban" "%nick" "$nick"} $enforce(kmsg)]"
    } else {
      set nlist ""
      foreach x $list {
        lappend nlist $x
        if {[llength $nlist] == "3"} {
          putserv "KICK $chan [join $nlist ,] :[string map {"%ban" "$ban" "%nick" "$nick"} $enforce(kmsg)]"
          set nlist ""
        }
      }
      if {[llength $nlist] != ""} {
        putserv "KICK $chan [join $nlist ,] :[string map {"%ban" "$ban" "%nick" "$nick"} $enforce(kmsg)]"
        set nlist ""
      }
    }
  }
}

putlog "Enforcebans loaded."
Not tested.

Added in kick flood protection, only 3 users kicked at a time. If not needed, just remove it.
r0t3n @ #r0t3n @ Quakenet
i
i.m.offline
Halfop
Posts: 74
Joined: Thu Mar 02, 2006 11:47 am

Post by i.m.offline »

wow thats working charm & almost perfect as I expected :D thx a lot

Only one problem is with kick msg, its showing kick msg as:
3(:Banned $ban by $nick")

Please see if u can do something about it :s thx a lot
r
r0t3n
Owner
Posts: 507
Joined: Tue May 31, 2005 6:56 pm
Location: UK

Post by r0t3n »

Try:

Code: Select all

bind mode - "* +b" enforcebans

set enforce(max) "8"
set enforce(kmsg) "Banned :ban: by :nick:"

proc enforcebans {nick uhost hand chan mc ban} {
  global enforce botname
  if {![botisop $chan]} { return }
  set ban [string map {"\\" "\\\\" "\[" "\\["} $ban]
  if {[string match -nocase $ban $botname]} { return }
  set kickmsg "$enforce(kmsg)"
  regsub -all :ban: $kickmsg $ban kickmsg
  regsub -all :nick: $kickmsg $nick kickmsg
  set list ""
  foreach user [chanlist $chan] {
    if {[string match -nocase $ban $user![getchanhost $user $chan]]} {
      lappend list $user
    }
  }
  if {[llength $list] == "0"} { return }
  if {[llength $list] > $enforce(max)} {
    putserv "MODE $chan -ob $nick $ban"
  } else {
    if {[llength $list] <= "3"} {
      putserv "KICK $chan [join $list ,] :$kickmsg"
    } else {
      set nlist ""
      foreach x $list {
        lappend nlist $x
        if {[llength $nlist] == "3"} {
          putserv "KICK $chan [join $nlist ,] :$kickmsg"
          set nlist ""
        }
      }
      if {[llength $nlist] != ""} {
        putserv "KICK $chan [join $nlist ,] :$kickmsg"
        set nlist ""
      }
    }
  }
}

putlog "Enforcebans loaded."
r0t3n @ #r0t3n @ Quakenet
i
i.m.offline
Halfop
Posts: 74
Joined: Thu Mar 02, 2006 11:47 am

Post by i.m.offline »

wooooooooow that works cooool like what exactly I wanted. Thanks a lot mate :D
i
i.m.offline
Halfop
Posts: 74
Joined: Thu Mar 02, 2006 11:47 am

Post by i.m.offline »

sorry for bothering again, if I want to exempt Bot users from being kicked as well, how can I add it? Please suggest so I will give a try. Thx
Post Reply