This script was blacklist need to make change first the ban patern to ban on join only what is not added on whitelist
and second to make check up /userip nick on join to match their hidden hostmask from vhost and to check if exist on whitelist and to allow, if the hostmask dont exist on whitelist to make ban +b *!*@*.domain
# Need to fix and add this 5 things :
# 1.To take off the reason when i add hostmask on whitelist.
# 2.On Join Channel need to check users with vhost /userip nick and to match their hostmask with whitelist exemp hostmask
# 3.When i add a hostmask to remove the ban from channel.
# 5.Type of ban the user on join +b *!*@*.domain when hostmask dont exist on whitelist exemp
# Thank You In Advance For Your Help
Code: Select all
set whitelist_file "scripts/dbase/whitelist"
bind PUB m|- .wl whitelist:list
bind PUB m|- .aw whitelist:add
bind PUB m|- .dw whitelist:del
bind TIME -|- "* * * * *" whitelist:sentry
bind JOIN -|- * whitelist:join
proc whitelist:list {nickname hostname handle channel arguments} {
global whitelist
set entrys 0
puthelp "NOTICE $nickname :whitelist entrys"
puthelp "NOTICE $nickname :Nr. Owner Hostmask"
foreach entry [array names whitelist] {
incr entrys
set owner [lindex $whitelist($entry) 0]
while {[string length $owner] < 15} {
set owner "$owner "
}
if {[string length $entrys] < 2} {
set target "$entrys "
} else {
set target $entrys
}
puthelp "NOTICE $nickname :#$target $owner $entry"
}
puthelp "NOTICE $nickname :End of list."
}
proc whitelist:add {nickname hostname handle channel arguments} {
global whitelist
set arguments [whitelist:clean $arguments]
set banmask [whitelist:validate:host [lindex $arguments 0]]
if {([regexp -all -- {!} $banmask] > 1) || ([regexp -all -- {@} $banmask] > 1)} {
puthelp "NOTICE $nickname :Sorry, couldn't add that hostmask."
return
}
set owner $handle
if {[regexp {^(\d{1,2}|[0-3][0-6][0-5])$} [lindex $arguments 1]]} {
set expire [expr ([lindex $arguments 1] * 86400) + [unixtime]]
set reason [join [lrange $arguments 2 end]]
} else {
set expire 0
set reason [join [lrange $arguments 1 end]]
}
if {[llength $reason] >= 1} {
if {![info exists whitelist($banmask)]} {
set whitelist($banmask) "$owner $expire $reason"
puthelp "NOTICE $nickname :Done. $banmask added on whitelist (reason: $reason)."
whitelist:sentry
} else {
puthelp "NOTICE $nickname :Sorry. This hostmask exist already on whitelist"
}
} else {
puthelp "NOTICE $nickname :You forgot to type a whitelist reason."
}
}
proc whitelist:del {nickname hostname handle channel arguments} {
global whitelist
set arguments [whitelist:clean $arguments]
set banmask [lindex $arguments 0]
set success 0
if {[regexp {^#([0-9]+)$} $banmask tmp number]} {
set item 0
foreach entry [array names whitelist] {
incr item
if {$item == $number} {
unset whitelist($entry)
set success 1
}
}
} else {
if {[info exists whitelist($banmask)]} {
unset whitelist($banmask)
set success 1
}
}
if {$success == 0} {
puthelp "NOTICE $nickname :Couldn't delete the requested ban. Use .wl to view them."
} else {
puthelp "NOTICE $nickname :Done. Hostmask is removed from whitelist."
}
}
proc whitelist:sentry {{minute "0"} {hour "0"} {day "0"} {week "0"} {year "0"}} {
global whitelist
foreach channel [channels] {
if {![botisop $channel]} {continue}
foreach target [chanlist $channel] {
set userhost [whitelist:weirdclean "$target![getchanhost $target]"]
foreach entry [array names whitelist] {
set expire [lindex $whitelist($entry) 1]
if {$expire >= [unixtime] || ($expire == 0)} {
set reason [lrange [whitelist:clean $whitelist($entry)] 2 end]
set whitehost [whitelist:weirdclean $entry]
if {[string match -nocase $whitehost $userhost]} {
putquick "MODE $channel -b $whitehost $entry"
}
} else {
unset whitelist($entry)
}
}
}
}
whitelist:save
}
proc whitelist:join {nickname hostname handle channel} {
global whitelist
if {![botisop $channel]} {return}
set userhost [whitelist:weirdclean "$nickname![getchanhost $nickname]"]
foreach entry [array names whitelist] {
set reason [lrange [whitelist:clean $whitelist($entry)] 2 end]
set whitehost [whitelist:weirdclean $entry]
if {[string match -nocase $whitehost $userhost]} {
putquick "MODE $channel +b $whitehost $entry"
}
}
}
proc whitelist:validate:host {i} {
regsub -all {\*+} $i {*} i
array set ban {
ident *
host *
}
set ban(nick) $i
if {[regexp -- {!} $i]} {
regexp -- {^(.+?)!(.*?)(@(.*))?$} $i tmp ban(nick) ban(ident) tmp ban(host)
} elseif {[regexp -- {@} $i]} {
regexp -- {^(.+!)?(.*?)(@(.*))?$} $i tmp ban(nick) ban(ident) tmp ban(host)
}
foreach item [array names ban] {
if {[string length $ban($item)] < 1} {
set ban($item) *
}
}
return $ban(nick)!$ban(ident)@$ban(host)
}
proc whitelist:load {} {
global whitelist whitelist_file
regexp {(\S+/)?} $whitelist_file tmp whitelist_dir
if {$whitelist_dir != ""} {
if {![file isdirectory $whitelist_dir]} {
file mkdir $whitelist_dir
putlog "Created directory: $whitelist_dir"
}
}
if {![file exists $whitelist_file]} {
array set whitelist {}
return
}
if {[array exists whitelist]} {
array unset whitelist
}
set file [open $whitelist_file r]
while {![eof $file]} {
gets $file line
if {[regexp -- {(\S+)\s(\S+)\s(\S+)\s(.+)} $line tmp banmask owner expire reason]} {
if {$expire >= [unixtime] || ($expire == 0)} {
set whitelist($banmask) "$owner $expire $reason"
}
}
}
close $file
}
proc whitelist:save {} {
global whitelist whitelist_file
set file "[open $whitelist_file w]"
foreach entry [array names whitelist] {
puts $file "$entry $whitelist($entry)"
}
close $file
}
proc whitelist:weirdclean {i} {
regsub -all -- \\\\ $i \001 i
regsub -all -- \\\[ $i \002 i
regsub -all -- \\\] $i \003 i
regsub -all -- \\\} $i \004 i
regsub -all -- \\\{ $i \005 i
return $i
}
proc whitelist:clean {i} {
regsub -all -- \\\\ $i \\\\\\\\ i
regsub -all -- \\\[ $i \\\\\[ i
regsub -all -- \\\] $i \\\\\] i
regsub -all -- \\\} $i \\\\\} i
regsub -all -- \\\{ $i \\\\\{ i
regsub -all -- \\\" $i \\\\\" i
return $i
}
whitelist:load
putlog "Script loaded: whitelist"