| View previous topic :: View next topic |
| Author |
Message |
mikey2 Voice
Joined: 18 Aug 2005 Posts: 19
|
Posted: Fri Aug 19, 2005 5:53 pm Post subject: Want to add ban to this working script (thx demond) |
|
|
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: |
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. |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Fri Aug 19, 2005 7:35 pm Post subject: |
|
|
| Code: | # 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]"
}
}
} |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts
Last edited by Sir_Fz on Fri Aug 19, 2005 7:36 pm; edited 1 time in total |
|
| Back to top |
|
 |
Alchera Revered One

Joined: 11 Aug 2003 Posts: 3344 Location: Ballarat Victoria, Australia
|
Posted: Fri Aug 19, 2005 7:36 pm Post subject: |
|
|
You could replace the 'puthelp' line in got318 with 'newchanban'
| Quote: | 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 |
|
| Back to top |
|
 |
mikey2 Voice
Joined: 18 Aug 2005 Posts: 19
|
Posted: Fri Aug 19, 2005 8:05 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Fri Aug 19, 2005 8:45 pm Post subject: |
|
|
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: | | newchanban $chan *!*@[lindex [split $uhost @] 1] unreg "please identify or register your nick" 5 |
instead of the kick command. _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
mikey2 Voice
Joined: 18 Aug 2005 Posts: 19
|
Posted: Fri Aug 19, 2005 9:04 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
Alchera Revered One

Joined: 11 Aug 2003 Posts: 3344 Location: Ballarat Victoria, Australia
|
Posted: Sat Aug 20, 2005 12:23 am Post subject: |
|
|
| 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: | | puthelp "kick $chan $nick :please identify or register your nick" |
with:
| Code: | | 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 |
|
| Back to top |
|
 |
mikey2 Voice
Joined: 18 Aug 2005 Posts: 19
|
Posted: Sat Aug 20, 2005 2:31 pm Post subject: |
|
|
| thanks for all your help... I'll give it a try. |
|
| Back to top |
|
 |
mikey2 Voice
Joined: 18 Aug 2005 Posts: 19
|
Posted: Sat Aug 20, 2005 3:07 pm Post subject: |
|
|
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: |
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. |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sat Aug 20, 2005 5:26 pm Post subject: |
|
|
Try this:
| Code: | 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
}
}
} |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
mikey2 Voice
Joined: 18 Aug 2005 Posts: 19
|
Posted: Sat Aug 20, 2005 7:01 pm Post subject: |
|
|
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: |
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. |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sun Aug 21, 2005 10:17 pm Post subject: |
|
|
Try to add
| Code: | | 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. _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
b|_ack Voice
Joined: 10 Feb 2005 Posts: 6
|
Posted: Thu Aug 25, 2005 12:14 pm Post subject: |
|
|
| Sir_Fz wrote: | Try to add
| Code: | | 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 |
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Thu Aug 25, 2005 12:30 pm Post subject: |
|
|
| b|_ack wrote: | | Sir_Fz wrote: | Try to add
| Code: | | 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 |
|
| Back to top |
|
 |
|