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 

bind time not working properly

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


Joined: 18 Jan 2009
Posts: 80

PostPosted: Fri Mar 13, 2009 9:11 am    Post subject: bind time not working properly Reply with quote

Hi, I have a script that uses bind time events.

It does something like this:

Quote:

[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?
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Fri Mar 13, 2009 9:28 am    Post subject: Reply with quote

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.
_________________
Follow me on GitHub

- Opposing

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


Joined: 18 Jan 2009
Posts: 80

PostPosted: Fri Mar 13, 2009 4:14 pm    Post subject: Reply with quote

Code:

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"
}
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Fri Mar 13, 2009 7:56 pm    Post subject: Reply with quote

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:
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"
}

_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Fri Mar 13, 2009 9:34 pm    Post subject: Reply with quote

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:
string trimleft $month "0"

_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Fill
Halfop


Joined: 18 Jan 2009
Posts: 80

PostPosted: Sat Mar 14, 2009 10:21 am    Post subject: Reply with quote

so how would it stay?

expr [[string trimleft $month "0"] +1] ??
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sat Mar 14, 2009 1:47 pm    Post subject: Reply with quote

Rather this:
expr {[string trimleft $month "0"] + 1}
_________________
NML_375, idling at #eggdrop@IrcNET
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