| View previous topic :: View next topic |
| Author |
Message |
e-force Voice
Joined: 04 Jan 2005 Posts: 23
|
Posted: Tue Aug 29, 2006 10:28 am Post subject: badnick with database problem |
|
|
Hello there, i`ve search most of the topics here but i didn`t find any desicion on my problem. There it is:
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: | 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"
}
}
|
I`m afraid that if bot read the database.db file everytime when someone joining the channel it will load a bit. That`s why i`m searching for other way to slove the problem. Tnx in advice! |
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Tue Aug 29, 2006 11:58 pm Post subject: |
|
|
you haven't tried hard enough (looking up the forum for solution); if you had, you'd find my countless HOWTOs on the subject, which essentially say that you need to: (1) open the file on loading the script, (2) read the entire contents into memory (list) and then close the file, (3) manipulate that list only, not the file itself and (4) periodically save the list into file _________________ connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use [code] tag when posting logs, code |
|
| Back to top |
|
 |
e-force Voice
Joined: 04 Jan 2005 Posts: 23
|
Posted: Wed Aug 30, 2006 2:46 pm Post subject: |
|
|
| ok, tnx.I will search for HOWTOs in this forum, if you want, can post for me here the links.If not..i will continue with my search. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|