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 

Time Help

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


Joined: 29 Aug 2006
Posts: 82

PostPosted: Fri May 11, 2007 3:09 pm    Post subject: Time Help Reply with quote

set math [expr [clock seconds] - $typl]
putlog "$math"

or

set math [expr [unixtime] - $typl]
putlog "$math"


what would be better is

set maxtime 300
if {[expr [unixtime]-[clock scan $typl]]>=$maxtime} {
putlog "$maxtime"

but that wont even work =/


i tried putting the put log in for some de bugging and it wouldnt return anything Sad

i have no idea why

time is stored in the db as: 2007-05-03 12:35:25
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Fri May 11, 2007 3:37 pm    Post subject: Reply with quote

Do you think you could atleast try to explain what you try to achieve, and how your results differ from that?
Also, what would "typl" typically be? What could it be?
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Ace-T
Halfop


Joined: 29 Aug 2006
Posts: 82

PostPosted: Fri May 11, 2007 5:00 pm    Post subject: Reply with quote

ok found my problem

its cause the times not stored in unix time stamp so i need to get it into that now..

but cant seem to do it Sad

here is my query

set sql "INSERT INTO test VALUES(null, 'TEST', '$text1', '$type', unix_timestamp(now))"

but wont work >_>
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Fri May 11, 2007 5:15 pm    Post subject: Reply with quote

Right now I can't make heads and tails about what it is you are asking help with... You're just posting fragments that really does'nt make much sense by their own...

If you are asking for help on constructing a valid sql-query, we'd need help on which dialect of sql you're using (mysql, postgresql, mssql, etc), the actual layout of your database and so forth...

What I can say, atleast for mysql, is that it is advisable to supply a column-list with INSERT-queries (although not required).

http://dev.mysql.com/doc/refman/4.1/en/index.html might also be worth a visit.
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Ace-T
Halfop


Joined: 29 Aug 2006
Posts: 82

PostPosted: Fri May 11, 2007 5:27 pm    Post subject: Reply with quote

to be all honest all i want is something like thsi working

set maxtime 300
if {[expr [unixtime]-[clock scan $typl]]>=$maxtime} {
putlog "$maxtime"

my time in sql is not in unix time stamps so the code is useless atm,
$typl is just a table i made to store the date time ( like 00-00-00 00:00:00)

i basically need the code to only say some text in irc if the time is under 300 secs, ive been searching the forums for hours for an answer.
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Fri May 11, 2007 5:41 pm    Post subject: Reply with quote

If you just want something to work, you'd be better off posting under "Script Requests".

$typl is not a table.. it's a variable.. If the value is retrieved from a sql-database using a query, say so.

That said, most time/date formats used by various sql-dialects can be directly interpreted using "clock scan". The date in your first post works just fine with "clock scan" (tested with: clock format [clock scan "2007-05-03 12:35:25"]). If you are using some different date/time-format, please specify it.'

Also, you say it should respond if the time delta is less than 300, yet your test in the conditional is wether it is actually greater or equal than 300...
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Ace-T
Halfop


Joined: 29 Aug 2006
Posts: 82

PostPosted: Fri May 11, 2007 5:56 pm    Post subject: Reply with quote

right,

time is stored in the db as: 2007-05-03 12:35:25

i want the code to react to if under 300 secs

and im sure this line does NOT work due to my time not being stored as unixtime, code here -> if {[expr [unixtime]-[clock scan $typl]]<=$maxtime} {


also

Quote:

$typl is not a table.. it's a variable.. If the value is retrieved from a sql-database using a query, say so.


yeh i didnt read back what wrote just stressed cause i cant seem to fix this Sad
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Fri May 11, 2007 6:04 pm    Post subject: Reply with quote

Then why don't you re-read the last line in my previous post...

Code:
expr [unixtime]-[clock scan "2007-05-03 12:35:25"]
returned a value of 732398 for me, which is quite larger than 300, and hence the conditional would be true, and whatever code you have within your if-statement would be executed.
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Ace-T
Halfop


Joined: 29 Aug 2006
Posts: 82

PostPosted: Fri May 11, 2007 6:22 pm    Post subject: Reply with quote

set maxtime 3000000000000000000000
if {[expr [unixtime]-[clock scan $typl]]<=$maxtime} {

putquick "PRIVMSG $channel : TEST -> WORKING"
return 0
}


just tried that and it dont work, so im lost.
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Fri May 11, 2007 6:29 pm    Post subject: Reply with quote

Try setting maxtime to something alittle smaller, that won't overflow. Such as 2000000...
In any case, have you tried printing the actual value that you're comparing: ie putlog "$typl : [expr [unixtime] - [clock scan $typl]]", so that you can see what is actually going on?
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Ace-T
Halfop


Joined: 29 Aug 2006
Posts: 82

PostPosted: Fri May 11, 2007 6:43 pm    Post subject: Reply with quote

nothing at all in logs =/
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Fri May 11, 2007 6:54 pm    Post subject: Reply with quote

Then, without knowing the contents of your script, there's not much else I can do...
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Ace-T
Halfop


Joined: 29 Aug 2006
Posts: 82

PostPosted: Sat May 12, 2007 5:43 am    Post subject: Reply with quote

i would like to say thx for the guidance Smile

i have completed my mission and have it fully working now Smile
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