View previous topic :: View next topic |
Author |
Message |
simo Revered One
Joined: 22 Mar 2015 Posts: 1051
|
Posted: Sun Mar 20, 2022 6:00 am Post subject: BadNicks added and removed with pub command more effiecient |
|
|
i was wondering if and how this tcl i got from RANA USMAN wich stores the badnicks in a var in the tcl itself could be changed to store more effiecient like mircs hash tables does and not in a text file wich most if not all tcls seem to have in tcls i come across
Code: |
set bnickxero {
"all4m"
"a||4m"
"aII4m"
"banger"
"suicide"
"siucide"
"hotter"
"h0tter"
"s*exy"
"needgirl"
"ne3dgirl"
"n3edglrl"
"n33dglrl"
"n3edg|rl"
"o-r-a-l"
"l3sbl"
"l3sbl"
"lesb|"
"l3sb|"
"lesbian"
"l3sbian"
"lesbion"
"l3sbion"
"f2f"
"f2f"
"niple"
"merried"
"meried"
"hotcam"
"bedroom"
"gentlebiter"
"bedro0m"
"bedr00m"
"bedr0om"
"naked"
"nudist"
"0inch"
"1inch"
"2inch"
"3inch"
"4inch"
"5inch"
"6inch"
"7inch"
"8inch"
"9inch"
"prostitut"
"HOMO"
"h0mo"
"hom0"
"gay"
"assho"
"pussy"
"[censored]"
"animal"
"cam2cam"
"cock"
"romantic"
"webcam"
"ugly"
"hotgirl"
"dick"
"suck"
"[censored]"
"tits"
"boob"
"sex"
"terror"
"pedo"
"whore"
"slut"
"hotmale"
"hotfemale"
"hotgirl"
"hotwoman"
"hotwomen"
"hotman"
"hotmen"
"skype"
"whatsapp"
"maried"
"Shortclips"
"want"
"btm"
"kuzz"
"phudd"
"phudi"
"phuud"
"lulla"
"kanj*r"
"randi"
"choot"
"madarchod"
"chodu"
"kuss"
"wife"
"died"
"b2b"
"onlyboy"
"moth*r"
"shalwar"
"madarlun"
"husband"
"breast"
"breasst"
"69"
"h*tb*y"
"chikna"
}
set kickreasonxero "choose a more apropriate nick thank you"
bind join - * join:RanaUsmanxero
bind nick - * nick:tvrshxero
proc nick:tvrshxero {nick uhost hand chan newnick} {
join:RanaUsman $newnick $uhost $hand $chan
}
proc join:RanaUsmanxero {nick uhost hand chan} {
global bnickxero kickreasonxero temp
regsub -all -- {(.)\1+} $nick {\1} nick2x2
if {($nick != $::botnick)} {
set temp 0
foreach ixo [string tolower $bnickxero] {
if {[string match *$ixo* [string tolower $nick]] && ![string match -nocase *guest* $nick]} {
set badpart $ixo
set temp 1
}
}
}
if {!$temp} { return } {
pushmode $chan +b *$badpart*!*@*
putserv "kick $chan $nick :$kickreasonxero"
}
}
|
other similar tcls i came across seem to have a lot of extra bells and whistles
like setting bans on host and ident and such while we wanted to store and check on join with *nick*!*@* to see if any bad parts match
also lot of similar tcls that have pub command to add and del badnicks have
stored bad nicks in a text file so it would need to loop the file on each joining nick wich isnt effiecient when the list is potentially large.
Last edited by simo on Sat Mar 26, 2022 4:40 pm; edited 1 time in total |
|
Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1145 Location: France
|
Posted: Sun Mar 20, 2022 11:11 am Post subject: |
|
|
Well, I'm not sure I understand your questions.
You can easily store the nicks (or masks) in a file and have it loaded only when eggdrop starts (or script is loaded), the file will just be a memory to let you manage the list easily.
If you want to use masks rather than nicks, you'll have to compare ${nick}!${uhost} with the stored values, probably with a little check to know if you've stored a nick or an host.
And peharps the simplest way could be to create permanent bans in the eggdrop, so you don't care about the storage and the optimization:
Code: | foreach b $::bnickxero {
if {![string match *!*@* $b]} {
# $b is a nick, creating a host
set b $b!*@*
}
newban $b $::botnick "bad nick" 0
# you can also use newchanban if you don't want global ban
} |
_________________ Eggdrop community - French IRC network |
|
Back to top |
|
 |
simo Revered One
Joined: 22 Mar 2015 Posts: 1051
|
Posted: Mon Mar 21, 2022 4:12 am Post subject: |
|
|
Thanks for your reply cc the comparison part is fine i just was wondering if there would be a more efficient way of storing the list of bad nicks rather than a txt file unless it doesn't compromise performance having to loop through the text file on each join in channel
And of course the part that allows adding and removing bad nicks on the go with public command |
|
Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1145 Location: France
|
Posted: Mon Mar 21, 2022 5:10 am Post subject: |
|
|
As I said before, I think that storing bans in eggdrop (built-in list) is better than in any external source.
As you want to use masks (with wildcards), other solutions will require a loop to check if the user matches or not because lsearch doesn't work when the list contains masks.
You can use a database but you'll require a package (mysql or sqlite) and queries won't work with wildcards (same as lsearch).
So, with external storage, the only way is to use it to recreate the tcl list, and loop on this list.
Example with a text file:
Code: | set kbnicks {}
set dbfile "kbnicks.db"
# proc to load the file in $kbnicks variable
proc kbinit {} {
if {![file exists $::dbfile]} {
set fo [open $::dbfile w]
close $fo
}
set fi [open $::dbfile r]
set ::kbnicks [split [read -nonewline $fi] "\n"]
close $fi
}
# add a ban in variable
bind pub -|n !kbadd
proc kbadd {nick uhost handle chan text} {
# I don't do the tests and all features needed, just adding
lappend ::kbnicks $text
kbrewrite
}
# remove a ban in variable
bind pub -|n !kbrem
proc kbrem {nick uhost handle chan text} {
# do your checks
lreplace $::kbnicks [lsearch $::kbnicks $text] [lsearch $::kbnicks $text]
kbrewrite
}
# rewrite the file
proc kbrewrite {} {
set fo [open $::dbfile w]
foreach n $::kbnicks {
puts $fo $n
}
close $fo
}
# call to init on load / startup
kbinit |
With this code, you can store your base in a file and keep the actual way your script work (loop on $::kbnicks) _________________ Eggdrop community - French IRC network |
|
Back to top |
|
 |
simo Revered One
Joined: 22 Mar 2015 Posts: 1051
|
Posted: Tue Mar 22, 2022 6:05 am Post subject: |
|
|
Thanks CC i will try and work with that |
|
Back to top |
|
 |
|