diff --git a/html/using.html b/html/using.html index 485d50e..d0aa48e 100644 --- a/html/using.html +++ b/html/using.html @@ -45,6 +45,9 @@

Other Commands

posts by username, even for people who you do not follow
  • /twitter_del_follow_extra <username> - Stop showing all the posts by username
  • +
  • /twitter_info <username>:<num> - Show infos about + a remembered tweets. Only 100 are remembered for each user, and this can be + completely disabled by changing the twirssi_track_replies variable.
  • /twitter_list_follow_extra - Show the list of all the usernames in the extra follow loop
  • /twitter_list_subscriptions - List all the existing search diff --git a/twirssi.pl b/twirssi.pl index 9a0e2bd..58fd159 100644 --- a/twirssi.pl +++ b/twirssi.pl @@ -310,6 +310,73 @@ sub cmd_broadcast { } } +sub cmd_info { + my ( $data, $server, $win ) = @_; + + $data =~ s/^\s+|\s+$//; + unless ( $data ) { + ¬ice( ["info"], "Usage: /twitter_info " ); + return; + } + + $data =~ s/[^\w\d\-:]+//g; + my ( $nick_orig, $id ) = split /:/, $data; + my $nick = lc $nick_orig; + unless ( exists $state{ $nick } ) { + ¬ice( [ "info" ], + "Can't find any tweet from $nick_orig!" ); + return; + } + + $id = $state{__indexes}{$nick_orig} unless $id; + my $statusid = $state{$nick}[$id]; + unless ( $statusid ) { + ¬ice( [ "info" ], + "Can't find a tweet numbered $id from $nick_orig!" ); + return; + } + + my $account = $state{__accounts}{$nick}[$id]; + my $service = $state{__services}{$nick}[$id]; +# my $timestamp = $state{__created_ats}{$nick}[$id]; + my $tweet = $state{__tweets}{$nick}[$id]; + my $reply_to_id = $state{__reply_to_ids}{$nick}[$id]; + my $reply_to_user = $state{__reply_to_users}{$nick}[$id]; + my $type = $state{__types}{$nick}[$id]; + + ¬ice( [ "info" ], ",---------" ); + ¬ice( [ "info" ], "| nick: $nick_orig" ); + ¬ice( [ "info" ], "| id: $statusid" ); + ¬ice( [ "info" ], "| type: " . ($type ? $type : '') ); +# ¬ice( [ "info" ], "| time: " . ($timestamp ? DateTime->from_epoch( epoch => $timestamp ) : '') ); + ¬ice( [ "info" ], "| account: " . ($account ? $account : '' ) ); + ¬ice( [ "info" ], "| text: " . ($tweet ? $tweet : '' ) ); + + if ( $service ) { + ¬ice( [ "info" ], "| Service: $service" ); + if ( $service eq 'Twitter' ) { + ¬ice( [ "info" ], "| URL: http://twitter.com/$nick_orig/statuses/$statusid" ); + } elsif ( $service eq 'Identica') { + ¬ice( [ "info" ], "| URL: http://identi.ca/notice/$statusid" ); + } else { + ¬ice( [ "info" ], "| URL: " ); + } + } else { + ¬ice( [ "info" ], "| Service: " ); + ¬ice( [ "info" ], "| URL: " ); + } + + if ($reply_to_id and $reply_to_user) { + if ( $service eq 'Twitter' ) { + ¬ice( [ "info" ], "| ReplyTo: http://twitter.com/$reply_to_user/statuses/$reply_to_id" ); + } elsif ( $service eq 'Identica') { + ¬ice( [ "info" ], "| ReplyTo: http://identi.ca/notice/$reply_to_id" ); + } + } + ¬ice( [ "info" ], "`---------" ); + +} + sub cmd_reply { my ( $data, $server, $win ) = @_; @@ -1139,6 +1206,20 @@ sub load_friends { return ( $added, $removed ); } +sub get_reply_to { + # extract reply-to-information from tweets + my $t = shift; + + if ($t->{in_reply_to_screen_name} + and $t->{in_reply_to_status_id}) { + return sprintf 'reply_to_user:%s reply_to_id:%s ', + $t->{in_reply_to_screen_name}, + $t->{in_reply_to_status_id}; + } else { + return ''; + } +} + sub get_updates { print scalar localtime, " - get_updates starting" if &debug; @@ -1323,8 +1404,8 @@ sub do_updates { next if $t->{user}{screen_name} eq $username and not $settings{own_tweets}; - printf $fh "id:%s account:%s nick:%s type:%s %s\n", - $t->{id}, $username, $t->{user}{screen_name}, $reply, $text; + printf $fh "id:%s account:%s %snick:%s type:%s %s\n", + $t->{id}, $username, &get_reply_to($t), $t->{user}{screen_name}, $reply, $text; $new_poll_id = $t->{id} if $new_poll_id < $t->{id}; } printf $fh "id:%s account:%s type:last_id timeline\n", @@ -1355,8 +1436,8 @@ sub do_updates { if exists $friends{ $t->{user}{screen_name} }; my $text = &get_text( $t, $obj ); - printf $fh "id:%s account:%s nick:%s type:tweet %s\n", - $t->{id}, $username, $t->{user}{screen_name}, $text; + printf $fh "id:%s account:%s %snick:%s type:tweet %s\n", + $t->{id}, $username, &get_reply_to($t), $t->{user}{screen_name}, $text; $new_poll_id = $t->{id} if $new_poll_id < $t->{id}; } printf $fh "id:%s account:%s type:last_id reply\n", $new_poll_id, $username; @@ -1382,8 +1463,8 @@ sub do_updates { foreach my $t ( reverse @$tweets ) { my $text = decode_entities( $t->{text} ); $text =~ s/[\n\r]/ /g; - printf $fh "id:%s account:%s nick:%s type:dm %s\n", - $t->{id}, $username, $t->{sender_screen_name}, $text; + printf $fh "id:%s account:%s %snick:%s type:dm %s\n", + $t->{id}, $username, &get_reply_to($t), $t->{sender_screen_name}, $text; $new_poll_id = $t->{id} if $new_poll_id < $t->{id}; } printf $fh "id:%s account:%s type:last_id dm\n", $new_poll_id, $username; @@ -1422,8 +1503,8 @@ sub do_updates { foreach my $t ( reverse @{ $search->{results} } ) { my $text = &get_text( $t, $obj ); - printf $fh "id:%s account:%s nick:%s type:search topic:%s %s\n", - $t->{id}, $username, $t->{from_user}, $topic, $text; + printf $fh "id:%s account:%s %snick:%s type:search topic:%s %s\n", + $t->{id}, $username, &get_reply_to($t), $t->{from_user}, $topic, $text; $new_poll_id = $t->{id} if not $new_poll_id or $t->{id} < $new_poll_id; @@ -1464,8 +1545,8 @@ sub do_updates { my $text = &get_text( $t, $obj ); printf $fh - "id:%s account:%s nick:%s type:search_once topic:%s %s\n", - $t->{id}, $username, $t->{from_user}, $topic, $text; + "id:%s account:%s %snick:%s type:search_once topic:%s %s\n", + $t->{id}, $username, &get_reply_to($t), $t->{from_user}, $topic, $text; } } } @@ -1525,14 +1606,14 @@ sub get_timeline { if ($context) { my $ctext = &get_text( $context, $obj ); - printf $fh "id:%s account:%s nick:%s type:tweet %s\n", - $context->{id}, $username, + printf $fh "id:%s account:%s %snick:%s type:tweet %s\n", + $context->{id}, $username, &get_reply_to($context), $context->{user}{screen_name}, $ctext; $reply = "reply"; } } - printf $fh "id:%s account:%s nick:%s type:%s %s\n", - $t->{id}, $username, $t->{user}{screen_name}, $reply, $text; + printf $fh "id:%s account:%s %snick:%s type:%s %s\n", + $t->{id}, $username, &get_reply_to($t), $t->{user}{screen_name}, $reply, $text; $last_id = $t->{id} if $last_id < $t->{id}; } printf $fh "id:%s account:%s type:last_id_fixreplies %s\n", @@ -1570,7 +1651,7 @@ sub monitor_child { my $hilight = 0; my %meta; - foreach my $key (qw/id account nick type topic/) { + foreach my $key (qw/id account reply_to_user reply_to_id nick type topic/) { if (s/^$key:((?:\S|\\ )+)\s*//) { $meta{$key} = $1; $meta{$key} =~ s/%20/ /g; @@ -1578,8 +1659,9 @@ sub monitor_child { } # avoid internal breakage by sneaky nicknames + # to be added: created_ats next if ($meta{nick} and $meta{nick} =~ - /^__(indexes|windows|searches|fixreplies|tweets|last_tweet|last_id)$/); + /^__(indexes|windows|searches|fixreplies|tweets|last_tweet|last_id|accounts|services|reply_to_users|reply_to_ids|types)$/); if ( $meta{type} and $meta{type} eq 'fix_replies_index' ) { $fix_replies_index{ $meta{account} } = $meta{id}; @@ -1617,6 +1699,9 @@ sub monitor_child { $state{ lc $meta{nick} }[$marker] = $meta{id}; $state{__indexes}{ $meta{nick} } = $marker; $state{__tweets}{ lc $meta{nick} }[$marker] = $_; + foreach my $key (qw/account service reply_to_id reply_to_user type/) { # created_at + $state{"__${key}s"}{ lc $meta{nick} }[$marker] = $meta{$key}; + } $marker = ":$marker"; } @@ -1935,7 +2020,7 @@ sub sig_complete { if ( $linestart =~ - m{^/twitter_delete\s*$|^/(?:retweet|twitter_reply)(?:_as)?\s*$} + m{^/twitter_(?:delete|info)\s*$|^/(?:retweet|twitter_reply)(?:_as)?\s*$} or ( $settings{use_reply_aliases} and $linestart =~ /^\/reply(?:_as)?\s*$/ ) ) @@ -2276,6 +2361,7 @@ sub window_to_account { Irssi::command_bind( "retweet", "cmd_retweet" ); Irssi::command_bind( "retweet_as", "cmd_retweet_as" ); Irssi::command_bind( "twitter_broadcast", "cmd_broadcast" ); + Irssi::command_bind( "twitter_info", "cmd_info" ); Irssi::command_bind( "twitter_reply", "cmd_reply" ); Irssi::command_bind( "twitter_reply_as", "cmd_reply_as" ); Irssi::command_bind( "twitter_login", "cmd_login" );