I want to make my egg tcl which kickban user on join in channel with a list of badnicks,which will be add from some operators. The problem is in the joining procedure, can i set the "black list" from file somwhere in eggdrop memory? Here is the code i`ve writen
Code: Select all
set ul(dbfile) "scripts/badnick-list.db"
set bchan ""
bind join - * join:badnick
bind pub l .addbnick save:nick
bind pub l .badnickload load:results
proc save:nick { nick uhost hand chan txt } {
global botnick ul
set msg [lrange $txt 0 end]
if { $txt == "" } {
putserv "PRIVMSG $chan :$nick, Please define bad nickname!"
return 0
} else {
putserv "PRIVMSG $chan :$msg Shte vi shiba za zakuska!!"
set file [open $ul(dbfile) "a"]
puts $file "$msg"
close $file
return 0
}
}
proc load:results { nick uhost hand chan txt } {
global botnick prefix ul
if {![file exist $ul(dbfile)]} {
putserv "PRIVMSG $chan :I have NO results for this request."
return 0
}
set file [open $ul(dbfile) r]
while {![eof $file]} {
set line [gets $file]
if {([string match "*" $line])} {
set bnick "[string range $line 0 end]"
putserv "PRIVMSG $chan :$bnick"
}
}
close $file
}
proc join:badnick {nick uhost hand chan} {
global bnick bchan kickreason temp
if {(([lsearch -exact [string tolower $bchan] [string tolower $chan]] != -1) || ($bchan == ""))} {
set temp 0
foreach i [string tolower $bnick] {
if {[string match *$i* [string tolower $nick]]} {
set temp 1
}
}
}
if {!$temp} { return } {
putquick "MODE $chan +b $nick"
putquick "KICK $chan $nick :$kickreason"
}
}