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.
Help for those learning Tcl or writing their own scripts.
Fill
Halfop
Posts: 80 Joined: Sun Jan 18, 2009 6:08 pm
Post
by Fill » Fri Mar 13, 2009 9:11 am
Hi, I have a script that uses bind time events.
It does something like this:
[Fri-04:00:11am] * @RoBotX It is now: 04:00 AM. Uploading '/home/filipe/eggdrop/Triggers/triggerlog.txt' ««« 13/02/2009 »»»
See that? Everything is alright, but he says
««« 13/02/2009 »»» , it should be 13/
03 /2009
What the hell is going on with months?
Sir_Fz
Revered One
Posts: 3794 Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:
Post
by Sir_Fz » Fri Mar 13, 2009 9:28 am
Show us the code so we can see how the date-string is being generated. Also, make sure the date is correctly set on the system where your Eggdrop is operating.
Fill
Halfop
Posts: 80 Joined: Sun Jan 18, 2009 6:08 pm
Post
by Fill » Fri Mar 13, 2009 4:14 pm
Code: Select all
bind time - "00 04 * * *" prepareftp
proc prepareftp { minutes hour day month year } {
global lf ht us ps rf
sendftp $lf $ht $us $ps $rf
puthelp "PRIVMSG #cyber-world \001ACTION It is now: \002$hour:$minutes AM\002. Uploading '$lf' \002««« $day/$month/$year »»»\002"
}
Sir_Fz
Revered One
Posts: 3794 Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:
Post
by Sir_Fz » Fri Mar 13, 2009 7:56 pm
Like in Java, the first month is 00 and not 01. So all you need to do is to add 1 to the $month variable.
Code: Select all
bind time - "00 04 * * *" prepareftp
proc prepareftp { minutes hour day month year } {
global lf ht us ps rf
sendftp $lf $ht $us $ps $rf
puthelp "PRIVMSG #cyber-world \001ACTION It is now: \002$hour:$minutes AM\002. Uploading '$lf' \002««« $day/[expr {$month + 1}]/$year »»»\002"
}
nml375
Revered One
Posts: 2860 Joined: Fri Aug 04, 2006 2:09 pm
Post
by nml375 » Fri Mar 13, 2009 9:34 pm
Don't forget the 0-padding, making tcl think we're dealing with octals rather than integers. Simply using expr {$month + 1} won't work well, especially in September and October.
Something like this should take care of that though:
NML_375
Fill
Halfop
Posts: 80 Joined: Sun Jan 18, 2009 6:08 pm
Post
by Fill » Sat Mar 14, 2009 10:21 am
so how would it stay?
expr [[string trimleft $month "0"] +1] ??
nml375
Revered One
Posts: 2860 Joined: Fri Aug 04, 2006 2:09 pm
Post
by nml375 » Sat Mar 14, 2009 1:47 pm
Rather this:
expr {[string trimleft $month "0"] + 1}
NML_375