diff --git a/ttytter-quote.pl b/ttytter-quote.pl new file mode 100755 index 0000000..3ab755c --- /dev/null +++ b/ttytter-quote.pl @@ -0,0 +1,60 @@ +################### +# +# ttytter-r2a.pl -- a TTYtter extension +# +# Copyright (C) 2013 by Ben Cotton and others +# +# See README.txt for more information +# +# Licensed under GNU Public License v2.0. See LICENSE for full text. +# +################### + +$TTYtter_QUOTE_VERSION='1.0'; + +$addaction = sub { + my @command = split(/ /,$_,3); + + # Check to see what command was given + if ( ( lc($command[0]) eq '/quote' ) || + ( lc($command[0]) eq '/quot' ) || + ( lc($command[0]) eq '/quo' ) || + ( lc($command[0]) eq '/qu' ) ) { + + # Get information about the tweet + my $tweet_id = $command[1]; + my $tweet = &get_tweet($tweet_id); + my $witty_reply = $command[2]; + + # Is the witty reply empty? Don't tweet it, that's obnoxious. + if ( $witty_reply eq '' ) { + print $stdout "-- There is no message here. Are you drunk?\n"; + return 1; + } + + # 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 = &descape($tweet->{'text'}); + + $witty_reply = "$witty_reply RT \@$screen_name $reply_tweet"; + + print $stdout "(expand to $witty_reply)\n"; + + &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; +}; +