Changeset 5214546


Ignore:
Timestamp:
Dec 19, 2009, 9:58:49 PM (15 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, release-1.10, release-1.7, release-1.8, release-1.9
Children:
22fce654
Parents:
9876953
git-author:
Nelson Elhage <nelhage@mit.edu> (12/19/09 18:57:20)
git-committer:
Nelson Elhage <nelhage@mit.edu> (12/19/09 21:58:49)
Message:
Add a twitter-retweet command
Location:
lib/BarnOwl/Module
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lib/BarnOwl/Module/Twitter.pm

    r176434d r5214546  
    256256);
    257257
     258BarnOwl::new_command( 'twitter-retweet' => sub { cmd_twitter_retweet(@_) },
     259    {
     260    summary     => 'Retweet the current Twitter message',
     261    usage       => 'twitter-retweet [ACCOUNT]',
     262    description => <<END_DESCRIPTION
     263Retweet the current Twitter message using ACCOUNT (defaults to the
     264account that received the tweet).
     265END_DESCRIPTION
     266    }
     267);
     268
    258269BarnOwl::new_command( 'twitter-follow' => sub { cmd_twitter_follow(@_); },
    259270    {
     
    304315    BarnOwl::start_edit_win("Reply to \@" . $user . ($account->nickname ? (" on " . $account->nickname) : ""),
    305316                            sub { $account->twitter_atreply($user, $id, shift) });
     317}
     318
     319sub cmd_twitter_retweet {
     320    my $cmd = shift;
     321    my $account = shift;
     322    my $m = BarnOwl::getcurmsg();
     323    if(!$m || $m->type ne 'Twitter') {
     324        die("$cmd must be used with a Twitter message selected.\n");
     325    }
     326
     327    $account = $m->account unless defined($account);
     328    find_account($account)->twitter_retweet($m);
    306329}
    307330
  • lib/BarnOwl/Module/Twitter/Handle.pm

    r9876953 r5214546  
    299299}
    300300
     301sub twitter_retweet {
     302    my $self = shift;
     303    my $msg = shift;
     304
     305    if($msg->service ne $self->{cfg}->{service}) {
     306        die("Cannot retweet a message from a different service.\n");
     307    }
     308    $self->twitter_command(retweet => $msg->{status_id});
     309}
     310
    301311sub twitter_follow {
    302312    my $self = shift;
Note: See TracChangeset for help on using the changeset viewer.