Bot-BasicBot-Pluggable-Module-Twitter
view release on metacpan or search on metacpan
lib/Bot/BasicBot/Pluggable/Module/Twitter.pm view on Meta::CPAN
$self->{ body } = $mess->{ body };
$self->{ who } = $mess->{ who };
$self->{ channel } = $mess->{ channel };
if ( $self->{ body } =~ /^!twitter\s(.*)$/ ) {
my $result = $self->{ twit }->update( $1 );
if ( !defined $result ) {
$self->tell( $self->{ channel },
$self->{ who } . ": an error occurs." );
}
else {
$self->tell( $self->{ channel },
$self->{ who } . ": consider it noted." );
}
}
elsif ( $self->{ body } =~ /^!twitter_all/ ) {
my $result = $self->{ twit }->public_timeline;
my $i = 0;
foreach my $t ( @{ $result } ) {
my $str = $t->{ user }->{ name }. " :". $t->{text};
$self->tell( $self->{ channel }, $str );
$i++;
last if $i == 5;
}
}
}
=head3 set
$twitter_handler->set(
{ username => "myusername",
password => "mypassword",
}
);
will set the username and the password for the bot.
=cut
sub set {
my ( $self, $params ) = @_;
foreach my $key ( keys %{ $params } ) {
$self->{ $key } = $$params{ $key };
}
croak "Error: no twitter username specified" unless $self->{ username };
croak "Error: no twitter password specified" unless $self->{ password };
$self->{ twit } = Net::Twitter->new(
username => $self->{ username },
password => $self->{ password }
);
return $self;
}
1;
__END__
=head1 BUGS AND LIMITATIONS
No bugs have been reported.
Please report any bugs or feature requests to
C<bug-bot-basicbot-pluggable-module-twitter@rt.cpan.org>, or through the web interface at
L<http://rt.cpan.org>.
=head1 AUTHOR
franck cuny C<< <franck.cuny@gmail.com> >>
=head1 LICENCE AND COPYRIGHT
Copyright (c) 2007, franck cuny C<< <franck.cuny@gmail.com> >>. All rights reserved.
This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself. See L<perlartistic>.
( run in 1.363 second using v1.01-cache-2.11-cpan-5837b0d9d2c )