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

Commit

Permalink
Merge pull request #3 from thameera/sandwich
Browse files Browse the repository at this point in the history
Add an alternate formatting (sandwich) mode. Thanks, thameera!
  • Loading branch information
funnelfiasco committed Feb 27, 2013
2 parents fb9be48 + 898e3d2 commit 75020d2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.txt
Expand Up @@ -18,6 +18,10 @@ 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.

By default, this extension will format the reply in the format '@screen_name
@mentioned witty_reply'. However, if you want the reply sandwiched, like
'@screen_name witty_reply @mentioned', you can use /rasw.

The list of matched user names does not include the sender of the tweet being
replyed to, nor does it include the user name that TTYtter is running under.
User matching is done by a simple regular expression ("@\w+"), so it's possible
Expand Down
22 changes: 19 additions & 3 deletions ttytter-r2a.pl
Expand Up @@ -18,7 +18,18 @@
# Check to see what command was given
if ( ( lc($command[0]) eq '/replyall' ) ||
( lc($command[0]) eq '/ra' ) ||
( lc($command[0]) eq '/replytoall' ) ) {
( lc($command[0]) eq '/replytoall' ) ||
( lc($command[0]) eq '/rasw' ) ) {

# Determine the sandwich mode.
my $sandwich;
if ( lc($command[0]) eq '/rasw' ) {
# '@screen_name witty_reply @mentioned'
$sandwich = 1;
} else {
# '@screen_name @mentioned witty_reply'
$sandwich = 0;
}

# Get information about the tweet
my $tweet_id = $command[1];
Expand Down Expand Up @@ -61,8 +72,13 @@
# 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";
# Prepend/append the tweet with the names to mention
if ( $sandwich ) {
$witty_reply = "\@$screen_name $witty_reply $mentioned";
} else {
$witty_reply = "\@$screen_name $mentioned $witty_reply";
}

&common_split_post($witty_reply, $in_reply_to, undef);
# All done!
return 1;
Expand Down

0 comments on commit 75020d2

Please sign in to comment.