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.

read from a .txt file...

Old posts that have not been replied to for several years.
Locked
b
blarre
Voice
Posts: 15
Joined: Sun Apr 28, 2002 8:00 pm

Post by blarre »

hi, can anyone pleas help me whit a script i whant to have...

when someone write !nextlan
then the bot will
read from a .txt file
and only the lines that are after the day now...
so if its 2002-05-12 now then the bot only shows the line who are posted after 2002-05-12

kan someone help me??
S
Shocky

Post by Shocky »

Well, the smartest way would be like this:
(I'de redo your date system, I personally like YYYYMMDD plain format, makes comparisons, easy, but if you don't wanna change the data you can simply read the datain and format the string.. easy enough)

a) create a binding for the trigger to execute the procedure.
b) in the procedure start a statement like
set mychan "#shellbox.net" <-- You could also just use $channel is it's a channel based argument.. up to you.
set filein [open "mytext.dat" r]
set today [clock format -format "%Y%m%d" [clock seconds]]
while {![eof $filein]} {
gets $filein datain
if {[lindex ${datain} 0] >= $today} {
putserv "PRIVMSG $mychan :${datain}"
}
}
close $filein

Grab a tcl manual (www.tcl.tk) and your tcl-commands.doc, this should set you in the right direction for making it how you want it done.
b
blarre
Voice
Posts: 15
Joined: Sun Apr 28, 2002 8:00 pm

Post by blarre »

hehe, thanks... hope i can make that file...
G
Gatekeeper-97

Post by Gatekeeper-97 »

Wow.. that was almost what I needed too :razz:
How do I make my tcl read from a file like this one:
---file---
[leeloo]
age=25
sex=female
---eof---

So that if someone type "!leeloo" my eggie says "leeloo is 25 years old and female" ?
Thanx for help

<font size=-1>[ This Message was edited by: Gatekeeper-97 on 2002-06-04 22:01 ]</font>

<font size=-1>[ This Message was edited by: Gatekeeper-97 on 2002-06-04 22:02 ]</font>
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Is that an ini file?

Look around some (google?) and you'll find lots of ini parsers that read and write files for you. Here's one of the first results on google:

http://mini.net/tcl/3295
G
Gatekeeper-97

Post by Gatekeeper-97 »

On 2002-06-05 00:43, stdragon wrote:
Is that an ini file?
- Yes
On 2002-06-05 00:43, stdragon wrote:
Here's one of the first results on google:

http://mini.net/tcl/3295
- What did you search for (what were your search string?)


----

You see.. What I want to do is that some how I want my eggie to "answer" on triggers an take the answers from the ini file.

"!lisa" returns "notice $nick : $person is $age yeas old."

there $person tells the script to search in "lisa" (1)
and $age in age (2)

---inifile---
[lisa] (1)
age=25 (2)
----eof----


The one that you (stdragon) posted didnt help me very much.. either Im to dump or that were the wring ting....

Thanx for help


<font size=-1>[ This Message was edited by: Gatekeeper-97 on 2002-06-05 03:05 ]</font>
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

I searched for "ini parser for tcl" heh. What did you search for?
G
Gatekeeper-97

Post by Gatekeeper-97 »

(1)+ini +eggdrop
(2)+windrop +ini
(3)inireader
and some more...
G
Gatekeeper-97

Post by Gatekeeper-97 »

But is there a "ini parser for tcl" I need?
Really dont know how I am supposed to solove this problem. I really need to be albe to read from ini files inside mi tcl script...

--------------------

Noticed that lots of tcl scripts uses .db files.. How do you setup data in those files? Are they like .ini files for mIRC? Are there any spec. commands for .db files like there is in mIRC for .ini files?

<font size=-1>[ This Message was edited by: Gatekeeper-97 on 2002-06-05 04:34 ]</font>
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

The script I posted a link to shows how to read through an ini file and get all the values you need. If you don't understand it, try downloading it and playing around with it for a while. It's a good idea to have the Tcl Command Manual open in another window, so you can always tell what the script is doing.

Once you understand that script, you'll be able to finish writing your own script with no problems (probably!).

Just remember, if you're serious about learning how to script for eggdrops, it will take time and patience like anything else :)

<font size=-1>[ This Message was edited by: stdragon on 2002-06-05 05:02 ]</font>
Locked