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.
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
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:
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]"
}
}
}
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
}
}
}