This repository has been archived by the owner on Nov 28, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Beta testers suggest that rta suggests a retweet-related command. Since
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
Showing
3 changed files
with
67 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters