| View previous topic :: View next topic |
| Author |
Message |
i.m.offline Halfop
Joined: 02 Mar 2006 Posts: 74
|
Posted: Sat Aug 26, 2006 4:07 am Post subject: Enforce Ban |
|
|
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: |
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
}
}
|
|
|
| Back to top |
|
 |
i.m.offline Halfop
Joined: 02 Mar 2006 Posts: 74
|
Posted: Wed Sep 13, 2006 5:13 am Post subject: |
|
|
Strange 83 views and not even single help can some1 please help in this regards. thx |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Wed Sep 13, 2006 2:36 pm Post subject: |
|
|
| Code: |
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. _________________ Once the game is over, the king and the pawn go back in the same box.
Last edited by caesar on Thu Sep 14, 2006 3:10 pm; edited 1 time in total |
|
| Back to top |
|
 |
i.m.offline Halfop
Joined: 02 Mar 2006 Posts: 74
|
Posted: Thu Sep 14, 2006 2:43 am Post subject: |
|
|
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) |
|
| Back to top |
|
 |
metroid Owner
Joined: 16 Jun 2004 Posts: 771
|
Posted: Thu Sep 14, 2006 8:44 am Post subject: |
|
|
| Code: | 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
}
} |
|
|
| Back to top |
|
 |
i.m.offline Halfop
Joined: 02 Mar 2006 Posts: 74
|
Posted: Thu Sep 14, 2006 9:26 am Post subject: |
|
|
ohh thanks, so sweet of u guys
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 |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Thu Sep 14, 2006 3:07 pm Post subject: |
|
|
My bad, forgot to change from:
to this:
Also fixed my previous code. _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
i.m.offline Halfop
Joined: 02 Mar 2006 Posts: 74
|
Posted: Sat Sep 16, 2006 3:58 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
r0t3n Owner
Joined: 31 May 2005 Posts: 507 Location: UK
|
Posted: Sat Sep 16, 2006 6:50 am Post subject: |
|
|
Change:
| Code: | if {[llength $list] > $enforce(max)} return
putkick $chan [join $list {,}] $enforce(rsn)
} else {
pushmode $chan -o $nick
} |
To:
| Code: | 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 |
|
| Back to top |
|
 |
i.m.offline Halfop
Joined: 02 Mar 2006 Posts: 74
|
Posted: Sat Sep 16, 2006 7:30 am Post subject: |
|
|
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.  |
|
| Back to top |
|
 |
r0t3n Owner
Joined: 31 May 2005 Posts: 507 Location: UK
|
Posted: Sat Sep 16, 2006 8:07 am Post subject: |
|
|
| Code: | 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 |
|
| Back to top |
|
 |
i.m.offline Halfop
Joined: 02 Mar 2006 Posts: 74
|
Posted: Sat Sep 16, 2006 8:41 am Post subject: |
|
|
wow thats working charm & almost perfect as I expected 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 |
|
| Back to top |
|
 |
r0t3n Owner
Joined: 31 May 2005 Posts: 507 Location: UK
|
Posted: Sat Sep 16, 2006 9:11 am Post subject: |
|
|
Try:
| Code: | 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 |
|
| Back to top |
|
 |
i.m.offline Halfop
Joined: 02 Mar 2006 Posts: 74
|
Posted: Sat Sep 16, 2006 11:54 am Post subject: |
|
|
wooooooooow that works cooool like what exactly I wanted. Thanks a lot mate  |
|
| Back to top |
|
 |
i.m.offline Halfop
Joined: 02 Mar 2006 Posts: 74
|
Posted: Wed Sep 20, 2006 5:39 am Post subject: |
|
|
| 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 |
|
| Back to top |
|
 |
|