Timing script

I’ve set up a script that can autoreply to ichat messages to control my house, get weather, ect. But now I want it to do this:

I send:
goodnight

over IM when I go to bed and then when I wake up I send:
goodmorning

When I send the goodmorning command, I want it to respond something like this:
Goodmorning Elijah! You’ve been sleeping for 8.8 hours.

In other words, I want it to find out the difference between the times of the two commands and tell that time to me.

MAYBE…even have it create a log of my sleep history, but HEY…just an idea… (-:

Any ideas?

Elijah

Model: iMac
Browser: Safari 531.22.7
Operating System: Mac OS X (10.6)

I’m not sure if this works (I haven’t had any time to sleep and test it… :P), but it should. It worked as a second timer. I then divided the result by 3600 (number of seconds in an hour), and in the end, it should return the number of hours.

I also don’t know how you read iChat messages, but here’s something to start from:

set startTime to time of (current date)
repeat until msg = "good morning"
	set endTime to time of (current date)
end repeat
set sleepHours to (endTime - startTime / 3600)

Good luck with this project! It’s a genius idea! I might end up stealin- er, borrowing it.

Let me know how it works,

-SuperScripter

Thanks so much SuperScripter!

I think I know how to impliment that…

Also, SuperScripter, if you want i’ll give you the code I have so far for my home automation project. Just email me at drummerboyx@verizon.net and I’ll give you the script and how to use it.