David A. Harding
Saturday, 08 Nov 2008
Humpty Dumpty sat on a wall.
Humpty Dumpty had a great fall.
All the king's horses and all the king's men
Couldn't put Humpty together again.
When I began using Twitter, I entered my XMPP (Jabber) address and had my friends' updates sent straight to my instant messaging client. Those updates made me feel like Twitter was a convenient chatroom filled with updates from my best friends, and despite my initial reservations about the service, I became addicted. But my addiction was suddenly curtailed when, without announcement, the Twitter Jabber service went down and never came back up. Although started as a temporary service outage, Twitter recently announced they are suspending their Jabber service indefinitely.
In the months since the Twitter Jabber service went down, I've tried nearly every free software Twitter client, but none of them made me happy.[1] I want Twitter Jabber back. I guess I'll have to do it myself.
The program, twidge, is a full-featured command-line Twitter
client. It's a recent addition to Debian Unstable and may not be
packaged for other free software operating systems. Yet it
only has two dependencies -- both common -- and can be readily installed
on any Unix-style operating system. After you tell it your Twitter
username and password by running twidge setup, you can get a list of
your recent unseen updates in the following format by running the
following command:
twidge lsrecent -us <loxosceles> 20K and going strong. #nanowrimo <dossy> Are Twitter spammers called Spitters? <pleia2> Mmmm, naps
The -us, which is optional, makes twidge show only (u)nseen updates while (s)aving the identifier of the most recent message so you don't see it or older messages the next time you use -u.
The program, sendxmpp, is a XMPP (Jabber) client that works
similar to the classic BSD mailx command. It's been around for several
years and is probably in most major distributions. Even if it's not in
your distribution, its only requirements are perl and the Jabber perl
module, which should be easy to obtain. After you tell it your Jabber
username and password by editing ~/.sendxmpp, you can send a Jabber to
me by running the following command[2]:
echo "Hello, Dave." | sendxmpp dharding@jabber.org
Although I enjoy feedback from my readers, you'll get better results from this and following examples if you replace my Jabber address with yours.
After you've set up both twidge and sendxmpp, you can very simply connect them together:
twidge lsrecent -us | sendxmpp dharding@jabber.org
When generating output, twidge automatically wraps lines so that they appear nicely formatted in a terminal. But when sent to my Jabber client, the wrapped lines look ugly, so I use twidge's -l option to generate detailed unwrapped output and then remove the details I don't want:
twidge lsrecent -usl | cut -f2,4 | sendxmpp dharding@jabber.org
In the above command, sendxmpp sends an empty Jabber message to me even when there are no new Twitter updates. That isn't a problem for me: my Jabber client automatically ignores empty messages. But if you have problems with empty messages, I suggest you install the moreutils suite of command-line utilities and use the If Not Empty program. For example:
twidge lsrecent -usl | cut -f2,4 | ifne sendxmpp dharding@jabber.org
The original Twitter Jabber sent updates as soon as they arrived. There's no way to duplicate that with the above command, but during the months since Twitter Jabber died, I've become used to a five-minute delay between updates, so I use my crontab to send me the most recent twitters every five minutes:
## Jabber me unseen twitters
*/5 * * * * twidge lsrecent -usl | cut -f2,4 | sendxmpp dharding@jabber.org
(Please don't put my Jabber address in your crontab. If I start receiving all of your friends' Twitter updates, I'll be forced to block you, which I don't want to do.)
Although you'll automatically receive Twitter updates in Jabber now, you still won't be able to send them through Jabber. If that's important to you, I suggest you examine the excla.im service. It's not important to me; I just type:
twidge update "My new Twitter setup (with Jabber!): http://gnuisance.net/blog/t/2008/twitter-jabber.html"
Passing your Twitters through a pipe before reading them creates many new opportunities. I'm excited that it lets me filter out uninteresting posts from people I otherwise find interesting. For example, my friend John LeMasney recently started Twittering every song he listens to:
<lemasney> I am listening to: Megadeth - One Thing
<lemasney> I am listening to: Megadeth - Megadeth - Paranoid
<lemasney> I am listening to: Megadeth - Never Say Die
...
I had to unsubscribe from John because his numerous minor updates hide his and my other friends' major updates, but now I can re-subscribe to John and filter out the updates I don't want to see:
twidge lsrecent -usl | cut -f2,4 | grep -v 'lemasney.*I am listening to: ' | sendxmpp dharding@jabber.org
With a little programing, which I haven't done yet, I can even direct unimportant updates to a file that gets automatically emailed to me once a day while sendxmpp continues to send me important and uncategorized updates. This makes me happy: I not only got back a feature I've been missing, but I got a new feature too.
[1] Every graphical Twitter client I used had much the same interface -- a copy of the Twitter web interface. That isn't the only way to present micro-blogging data, and I doubt it's the best way either. Moreover, development on Twitter clients seemingly ceases after duplicating the Twitter web interface: no client I used had any significant advanced features.
[2] The Jabber message format sent by sendxmpp is not compatible with all Jabber clients, including the popular Pidgin instant messager. Pidgin, for example, silently drops any messages from sendxmpp. There's a configuration file and command line option to sendxmpp that make it send Jabber messages Pidgin can read, but, unfortunately, both are broke in the version of sendxmpp on Debian; I'll file a Debian bug report when I discover why. For now, you can edit the sendxmpp file (a perl script) and find the following line:
my $message_type = 'message'; # default message type
Then replace it with the following line and save:
my $message_type = 'chat'; # default message type