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.

bind time not working properly

Help for those learning Tcl or writing their own scripts.
Post Reply
F
Fill
Halfop
Posts: 80
Joined: Sun Jan 18, 2009 6:08 pm

bind time not working properly

Post by Fill »

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?
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

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.
F
Fill
Halfop
Posts: 80
Joined: Sun Jan 18, 2009 6:08 pm

Post by Fill »

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"
}
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

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"
}
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

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:

Code: Select all

string trimleft $month "0"
NML_375
F
Fill
Halfop
Posts: 80
Joined: Sun Jan 18, 2009 6:08 pm

Post by Fill »

so how would it stay?

expr [[string trimleft $month "0"] +1] ??
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Rather this:
expr {[string trimleft $month "0"] + 1}
NML_375
Post Reply