Net::Twitter::RandomUpdate - Make people think you're paying attention to Twitter


Net-Twitter-RandomUpdate documentation Contained in the Net-Twitter-RandomUpdate distribution.

Index


Code Index:

NAME

Top

Net::Twitter::RandomUpdate - Make people think you're paying attention to Twitter

DESCRIPTION

Top

Will submit a random tweet at generally random times with some canned quotes or quotes defined by the implementor.

METHODS

Top

new( [ optional_quotes ] );

Will return a new object. You can pass an OPTIONAL reference to an array with a list of tweets the module will choose from. If ignored, the following will be used:

    my $quotes = [
        'How to store your baby walker: First, remove baby.',
        'I get to go to lots of overseas places, like Canada.',
        'The team has come along slow but fast.',
        'Most cars on our roads have only one occupant, usually the driver.',
        'Football players win football games.',
        'Most lies about blondes are false.',
        'I love California, I practically grew up in Phoenix.',
        'Strangely, in slow motion replay, the ball seemed to hang in the air for even longer.',
        'We\'re just physically not physical enough.',
        'The world is more like it is now then it ever has before.',
        'I cannot tell you how grateful I am -- I am filled with humidity.',
        'I have a God-given talent. I got it from my dad.',
        'Traditionally, most of Australia\'s imports come from overseas.',
    ];

tweet

Will send a tweet to the specified account if it falls within the random regularity selection.

ATTRIBUTES

Top

regularity

Default: .05 (will only tweet 5% of the time)

An integer <= 1 and >= 0, indicating the percentage of times you want the module to tweet. Good for use in a crontab, for example.

username

The username of the account.

password

The password of the account.

EXAMPLES

Top

    use Net::Twitter::RandomUpdate;

    # Use the default tweet-set send a tweet 100% of the time
    my $rand = Net::Twitter::RandomUpdate->new();
    $rand->regularity(1);
    $rand->password('pass');
    $rand->username('user');
    $rand->tweet();

    # Use self-defined tweet-set, send a tweet 50% of the time 
    my $rand = Net::Twitter::RandomUpdate->new( [ qw( hi ) ] );
    $rand->regularity(.5);
    $rand->password('pass');
    $rand->username('user');
    $rand->tweet();

SEE ALSO

Top

Net::Twitter

AUTHOR

Top

Trevor Hall, <wazzuteke@cpan.org>

COPYRIGHT AND LICENSE

Top


Net-Twitter-RandomUpdate documentation Contained in the Net-Twitter-RandomUpdate distribution.

package Net::Twitter::RandomUpdate;

use strict;
use warnings;

use Net::Twitter;

our $VERSION = join( '.', 1, map{ $_ - 53 } ( '$Rev: 59 $' =~ /(\d+)/g ) ); 

my $quotes = [
    'How to store your baby walker: First, remove baby.',
    'I get to go to lots of overseas places, like Canada.',
    'The team has come along slow but fast.',
    'Most cars on our roads have only one occupant, usually the driver.',
    'Football players win football games.',
    'Most lies about blondes are false.',
    'I love California, I practically grew up in Phoenix.',
    'Strangely, in slow motion replay, the ball seemed to hang in the air for even longer.',
    'We\'re just physically not physical enough.',
    'The world is more like it is now then it ever has before.',
    'I cannot tell you how grateful I am -- I am filled with humidity.',
    'I have a God-given talent. I got it from my dad.',
    'Traditionally, most of Australia\'s imports come from overseas.',
];

sub new {
    my ( $class, $notes ) = @_;

    return bless( $notes || $quotes, $class );
}

{
    my $user;
    sub username {
        return $user = pop;
    }

    my $pass;
    sub password {
        return $pass = pop;
    }

    my $reg = .05; 
    sub regularity {
        return $reg = pop;
    }

    sub tweet {
        return if ( rand() > $reg );
        my ($self) = @_;

        my $tweet = Net::Twitter->new(
            'username' => $user,
            'password' => $pass,
            'source'   => 'randomupdate',
        );

        my @tweets = @$self;
        $tweet->update( $tweets[ int( rand( @tweets ) ) ] ); 

        return;
    }
}

1;

__END__