egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

badnick with database problem

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
e-force
Voice


Joined: 04 Jan 2005
Posts: 23

PostPosted: Tue Aug 29, 2006 10:28 am    Post subject: badnick with database problem Reply with quote

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
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Tue Aug 29, 2006 11:58 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
e-force
Voice


Joined: 04 Jan 2005
Posts: 23

PostPosted: Wed Aug 30, 2006 2:46 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
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


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber