Skip to content
This repository has been archived by the owner on Nov 28, 2023. It is now read-only.

Commit

Permalink
Beta testers suggest that rta suggests a retweet-related command. Since
Browse files Browse the repository at this point in the history
we haven't publicized this yet, there's no harm in changing the project
name and removing ambiguity.
  • Loading branch information
Ben Cotton committed Nov 2, 2011
1 parent 553e5f5 commit 88ecd7f
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 5 deletions.
8 changes: 4 additions & 4 deletions README.txt
@@ -1,20 +1,20 @@
ttytter-rta.pl -- a TTYtter extension
ttytter-r2a.pl -- a TTYtter extension

Copyright (C) 2011 by Ben Cotton
Licensed under GNU Public License v2.0. See LICENSE.txt for
full license.

Project website: https://github.com/funnelfiasco/ttytter-rta
Project website: https://github.com/funnelfiasco/ttytter-r2a

ttytter-rta.pl is an extension that adds "reply-to-all" functionality to
ttytter-r2a.pl is an extension that adds "reply-to-all" functionality to
TTYtter. The usage is identical to the built-in '/reply' command. To reply to
all users mentioned in a tweet, the syntax is:
/replytoall <tweet_id> <reply_status>

For example:
/replytoall f2 oh yeah? Well check out this cool @TTYtter extension I wrote!

The lazy typist can also use /replyall or /rta. Commands are case-insensitive
The lazy typist can also use /replyall or /ra. Commands are case-insensitive
for the benefit of users running a DRUNKHULK-type account or who really like to
yell at others on the Internet.

Expand Down
62 changes: 62 additions & 0 deletions ttytter-r2a.pl
@@ -0,0 +1,62 @@
###################
#
# ttytter-r2a.pl -- a TTYtter extension
#
# Copyright (C) 2011 by Ben Cotton
#
# See README.txt for more information
#
# Licensed under GNU Public License v2.0. See LICENSE for full text.
#
###################

$addaction = sub {
my @command = split(/ /,$_,3);

# Check to see what command was given
if ( ( lc($command[0]) eq '/replyall' ) ||
( lc($command[0]) eq '/ra' ) ||
( lc($command[0]) eq '/replytoall' ) ) {

# Get information about the tweet
my $tweet_id = $command[1];
my $tweet = &get_tweet($tweet_id);
my $witty_reply = $command[2];

# Check that the tweet exists. If not, it will be hard to reply to it.
if (!$tweet->{'id_str'}) {
print $stdout "-- You have to wait for that tweet to exist!\n";
return 1;
}

# Who sent the tweet that we're replying to?
$screen_name = &descape($tweet->{'user'}->{'screen_name'});

# Who is mentioned in the tweet?
my $reply_tweet = $tweet->{'text'};
my $mentioned;
# We iterate over the string because I can't think of a better way
while ( $reply_tweet =~ m/(@\w+)/g ) {
# Don't add yourself to the reply list, or the person you're
# replying to, since they'll be added anyway
unless ( ( lc($1) eq lc("\@$whoami") ) ||
( lc($1) eq lc("\@$screen_name") ) ) {
$mentioned .= "$1 ";
}
}

# We're replying, so we'd better act like it
$in_reply_to = $tweet->{'id_str'};

# Prepend the tweet with the names to mention
$witty_reply = "\@$screen_name $mentioned $witty_reply";
&common_split_post($witty_reply, $in_reply_to, undef);
# All done!
return 1;
}

# You didn't ask to reply to all. Tell TTYtter that we don't want to deal
# with this input.
return 0;
};

2 changes: 1 addition & 1 deletion ttytter-rta.pl
Expand Up @@ -15,7 +15,7 @@

# Check to see what command was given
if ( ( lc($command[0]) eq '/replyall' ) ||
( lc($command[0]) eq '/rta' ) ||
( lc($command[0]) eq '/ra' ) ||
( lc($command[0]) eq '/replytoall' ) ) {

# Get information about the tweet
Expand Down

0 comments on commit 88ecd7f

Please sign in to comment.