Can anyone help with a script that will whois users who join a channel and if they have a realname which matched against a banned realname they will be kick, banned. This is mainly because we are getting problems on our channels with floods but they all seem to use the same realname but on different hosts.
#set this to the "bad" realanme
set badrealname "somerealname"
#set this to the length in mins of the ban
set bantime 60
#set this to the reason for the ban
set banreason "You norteh norteh boy!"
#set this to the channel where it should take effect
set banchan "#channel"
bind join - "$banchan *" ban:on:realname
proc ban:on:realname {nick host hand chan} {
if {![validuser $hand]} {
putserv "WHOIS $nick"
}
}
bind raw - 311 check:realname
proc check:realname {from key arg} {
global badrealname banreason bantime botnick
set realname [lindex [split $arg] end]
if {$realname == $badrealname} {
newchanban $banchan [maskhost [lindex [split $arg] 3]] $botnick $banreason $bantime -sticky
}
}
this is made without me having coofee and it is untested... try it at your own risk
this script is very basic and only matches if the badrealname is exactly like the users realname... I'll leave it to you to figure out how to fix this..
after all, we are not here to make scripts for you, we're here to help you make your own
I've took the liberty to mess around a bit with the code and noticed some stuff that I would like to share. I've looked on the result of the realname result and the realname starts with : so it's better to use something like:
# badrealname.tcl
# original code by Papillon
# modified by caesar
# What bad realnames should be banned?
set badr(list) {
"foo bar"
"bla bla"
"moo"
}
# The realname check should be done only in what channel?
set badr(chan) "#channel"
# For how many minutes whould you like the ban?
set badr(time) 60
# What reason will be used when an person is found using an bad realname?
set badr(reason) "You norteh norteh boy!"
# binds #
bind join - "$badr(chan) *" badrealname:join
bind raw - 311 badrealname:check
# join #
proc badrealname:join {nick host hand chan} {
if {![validuser $hand] || [strlwr $nick] != [strlwr $::botnick]} {
putserv "WHOIS $nick"
}
}
# check #
proc badrealname:check {from key arg} {
set realname [lindex [lrange [split $arg ":"] 1 end] 0]
foreach bah $::badr(list) {
if {$realname != $bah} {
continue
}
newchanban $::badr(chan) [maskhost [lindex [split $arg] 3]] $::botnick $::badr(reason) $::badr(time)
break
}
}
putlog "badrealname.tcl.. loaded."
Once the game is over, the king and the pawn go back in the same box.