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 

Database question?

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


Joined: 23 Jul 2006
Posts: 40

PostPosted: Mon Jan 01, 2007 7:31 pm    Post subject: Database question? Reply with quote

I currently use a text file that is named as a .dat to store my eggdrop's custom settings and variables, which is loaded and saved on each load. However, it wipes like weekly to bi-weekly. I think it may have something to do with the way I sync or it could be the file system. Yes, mIRC colour codes are stored within the file if that means anything.

Sync/Load code:
Code:
proc sync {} {
        global head tail delim djlist datafile cmdlist website public_channel p$

        if { [file exists $datafile] } {

                set FD [open $datafile r]
                set djlist ""
                while { ![eof $FD] } {
                        gets $FD line
                        set index [string first ":" $line ]
                        set name [string range $line 0 [expr {$index - 1}]]
                        set value [string range $line [expr {$index + 1}] end ]

                        switch -exact $name {

                                "head" {
                                        set head $value
                                }
                              "tail" {
                                        set tail $value
                                }

                                "delim" {
                                        set delim $value
                                }

                                "dj" {
                                        lappend djlist $value
                                }

                                "cmdlist" {
                                        set cmdlist $value
                                }

                                "website" {
                                        set website $value
                                }

                                "public_channel" {
                                        set public_channel $value
                                }

                                "private_channel" {
                                        set private_channel $value
                                }

                                "shoutcast" {
                                        set shoutcast $value
                                }

                                "shoutport" {
                                        set shoutport $value
                                }
                                "shoutpass" {
                                        set shoutpass $value
                                }

                                "topicmask" {
                                        set topicmask $value
                                }

                                "stream" {
                                        set stream $value
                                }

                                "rules" {
                                        set rules $value
                                }

                                "autodj" {
                                        set autodj $value
                                }

                                "greet1" {
                                        set greet1 $value
                                }

                                "greet2" {
                                        set greet2 $value
                                }
                                "greet3" {
                                        set greet3 $value
                                }

                                "ads" {
                                        set ads $value
                                }

                                "friends" {
                                        set friends $value
                                }

                                "schedules" {
                                        set schedules $value
                                }

                        }
                }
                close $FD
        }
}



Flush/Save code:
Code:
proc battle:flush {} {
        global head tail delim djlist datafile cmdlist website public_channel pr$
        set FD [open $datafile w]

        puts $FD "cmdlist:$cmdlist"
        puts $FD "head:$head"
        puts $FD "tail:$tail"
        puts $FD "delim:$delim"
        puts $FD "website:$website"
        puts $FD "topicmask:$topicmask"
        puts $FD "shoutcast:$shoutcast"
        puts $FD "shoutport:$shoutport"
        puts $FD "shoutpass:$shoutpass"
        puts $FD "public_channel:$public_channel"
        puts $FD "private_channel:$private_channel"
        puts $FD "stream:$stream"
        puts $FD "rules:$rules"
        puts $FD "autodj:$autodj"
        puts $FD "greet1:$greet1"
        puts $FD "greet2:$greet2"
        puts $FD "greet3:$greet3"
        puts $FD "ads:$ads"
        puts $FD "friends:$friends"
        puts $FD "schedules:$schedules"
        foreach dj $djlist {
                puts $FD "dj:$dj"
        }
        close $FD
}


Basically: I want to solve the problem of it wiping itself. I'm more convinced its the linux file system not liking the colour codes or something though, as both of my backup files got wiped too.
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Mon Jan 01, 2007 7:36 pm    Post subject: Reply with quote

Why don't you save them in the form:
Quote:
set var1 bla
set var2 blo
...

and simply source the file.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
Nara
Halfop


Joined: 23 Jul 2006
Posts: 40

PostPosted: Tue Jan 02, 2007 12:31 am    Post subject: Reply with quote

Because I never knew you could do that. So, just put them in a blank file, name it .tcl, and load it before the script in the eggdrop configuration?
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Tue Jan 02, 2007 7:16 am    Post subject: Reply with quote

Yes, or you can load it inside the script before the code starts (i.e. add source scripts/variables.tcl before starting the code).

PS: It doesn't have to be a .tcl file, that's just a standard.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
metroid
Owner


Joined: 16 Jun 2004
Posts: 771

PostPosted: Wed Jan 03, 2007 12:28 pm    Post subject: Reply with quote

source can load any file, it just won't react too well on non-tcl code.

you can give it any extension you want, or no extension at all.
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