Update Here is a Cocoa version that is…
Update: Here is a Cocoa version that is easier to use!
May did a good job selling us on Twitter, so now you can see my twittr status in the sidebar.. I wished that changing my Twitter status was as easy as changing my iChat status, so I hacked up this bit of perl that will update it when your iChat status changes. It runs every five minutes via launchd, and uses the newly-announced Twitter API.
#!/usr/bin/perl use strict; use warnings; use URI::Escape; my $user = 'user@example.com'; my $pass = 'pin'; my $isAvailable = `osascript -e 'tell application "iChat" to status'`; chomp $isAvailable; exit if ('available' ne $isAvailable); my $status = `osascript -e 'tell application "iChat" to status message'`; chomp $status; if ('' eq $status) { $status = 'lazy'; } my $savedStatusFile = 'savedStatus.txt'; my $savedStatus = ''; if (-e $savedStatusFile) { $savedStatus = `cat $savedStatusFile`; } if ($status ne $savedStatus) { #status changed, update twitter my $encStatus = 'status=' . uri_escape($status, "^A-Za-z0-9"); `curl -s -d '$encStatus' -u $user:$pass http://twitter.com/statuses/update.xml`; open (FILE, ">$savedStatusFile") or die "can't open $savedStatusFile for writing"; print FILE $status; close FILE; }
You can get launchd to run the script every five minutes by creating a file called ~/Library/LaunchAgents/net.tikirobot.status.plist that looks like this:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple. com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>net.tikirobot.status</string> <key>ProgramArguments</key> <array> <string>/Users/user/status.pl</string> </array> <key>StartInterval</key> <integer>300</integer> </dict> </plist>
And then load the job using:
launchctl load ~/Library/LaunchAgents/net.tikirobot.status.plist
Update: The script now uses URI::URL and POST. Fixed a typo.
Update2: Now uses URI::Escape
rajbot 1:17 am on September 24, 2006 Permalink | Log in to Reply
Why oh why does our theme make source code look like shit?
peliom 2:03 pm on September 24, 2006 Permalink | Log in to Reply
I dunno … I changed it to use the “pre” tag and it was even worse. We need to go find someones source code CSS and lift it …..
rajbot 4:48 pm on September 24, 2006 Permalink | Log in to Reply
How can WordPress/our stupid theme fuck up even the pre tag?
And you know what else? When you try to edit the post, WordPress translates all ampersand-l-t-semicolons back into angle brackets, and you have to manually change them back.
To make the problem even worse, Apple’s plist format is stupidly verbose. I’m only setting two parameters. The xml should be as simple as this:
<cron>
<path>/full/path/blah.pl</path>
<interval>300</interval>
</cron>
rajbot 10:52 pm on September 24, 2006 Permalink | Log in to Reply
OK, the ig:syntax hiliter is now installed, and things look much better. I found it on this list of wordpress syntax highlighters.
Jessica 6:55 pm on October 10, 2006 Permalink | Log in to Reply
just testing this thing out :)
Jessica 7:00 pm on October 10, 2006 Permalink | Log in to Reply
TESTING :)
dydimustk 12:57 am on October 11, 2006 Permalink | Log in to Reply
This looks awesome and I want to give it a try, but permissions are flaked. I made status.pl 777. but I still get this in the console:
Oct 11 02:43:14 adamnan launchd[2485]: net.tikirobot.status: execvp(“/Users/Dydimustk/status.pl”, …): Permission denied
Oct 11 02:43:14 adamnan launchd[2482]: net.tikirobot.status: execve(): Permission denied
rajbot 8:41 am on October 11, 2006 Permalink | Log in to Reply
dydimustk, does status.pl work for you if you run it from the command line? Stupid launchd…
dydimustk 12:38 pm on November 12, 2006 Permalink | Log in to Reply
Sorry that I didn’t get back to you till now. I did get it to work with a little messing around in launchd. But I wanted to mention, that I want to try and get this to work in reverse now as well. So that iChat will grab its status from twitter. If I get it working, I’ll post it here.
Seth 12:15 pm on January 18, 2007 Permalink | Log in to Reply
I want this to work the other way around… when I change my Twitter info, I want *that* to become my iChat status message.
Can that be done?
rajbot 1:38 pm on January 18, 2007 Permalink | Log in to Reply
Sure.. you will have to change the script a bit, but it’s not too hard.
If you don’t want to mess with it yourself, I might be able to do it in a few days when I get some time…
ChrisW 3:12 pm on January 20, 2007 Permalink | Log in to Reply
Thanks for posting something like this. Unfortunately, I can’t get it to work. I’m getting something like this in the Terminal:
chrischris:~ chris$ launchctl load ~/Library/LaunchAgents/net.twitter.status.plist
launchctl: propertyList is NULL
launchctl: no plist was returned for: /Users/chris/Library/LaunchAgents/net.twitter.status.plist
launchctl: no plist was returned for: /Users/chris/Library/LaunchAgents/net.twitter.status.plist
nothing found to load
Don’t know what I’m doing wrong. Please help!
rajbot 1:35 am on January 29, 2007 Permalink | Log in to Reply
OK, I made a Cocoa version that is much easier to use. You can get it here
TikiRobot!, Mai Tais and Blinky Lights, Ahoy! » Update Twitter via iChat status message, part II 12:10 am on May 1, 2007 Permalink | Log in to Reply
[...] while back I posted a perl script that would update your Twitter status whenever you changed your iChat status message. [...]
My Weblog 7:35 am on December 3, 2007 Permalink | Log in to Reply
[...] Updating Twitter via iChat or AIM status message [...]
Ryan 11:09 am on November 10, 2008 Permalink | Log in to Reply
Those who are getting ‘propertyList is NULL’ errors…you can run this at the command-line to debug your XML errors:
perl -MXML::Parser -e ‘$p = new XML::Parser(Style=>”Debug”); $p->parsefile(“your_file.plist”);’
It’ll spit out any errors the parser finds.
Have Your Quake And Twitter It Too « FAGEINC⋟ 3:42 am on April 6, 2011 Permalink | Log in to Reply
[...] of their Twitters up there which is neat. More importantly, they’ve hacked our api so that an iChat status automatically publishes as a Twitter status. Thus, they have gotten right down to the roots of what Twitter is all about. [...]