This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

badnick with database problem

Help for those learning Tcl or writing their own scripts.
Post Reply
e
e-force
Voice
Posts: 23
Joined: Tue Jan 04, 2005 7:10 pm

badnick with database problem

Post by e-force »

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: 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"
 }
}
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!
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

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: Select all

 tag when posting logs, code
e
e-force
Voice
Posts: 23
Joined: Tue Jan 04, 2005 7:10 pm

Post by e-force »

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.
Post Reply