| View previous topic :: View next topic |
| Author |
Message |
Stefano1990 Voice
Joined: 04 Jun 2018 Posts: 25
|
Posted: Mon Nov 11, 2019 11:19 am Post subject: new whitelist script |
|
|
Tcl On Join Channel ban only the User who are not in whitelist
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: |
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"
|
_________________ Use your common sense and try not to make me look too much like I know what I'm doing.
Last edited by Stefano1990 on Sat Nov 16, 2019 12:52 am; edited 1 time in total |
|
| Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
Posted: Wed Nov 13, 2019 1:16 pm Post subject: whitelist 0.1 |
|
|
| Quote: | | This script was blacklist need to make change first the ban patern to ban on join only what is not added on whitelist |
This edited process should change the basic function from a blacklist (ban anyone in the list) to a whitelist script (ban anyone NOT in the list)
Replace the entire existing proc whitelist:join with this edited process...
| Code: |
proc whitelist:join {nickname hostname handle channel} {
global whitelist
if {![botisop $channel]} {return}
set userhost [whitelist:weirdclean "$nickname![getchanhost $nickname]"]
set iswhite 0
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]} {
set iswhite 1
break
}
}
if {$iswhite == 0} {
putquick "MODE $channel +b [maskhost $userhost 4]"
}
}
|
_________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
. |
|
| Back to top |
|
 |
Stefano1990 Voice
Joined: 04 Jun 2018 Posts: 25
|
Posted: Wed Nov 13, 2019 1:29 pm Post subject: |
|
|
Yes now is work as whitelist is ban what is not added on whitelist
is work perfectly
the proc join you fixed thank you Spike^^ _________________ Use your common sense and try not to make me look too much like I know what I'm doing. |
|
| Back to top |
|
 |
Stefano1990 Voice
Joined: 04 Jun 2018 Posts: 25
|
Posted: Sat Nov 16, 2019 2:50 pm Post subject: Hello |
|
|
can anyone to help to add this code raw340 userip on other proc whitelist:join
| Code: |
bind join - "#test *" do_userip_on_join
###
proc do_userip_on_join {nick uhost handle chan} {
global chan_where_doing_userip
set chan_where_doing_userip $chan
putserv "privmsg $chan :$nick just joined $chan with hostmask of: $uhost"
bind raw - "340" watch_for_userip
putserv "userip $nick"
utimer 3 [list unbind raw - "340" watch_for_userip]
}
###
###
proc watch_for_userip {from keyword text} {
global chan_where_doing_userip
#putserv "privmsg $chan_where_doing_userip :text is: $text"
putserv "privmsg $chan_where_doing_userip : [lindex [split $text =] 1] "
}
|
now need to add here in this proc join below to match users hostmask address with vhost to read the whitelist file exemp host
| Code: |
proc whitelist:join {nickname hostname handle channel} {
if { ![channel get $channel whitelist] } { return 0 }
global whitelist
if {![botisop $channel]} {return}
set userhost [whitelist:weirdclean "$nickname![getchanhost $nickname]"]
set iswhite 0
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]} {
set iswhite 1
break
}
}
if {$iswhite == 0} {
putquick "MODE $channel +b [maskhost $userhost 4]"
putquick "KICK $channel $nickname :This Channel is restricted"
}
}
|
_________________ Use your common sense and try not to make me look too much like I know what I'm doing. |
|
| Back to top |
|
 |
Stefano1990 Voice
Joined: 04 Jun 2018 Posts: 25
|
Posted: Mon Nov 18, 2019 12:48 am Post subject: Hello |
|
|
This was a BlackList script , i change it to a Whitelist Script for privat channel protection to add innocent real user hostmask as trusted exemp host on whitelist file database , now dont need reason when i add trusted users hostmask
<@Stef> .t *!*@*.AEE21FF0.IP
-Bot-test- Done. *!*@*.AEE21FF0.IP added on whitelist.
<@Stef> .t *!*@*.AEE21FF0.IP
-Bot-test- Sorry. This hostmask exist already on whitelist
<@Stef> .wl
-Bot-test- whitelist entrys
-Bot-test- Nr. Owner Hostmask
-Bot-test- #1 Stef *!*@*.AEE21FF0.IP
-Bot-test- End of list.
<@Stef> .ut *!*@*.AEE21FF0.IP
-Bot-test- Done. Hostmask is removed from whitelist.
Now if someone can help to add a code raw 340 userip nick on join event to take out the hidden hostmask from users vhost to be check if their hostmask exist on whitelist file to not be kick-ban will be very helpfull
This is the code what is doing on join with raw 340 check userip nick
* Joins: Test1 (test@test.test)
<&Bot-test> Test1 just joined #Test with hostmask of: test@test.test
* Bot-test sets mode: +b *!*@test.test
* Test1 was kicked by Bot-test (This Channel Is Restricted)
<&Bot-test> +test@2D5F7E1.3AA808D4.AEE21FF0.IP
| Code: |
bind join - "#Test *" do_userip_on_join
###
proc do_userip_on_join {nick uhost handle chan} {
global chan_where_doing_userip
set chan_where_doing_userip $chan
putserv "privmsg $chan :$nick just joined $chan with hostmask of: $uhost"
bind raw - "340" watch_for_userip
putserv "userip $nick"
utimer 3 [list unbind raw - "340" watch_for_userip]
}
###
###
proc watch_for_userip {from keyword text} {
global chan_where_doing_userip
#putserv "privmsg $chan_where_doing_userip :text is: $text"
putserv "privmsg $chan_where_doing_userip : [lindex [split $text =] 1] "
}
|
Here: on proc whitelist:join
| Code: |
#Tcl kick-Ban On Join channel Only Users Without hostmask added on whitelist
set whitelist_file "scripts/dbase/whitelist"
bind PUB m|- .wl whitelist:list
bind PUB m|- .t whitelist:add
bind PUB m|- .ut 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 "Ok"
} else {
set expire 0
set reason "Ok"
}
if {[llength $reason] >= 1} {
if {![info exists whitelist($banmask)]} {
set whitelist($banmask) "$owner $expire $reason"
puthelp "NOTICE $nickname :Done. $banmask added on whitelist."
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
}
bind pub o|o .pro whitelist_control
proc whitelist_control {nick host handle chan args} {
global botnick
if { ![channel get $chan whitelist] && [string compare $args "on"] == 0 } {
channel set $chan +whitelist
putserv "NOTICE $nick :whitelist: enabled on $chan"
} elseif { [channel get $chan whitelist] && [string compare $args "off"] == 0 } {
channel set $chan -whitelist
putserv "NOTICE $nick :whitelist: disabled on $chan"
}
}
setudef flag whitelist
proc whitelist:join {nickname hostname handle channel} {
if { ![channel get $channel whitelist] } { return 0 }
global whitelist
if {![botisop $channel]} {return}
set userhost [whitelist:weirdclean "$nickname![getchanhost $nickname]"]
set iswhite 0
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]} {
set iswhite 1
break
}
}
if {$iswhite == 0} {
putquick "MODE $channel +b [maskhost $userhost 4]"
putquick "KICK $channel $nickname :This Channel Is Restricted"
}
}
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}
return $i
}
whitelist:load
putlog "Script loaded: whitelist"
|
Need and protection anti massjoin flood code
to set mode +i when is match massjoin flood 5:2
the users hostmask who are not in whitelist exemp file
and to unset mode -i after 20second
if someone can help thank you in advance
| Code: |
# Mass joins, set mode on joins:seconds #
set mj(flood) 5:2
# Set channel mode(s) on flood detected. #
# - set empty to disable setting channel modes (ex. set mj(mode) "") #
set mj(mode) "i"
# Remove these channel modes after how many seconds? #
set mjp(mrem) 20
|
_________________ Use your common sense and try not to make me look too much like I know what I'm doing. |
|
| Back to top |
|
 |
|