Changeset 140429f


Ignore:
Timestamp:
Jan 23, 2014, 5:52:26 PM (4 years ago)
Author:
Nelson Elhage <nelhage@nelhage.com>
Branches:
master
Children:
5f3f1e4
Parents:
0d53dfb
Message:
Implement :twitter-favorite
Location:
perl/modules/Twitter/lib/BarnOwl/Module
Files:
2 edited

Legend:

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

    r7ff3907 r140429f  
    276276);
    277277
     278BarnOwl::new_command( 'twitter-favorite' => sub { cmd_twitter_favorite(@_) },
     279    {
     280    summary     => 'Favorite the current Twitter message',
     281    usage       => 'twitter-favorite [ACCOUNT]',
     282    description => <<END_DESCRIPTION
     283Favorite the current Twitter message using ACCOUNT (defaults to the
     284account that received the tweet).
     285END_DESCRIPTION
     286    }
     287);
     288
    278289BarnOwl::new_command( 'twitter-follow' => sub { cmd_twitter_follow(@_); },
    279290    {
     
    357368    $account = $m->account unless defined($account);
    358369    find_account($account)->twitter_retweet($m);
     370    return;
     371}
     372
     373sub cmd_twitter_favorite {
     374    my $cmd = shift;
     375    my $account = shift;
     376    my $m = BarnOwl::getcurmsg();
     377    if(!$m || $m->type ne 'Twitter') {
     378        die("$cmd must be used with a Twitter message selected.\n");
     379    }
     380
     381    $account = $m->account unless defined($account);
     382    find_account($account)->twitter_favorite($m);
    359383    return;
    360384}
  • perl/modules/Twitter/lib/BarnOwl/Module/Twitter/Handle.pm

    r0d53dfb r140429f  
    429429}
    430430
     431sub twitter_favorite {
     432    my $self = shift;
     433    my $msg = shift;
     434
     435    if($msg->service ne $self->{cfg}->{service}) {
     436        die("Cannot favorite a message from a different service.\n");
     437    }
     438    $self->twitter_command(create_favorite => $msg->{status_id});
     439}
     440
     441
    431442sub twitter_follow {
    432443    my $self = shift;
Note: See TracChangeset for help on using the changeset viewer.