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

(+)add a plugin which implements the quote function #4

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
60 changes: 60 additions & 0 deletions 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;
};