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.

Some Addition for +enforcebans

Help for those learning Tcl or writing their own scripts.
Post Reply
i
i.m.offline
Halfop
Posts: 74
Joined: Thu Mar 02, 2006 11:47 am

Some Addition for +enforcebans

Post by i.m.offline »

I have a code for enforce ban (I want to use this instead of +enforcebans, as I want to show own kick msg etc).
I would request if some one can make it little more protected, i.e. it shouldn't kick if the ban mask is *!*@* & if ban mask matches bot's nick. if banmask is set to *!*@* then bot shall remove the unban the mask & deop the Nick and if banmask matches to bots nick then just release the ban. Thanks in advance.

Code: Select all


bind mode - "* +b" enforcebans  
 
proc enforcebans {nick uhost hand chan mc ban} {  
 foreach n [chanlist $chan] {  
  if {[string match -nocase $ban $n![getchanhost $n $chan]]} {  
   putkick $chan $n "Banned: Enforcing ban set by $nick 14($ban)"  
  }  
 }  
}

m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

Because string match is slightly gay, some banmasks would never match a user like that.

So we use a string map to get rid of \ and [ because string match will try to behave a little like regexp if you don't.

Code: Select all

bind mode - "* +b" enforcebans 
 
proc enforcebans {nick uhost hand chan mc ban} {
  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 "Banned: Enforcing ban set by $nick 14($ban)" 
      } 
    } 
  } else {
    pushmode $chan -o $nick
  }
} 
This is the best i'm willing to do, the bot will unban any masks that match his nick/host anyway.
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

what's with the "string map"? Only the 'string match -nocase' should do fine.
Once the game is over, the king and the pawn go back in the same box.
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

No because string match does strange things with [ (i think \ too, not sure)

Try it yourself

Code: Select all

% string match -nocase \[moo\] \[moo\]
0
% string match \[moo\] \[moo\]
0
% string match *\[mo\]* moo
1
%
This what i meant with string match acting like regexp
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

I for one haven't seen a host that has a [ in it, have you?
Once the game is over, the king and the pawn go back in the same box.
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

He checks banmasks, thus checks nicknamess too.

I've seen nicknames with [ in it. :)
i
i.m.offline
Halfop
Posts: 74
Joined: Thu Mar 02, 2006 11:47 am

Post by i.m.offline »

It works charm MeTroiD. Thanks a million :D.
i
i.m.offline
Halfop
Posts: 74
Joined: Thu Mar 02, 2006 11:47 am

Post by i.m.offline »

Can I request for little more update in it, it should check for bans only if OPed in channel. because else its causing error. Thanks in advance.
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Code: Select all

if {![botisop $chan]} {return}
Add the above line before:

Code: Select all

if {![string match ...
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
i
i.m.offline
Halfop
Posts: 74
Joined: Thu Mar 02, 2006 11:47 am

Post by i.m.offline »

Now it look most perfect. Thanks Alchera :D
i
i.m.offline
Halfop
Posts: 74
Joined: Thu Mar 02, 2006 11:47 am

Post by i.m.offline »

Once again I need little more update in this, I did request in other post but got no response.

Script works almost charm except I want to add one more option to make it more secured.

I should deop the nick & release the banmask, if the ban mask matchs more than x number of users. Just to prevent masskick in channel.

Thx again in advance.
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

You've recived an answer on your other thread. Stick to one thread with the question on the same issue.
Once the game is over, the king and the pawn go back in the same box.
Post Reply