Ignore:
Timestamp:
Aug 20, 2017, 4:38:40 PM (7 years ago)
Author:
Alex Dehnert <adehnert@mit.edu>
Children:
834dc31
Parents:
38c584e
git-author:
Edward Z. Yang <ezyang@cs.stanford.edu> (03/22/14 03:08:15)
git-committer:
Alex Dehnert <adehnert@mit.edu> (08/20/17 16:38:40)
Message:
Implement Twitter at-reply prefill semantics.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
File:
1 edited

Legend:

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

    r38c584e r1f69b54  
    265265);
    266266
     267BarnOwl::new_command( 'twitter-prefill' => sub { cmd_twitter_prefill(@_); },
     268    {
     269    summary     => 'Send a Twitter message with prefilled text',
     270    usage       => 'twitter-prefill PREFILL [ID [ACCOUNT]]',
     271    description => 'Send a Twitter message with initial text PREFILL on ACCOUNT (defaults to default_sender,'
     272    . "\nor first service if no default is provided)"
     273    }
     274);
     275
    267276BarnOwl::new_command( 'twitter-retweet' => sub { cmd_twitter_retweet(@_) },
    268277    {
     
    356365                            sub { $account->twitter_atreply($user, $id, shift) });
    357366    BarnOwl::Editwin::insert_text("\@$user ");
     367}
     368
     369sub cmd_twitter_prefill {
     370    my $cmd  = shift;
     371    # prefill is responsible for spacing
     372    my $prefill = shift || die("Usage: $cmd PREFILL [In-Reply-To ID]\n");
     373    my $id   = shift;
     374    my $account = find_account_default(shift);
     375
     376    my $msg = "What's happening?";
     377    if ($id) {
     378        # So, this isn't quite semantically correct, but it's close
     379        # enough, and under the planned use-case, it will look identical.
     380        $msg = "Reply to " . $prefill;
     381    }
     382    if ($account->nickname) {
     383        # XXX formatting slightly suboptimal on What's happening message;
     384        # and the behavior does not match up with 'twitter' anyhoo,
     385        # which doesn't dispatch through account_find_default
     386        $msg .= " on " . $account->nickname;
     387    }
     388    BarnOwl::start_edit_win($msg,
     389                            sub { $account->twitter_atreply(undef, $id, shift) });
     390    BarnOwl::Editwin::insert_text($prefill);
    358391}
    359392
Note: See TracChangeset for help on using the changeset viewer.