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.

Want to add ban to this working script (thx demond)

Old posts that have not been replied to for several years.
Locked
m
mikey2
Voice
Posts: 19
Joined: Thu Aug 18, 2005 4:39 pm

Want to add ban to this working script (thx demond)

Post by mikey2 »

This bit of code to check if a user's nick is registered works great (a big thanks go out to Demond for all their help:)

Code: Select all

bind join - * foo 
proc foo {n u h c} { 
   puthelp "whois $n" 
} 
bind raw - 311 got311 ;# first WHOIS reply 
bind raw - 307 got307 ;# nick has identified (registered) 
bind raw - 318 got318 ;# End of /WHOIS list 
proc got311 {f k t} { 
   set n [lindex [split $t] 1] 
   set ::whoised($n) 0 
} 
proc got307 {f k t} { 
   set n [lindex [split $t] 1] 
   incr ::whoised($n) 
} 
proc got318 {f k t} { 
   set n [lindex [split $t] 1] 
   if {$::whoised($n) == 0} { 
      puthelp "privmsg $n :please identify or register your nick" 
   } 
} 
Now, I would like to add a ban to this which would kick/ban a non-reg. user for 5 mins upon joining my channel. After 3 attempts to join channel with a non-reg. nick the user gets banned permanently.

Thanks for all your support. This website rocks.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Code: Select all

# ban after how many joins in how many seconds?
set banafter(j:s) 3:60

bind join - * kick:unreg

foreach {banafter(j) banafter(s)} [split $banafter(j:s) :] {break}

proc kick:unreg {nick uhost hand chan} {
 global banafter whoised rejoins
 if {![info exists rejoins([set n [string tolower $nick]])]} { set rejoins($n) 0 }
 if {!$whoised($nick)} { 
  puthelp "kick $chan $nick :please identify or register your nick" 
  utimer $banafter(s) [list incr rejoins($n) -1]
  if {[incr rejoins($n)] >= $banafter(j)} {
   puthelp "MODE $chan +b *!*@[lindex [split $uhost @] 1]"
  }
 } 
}
Last edited by Sir_Fz on Fri Aug 19, 2005 7:36 pm, edited 1 time in total.
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

You could replace the 'puthelp' line in got318 with 'newchanban'
newchanban <channel> <ban> <creator> <comment> [lifetime] [options]
Description: adds a ban to the ban list of a channel; creator is given
credit for the ban in the ban list. lifetime is specified in
minutes. If lifetime is not specified, ban-time (usually 60) is
used. Setting the lifetime to 0 makes it a permanent ban.
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
m
mikey2
Voice
Posts: 19
Joined: Thu Aug 18, 2005 4:39 pm

Post by mikey2 »

Thanks for your quick comments Sir_Fz. And Alchera, can you give me an example of your suggestion? Sorry I'm a newbie here.

Question for Sir_Fz:

Will this code kick/ban for 5 mins. for each join? As this will prevent auto-join for non-reg. users. So the flow should be as follows:

1st. join - kick/ban (5 min. ban)
2nd. join - kick/ban (5 min. ban)
3rd. join - kick/ban (permanent ban)

I like how you set so I can adjust the j/s (join/sec.).

Thanks for your help.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

No, the code I gave will kick the first 2 times, and ban on the third join. If you want it to ban for 5 minutes on each join, then add

Code: Select all

newchanban $chan *!*@[lindex [split $uhost @] 1] unreg "please identify or register your nick" 5
instead of the kick command.
m
mikey2
Voice
Posts: 19
Joined: Thu Aug 18, 2005 4:39 pm

Post by mikey2 »

Sorry for being such a bonehead, but can you include this in your code, and paste the whole script here so I can see how it's done?

Thanks.
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

mikey2 wrote:Sorry for being such a bonehead, but can you include this in your code, and paste the whole script here so I can see how it's done?

Thanks.
Simply replace:

Code: Select all

puthelp "kick $chan $nick :please identify or register your nick"
with:

Code: Select all

newchanban $chan *!*@[lindex [split $uhost @] 1] unreg "please identify or register your nick" 5
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
m
mikey2
Voice
Posts: 19
Joined: Thu Aug 18, 2005 4:39 pm

Post by mikey2 »

thanks for all your help... I'll give it a try.
m
mikey2
Voice
Posts: 19
Joined: Thu Aug 18, 2005 4:39 pm

Post by mikey2 »

Script works, but only if you do a /hop in the channel. It does not ban when the user initially joins the channel. That's what I would like it to do. Here's the code:

Code: Select all

bind join - * foo 
proc foo {n u h c} { 
   puthelp "whois $n" 
} 
bind raw - 311 got311 ;# first WHOIS reply 
bind raw - 307 got307 ;# nick has identified (registered) 
bind raw - 318 got318 ;# End of /WHOIS list 
proc got311 {f k t} { 
   set n [lindex [split $t] 1] 
   set ::whoised($n) 0 
} 
proc got307 {f k t} { 
   set n [lindex [split $t] 1] 
   incr ::whoised($n) 
} 
proc got318 {f k t} { 
   set n [lindex [split $t] 1] 
   if {$::whoised($n) == 0} { 
      puthelp "privmsg $n :Hello $n and welcome.  You MUST register your nick to join this channel." 
   } 
}
# ban after how many joins in how many seconds? 
set banafter(j:s) 3:60 

bind join - * kick:unreg 

foreach {banafter(j) banafter(s)} [split $banafter(j:s) :] {break} 

proc kick:unreg {nick uhost hand chan} { 
 global banafter whoised rejoins 
 if {![info exists rejoins([set n [string tolower $nick]])]} { set rejoins($n) 0 } 
 if {!$whoised($nick)} { 
  newchanban $chan *!*@[lindex [split $uhost @] 1] unreg "please identify or register your nick. 5 min. ban.  Please return after you have registered." 5
  utimer $banafter(s) [list incr rejoins($n) -1] 
  if {[incr rejoins($n)] >= $banafter(j)} { 
   puthelp "MODE $chan +b *!*@[lindex [split $uhost @] 1]" 
  } 
 } 
}
Any ideas??? I appreciate your help.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Try this:

Code: Select all

bind join - * foo
bind raw - 311 got311 ;# first WHOIS reply 
bind raw - 307 got307 ;# nick has identified (registered) 
bind raw - 318 got318 ;# End of /WHOIS list 

proc foo {n u h c} {
 global whoisc 
 puthelp "whois $n"
 set whoisc($n) "$c *!*@[lindex [split $uhost @] 1]"
} 

proc got311 {f k t} { 
 set n [lindex [split $t] 1] 
 set ::whoised($n) 0
} 

proc got307 {f k t} { 
 set n [lindex [split $t] 1] 
 incr ::whoised($n) 
} 

proc got318 {f k t} {
 global whoisc
 set n [lindex [split $t] 1] 
 if {$::whoised($n) == 0} { 
  puthelp "privmsg $n :Hello $n and welcome.  You MUST register your nick to join this channel."
  if {[info exists whoisc($n)]} {
   newchanban [lindex [split $whoisc($n)] 0] [lindex [split $whoisc($n)] 1] unreg "please identify or register your nick. 5 min. ban.  Please return after you have registered." 5
  }
 } 
}
m
mikey2
Voice
Posts: 19
Joined: Thu Aug 18, 2005 4:39 pm

Post by mikey2 »

oops...this one doesn't ban at all. gives pm to user, but no ban onjoin nor with multiple /hops. Notice you cut out this portion of code:

Code: Select all

 utimer $banafter(s) [list incr rejoins($n) -1] 
  if {[incr rejoins($n)] >= $banafter(j)} { 
   puthelp "MODE $chan +b *!*@[lindex [split $uhost @] 1]" 
is this required? maybe this is the prob.

Also, I noticed this script is reversing the bans that had already been set in channel from other ops.

Thanks for your help.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Try to add

Code: Select all

putkick [lindex [split $whoisc($n)] 0] $n "please identify or register your nick. 5 min. ban.  Please return after you have registered."
after the newchanban line and see if it kicks the user out.

PS: don't double post.
b
b|_ack
Voice
Posts: 6
Joined: Thu Feb 10, 2005 4:25 am

Post by b|_ack »

Sir_Fz wrote:Try to add

Code: Select all

putkick [lindex [split $whoisc($n)] 0] $n "please identify or register your nick. 5 min. ban.  Please return after you have registered."
after the newchanban line and see if it kicks the user out.

PS: don't double post.
Can someone please let me know how I can just ban any/all unregistered nicks which have the word {bot b0t serv sevr} Thnx
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

b|_ack wrote:
Sir_Fz wrote:Try to add

Code: Select all

putkick [lindex [split $whoisc($n)] 0] $n "please identify or register your nick. 5 min. ban.  Please return after you have registered."
after the newchanban line and see if it kicks the user out.

PS: don't double post.
Can someone please let me know how I can just ban any/all unregistered nicks which have the word {bot b0t serv sevr} Thnx
by using the above script after patching it to check if the nick contains whatever sh*tword you deemed unacceptable
Locked