vim modeline: # vim: set sts=4 expandtab:
[twirssi-net-twitter-lite.git] / twirssi.pl
index 6358591b9b6e4bfeffbea0b8e266a22239b61cde..b00fe807628e6d0c6e0e9ba664c8baf29d430da4 100644 (file)
@@ -6,20 +6,13 @@ use HTML::Entities;
 use File::Temp;
 use LWP::Simple;
 use Data::Dumper;
+use Net::Twitter;
 $Data::Dumper::Indent = 1;
 
-BEGIN {
-    $ENV{JSON_ANY_ORDER} = "JSON Syck DWIW";
-    require JSON::Any;
-    import JSON::Any;
-    require Net::Twitter;
-    import Net::Twitter;
-}
-
 use vars qw($VERSION %IRSSI);
 
-$VERSION = "1.7.3";
-my ($REV) = '$Rev: 354 $' =~ /(\d+)/;
+$VERSION = "1.7.5";
+my ($REV) = '$Rev: 374 $' =~ /(\d+)/;
 %IRSSI = (
     authors     => 'Dan Boger',
     contact     => 'zigdon@gmail.com',
@@ -28,7 +21,7 @@ my ($REV) = '$Rev: 354 $' =~ /(\d+)/;
       . 'Can optionally set your bitlbee /away message to same',
     license => 'GNU GPL v2',
     url     => 'http://tinyurl.com/twirssi',
-    changed => '$Date: 2009-01-08 14:46:04 -0800 (Thu, 08 Jan 2009) $',
+    changed => '$Date: 2009-01-19 23:31:12 -0800 (Mon, 19 Jan 2009) $',
 );
 
 my $window;
@@ -604,8 +597,11 @@ sub do_updates {
 
     unless ( ref $tweets ) {
         if ( $obj->can("get_error") ) {
+            my $error;
+            eval { $error = JSON::Any->jsonToObj( $obj->get_error() ) };
+            if ($@) { $error = $obj->get_error() }
             print $fh "type:debug API Error during friends_timeline call: ",
-              JSON::Any->jsonToObj( $obj->get_error() ), "  Aborted.\n";
+              "$error  Aborted.\n";
         } else {
             print $fh
               "type:debug API Error during friends_timeline call. Aborted.\n";
@@ -615,7 +611,7 @@ sub do_updates {
 
     foreach my $t ( reverse @$tweets ) {
         my $text = decode_entities( $t->{text} );
-        $text =~ s/(^|\W)\@([-\w]+)/$1\cC12\@$2\cC/g;
+        $text =~ s/(^|\W)\@([-\w]+)/$1\cC12\@$2\cO/g;
         $text =~ s/[\n\r]/ /g;
         my $reply = "tweet";
         if (    Irssi::settings_get_bool("show_reply_context")
@@ -631,7 +627,7 @@ sub do_updates {
 
             if ($context) {
                 my $ctext = decode_entities( $context->{text} );
-                $ctext =~ s/(^|\W)\@([-\w]+)/$1\cC12\@$2\cC/g;
+                $ctext =~ s/(^|\W)\@([-\w]+)/$1\cC12\@$2\cO/g;
                 $ctext =~ s/[\n\r]/ /g;
                 printf $fh "id:%d account:%s nick:%s type:tweet %s\n",
                   $context->{id}, $username,
@@ -668,7 +664,7 @@ sub do_updates {
           if exists $friends{ $t->{user}{screen_name} };
 
         my $text = decode_entities( $t->{text} );
-        $text =~ s/(^|\W)\@([-\w]+)/$1\cC12\@$2\cC/g;
+        $text =~ s/(^|\W)\@([-\w]+)/$1\cC12\@$2\cO/g;
         $text =~ s/[\n\r]/ /g;
         printf $fh "id:%d account:%s nick:%s type:tweet %s\n",
           $t->{id}, $username, $t->{user}{screen_name}, $text;
@@ -688,7 +684,7 @@ sub do_updates {
 
     foreach my $t ( reverse @$tweets ) {
         my $text = decode_entities( $t->{text} );
-        $text =~ s/(^|\W)\@([-\w]+)/$1\cC12\@$2\cC/g;
+        $text =~ s/(^|\W)\@([-\w]+)/$1\cC12\@$2\cO/g;
         $text =~ s/[\n\r]/ /g;
         printf $fh "id:%d account:%s nick:%s type:dm %s\n",
           $t->{id}, $username, $t->{sender_screen_name}, $text;
@@ -899,9 +895,10 @@ sub event_send_text {
 
     # if the window where we got our text was the twitter window, and the user
     # wants to be lazy, tweet away!
-    if ( ($awin->get_active_name() eq $window->{name})
-         and Irssi::settings_get_bool("tweet_window_input") ) {
-        &cmd_tweet($line, $server, $win);
+    if ( ( $awin->get_active_name() eq $window->{name} )
+        and Irssi::settings_get_bool("tweet_window_input") )
+    {
+        &cmd_tweet( $line, $server, $win );
     }
 }
 
@@ -1033,3 +1030,4 @@ if ($window) {
           . " or change the value of twitter_window.  Then, reload twirssi." );
 }
 
+# vim: set sts=4 expandtab: