send commands via twitter

I would like to write a script that would allow me to send my computer commands via twitter from my phone, I would have an account and my computer would have its own account with which to be controlled. I would like to be able to do things like send a tweet “shutdown” and have my computer shutdown, or send some other command to run an applescript. How would I do this, I am fairly new to applescript and don’t have much experience.

any help would be greatly appreciated,
googleman76

You can try something along these lines:

In a separate script, use this to find the id of the account of the latest tweet (your target account) :

tell application "Twitter" to return author's user id of (item 1 of (status of (home timeline of account 1)))

Then populate the userId variable and remember to save it as a stay open application.
I’m tired so this still may be a bit buggy…

on idle
	set myIdle to 30 -- the delay in seconds before the script checks twitter for commands
	set myTriggers to {"beep", "say hello"}
	set userId to "816653" -- target account's user id
	
	-- You can get the user id of the most recent tweet like this:
	--tell application "Twitter" to return author's user id of (item 1 of (status of (home timeline of account 1)))
	
	tell application "Twitter"
		set tCount to count of (status of (home timeline of account 1))
		
		repeat with i from 1 to tCount
			set scriptDate to current date
			set {tDate, tAuthor, tText} to {date, author's user id, text} of (item i of (status of (home timeline of account 1)))
			set freshCheck to (scriptDate - tDate) -- How old is tweet in seconds
			if freshCheck < myIdle then
				if tAuthor = userId and tText is in myTriggers then -- If tweeted since last time checked and target user
					if tText = "beep" then
						tell me to beepHandler()
					else if tText = "say hello" then
						tell me to helloHandler()
					end if
				end if
			else -- the rest of the tweets have already been checked
				exit repeat
			end if
		end repeat
	end tell
	return myIdle
end idle

on beepHandler()
	beep
end beepHandler

on helloHandler()
	say "hello"
end helloHandler

Thanks, that helps, I am trying to do something like this

http://www.youtube.com/watch?v=z-wFXv8tDX4&feature=plcp

googleman76

It might be better to use the twitter API than to script the twitter application.

how would I go about that, when I looked at the twitter api and developer website I wasn’t able to find much information on applescript

googleman76

Twurl is an “OAuth-enabled curl for the Twitter API”.
https://github.com/marcel/twurl

If you want to use AppleScript to send commands to the shell, here is an article that discusses AppleScript and Twurl.
http://jimmitchell.org/2010/09/20/applescripttweet-updated-for-use-with-twurl/