Ignore:
Timestamp:
Aug 4, 2009, 2:23:28 AM (12 years ago)
Author:
Kevin Riggle <kevinr@free-dissociation.com>
Branches:
master, release-1.7, release-1.8, release-1.9
Children:
4bd9327
Parents:
82e0f26
Message:
Add :twitter-follow and :twitter-unfollow commands
File:
1 edited

Legend:

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

    refcd223 r513da71  
    218218}
    219219
     220sub twitter_follow {
     221    my $account = shift;
     222
     223    if (defined $account) {
     224        my $handle = find_account($account);
     225        $handle->twitter_follow(@_);
     226    } elsif (defined $default_handle) {
     227        $default_handle->twitter_follow(@_);
     228    }
     229    else {
     230        $twitter_handles[0]->twitter_follow(@_);
     231    }
     232}
     233
     234sub twitter_unfollow {
     235    my $account = shift;
     236
     237    if (defined $account) {
     238        my $handle = find_account($account);
     239        $handle->twitter_unfollow(@_);
     240    } elsif (defined $default_handle) {
     241        $default_handle->twitter_unfollow(@_);
     242    }
     243    else {
     244        $twitter_handles[0]->twitter_unfollow(@_);
     245    }
     246}
     247
    220248BarnOwl::new_command(twitter => \&cmd_twitter, {
    221249    summary     => 'Update Twitter from BarnOwl',
     
    238266    usage       => 'twitter-atreply USER [ACCOUNT]',
    239267    description => 'Send a Twitter @reply Message to USER on ACCOUNT (defaults to default_sender,'
    240     . "or first service if no default is provided)"
    241     }
    242 );
    243 
     268    . "\nor first service if no default is provided)"
     269    }
     270);
     271
     272BarnOwl::new_command( 'twitter-follow' => sub { cmd_twitter_follow(@_); },
     273    {
     274    summary     => 'Follow a user on Twitter',
     275    usage       => 'twitter-follow USER [ACCOUNT]',
     276    description => 'Follow USER on Twitter ACCOUNT (defaults to default_sender, or first service'
     277    . "\nif no default is provided)"
     278    }
     279);
     280
     281BarnOwl::new_command( 'twitter-unfollow' => sub { cmd_twitter_unfollow(@_); },
     282    {
     283    summary     => 'Stop following a user on Twitter',
     284    usage       => 'twitter-unfollow USER [ACCOUNT]',
     285    description => 'Stop following USER on Twitter ACCOUNT (defaults to default_sender, or first'
     286    . "\nservice if no default is provided)"
     287    }
     288);
    244289
    245290sub cmd_twitter {
     
    270315    my $account = shift;
    271316    BarnOwl::start_edit_win("Reply to \@" . $user . (defined $account ? " on $account" : ""), sub { twitter_atreply($account, $user, $id, shift) });
     317}
     318
     319sub cmd_twitter_follow {
     320    my $cmd = shift;
     321    my $user = shift;
     322    die("Usage: $cmd USER\n") unless $user;
     323    my $account = shift;
     324    twitter_follow($account, $user);
     325}
     326
     327sub cmd_twitter_unfollow {
     328    my $cmd = shift;
     329    my $user = shift;
     330    die("Usage: $cmd USER\n") unless $user;
     331    my $account = shift;
     332    twitter_unfollow($account, $user);
    272333}
    273334
Note: See TracChangeset for help on using the changeset viewer.