egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Enforce Ban
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
i.m.offline
Halfop


Joined: 02 Mar 2006
Posts: 74

PostPosted: Sat Aug 26, 2006 4:07 am    Post subject: Enforce Ban Reply with quote

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
View user's profile Send private message
i.m.offline
Halfop


Joined: 02 Mar 2006
Posts: 74

PostPosted: Wed Sep 13, 2006 5:13 am    Post subject: Reply with quote

Strange 83 views and not even single help Sad can some1 please help in this regards. thx
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Wed Sep 13, 2006 2:36 pm    Post subject: Reply with quote

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.. Neutral

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
View user's profile Send private message
i.m.offline
Halfop


Joined: 02 Mar 2006
Posts: 74

PostPosted: Thu Sep 14, 2006 2:43 am    Post subject: Reply with quote

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
View user's profile Send private message
metroid
Owner


Joined: 16 Jun 2004
Posts: 771

PostPosted: Thu Sep 14, 2006 8:44 am    Post subject: Reply with quote

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
View user's profile Send private message
i.m.offline
Halfop


Joined: 02 Mar 2006
Posts: 74

PostPosted: Thu Sep 14, 2006 9:26 am    Post subject: Reply with quote

ohh thanks, so sweet of u guys Very Happy
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
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Thu Sep 14, 2006 3:07 pm    Post subject: Reply with quote

My bad, forgot to change from:
Code:

lappend list $user

to this:
Code:

lappend list $n

Also fixed my previous code.
_________________
Once the game is over, the king and the pawn go back in the same box.
Back to top
View user's profile Send private message
i.m.offline
Halfop


Joined: 02 Mar 2006
Posts: 74

PostPosted: Sat Sep 16, 2006 3:58 am    Post subject: Reply with quote

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
View user's profile Send private message
r0t3n
Owner


Joined: 31 May 2005
Posts: 507
Location: UK

PostPosted: Sat Sep 16, 2006 6:50 am    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
i.m.offline
Halfop


Joined: 02 Mar 2006
Posts: 74

PostPosted: Sat Sep 16, 2006 7:30 am    Post subject: Reply with quote

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. Smile
Back to top
View user's profile Send private message
r0t3n
Owner


Joined: 31 May 2005
Posts: 507
Location: UK

PostPosted: Sat Sep 16, 2006 8:07 am    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
i.m.offline
Halfop


Joined: 02 Mar 2006
Posts: 74

PostPosted: Sat Sep 16, 2006 8:41 am    Post subject: Reply with quote

wow thats working charm & almost perfect as I expected Very Happy 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
View user's profile Send private message
r0t3n
Owner


Joined: 31 May 2005
Posts: 507
Location: UK

PostPosted: Sat Sep 16, 2006 9:11 am    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
i.m.offline
Halfop


Joined: 02 Mar 2006
Posts: 74

PostPosted: Sat Sep 16, 2006 11:54 am    Post subject: Reply with quote

wooooooooow that works cooool like what exactly I wanted. Thanks a lot mate Very Happy
Back to top
View user's profile Send private message
i.m.offline
Halfop


Joined: 02 Mar 2006
Posts: 74

PostPosted: Wed Sep 20, 2006 5:39 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber