Tim Mattison

Hardcore tech

Update: Nicer Formatting for Cisco Twitter Timelines and Direct Message Support

| Comments

A savvy guy in Germany gave me some pointers on what could be improved in my previous post How-To: Get a Twitter timeline on a Cisco 7960. Rather than updating that one again and having it get lost I’ll put the newest stuff in new posts as they come up.

First, rather than getting your friends timeline he suggested, and modified the script, to only pull the direct messages. The change is straightforward and you can simply replace

$timeline = $twit->friends_timeline();


$timeline = $twit->direct_messages();

Second, the message formatting that comes from the API leaves a little bit to be desired. Therefore the two suggestions were to remove the “+0000” and move the year so it’s between the date and time. This change is a bit more tricky but can be done with regular expressions. For the first I did this

$input =~ s/ \+0000//g;

and for the second I did this

$input =~ s/^([^ ]*) *([^ ]*) *([^ ]*) *([^ ]*) *([^ ]*) *([^ ]*) *([^ ]*):/$1 $2 $3 $4 $5 $7 $6:/;

Put whichever of these you’d like (or both) right before

return $input

in the fix_cisco_issues subroutine. Make sure you copy them

exactly or they can break the script.

If you run into any trouble (ie. blank Cisco screen after doing the updates), run the script on the command-line and see if there are any errors showing up on STDERR. Usually, it’s just a typo so pay attention to the error output and patch it up!