| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package WWW::ItsABot; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 2 |  |  | 2 |  | 81072 | use warnings; | 
|  | 2 |  |  |  |  | 5 |  | 
|  | 2 |  |  |  |  | 61 |  | 
| 4 | 2 |  |  | 2 |  | 11 | use strict; | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 68 |  | 
| 5 | 2 |  |  | 2 |  | 11 | use base 'Exporter'; | 
|  | 2 |  |  |  |  | 9 |  | 
|  | 2 |  |  |  |  | 220 |  | 
| 6 | 2 |  |  | 2 |  | 1735 | use LWP::Simple; | 
|  | 2 |  |  |  |  | 226837 |  | 
|  | 2 |  |  |  |  | 21 |  | 
| 7 | 2 |  |  | 2 |  | 1291 | use Carp qw/croak/; | 
|  | 2 |  |  |  |  | 5 |  | 
|  | 2 |  |  |  |  | 837 |  | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | =head1 NAME | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | WWW::ItsABot - Ask itsabot.com if a Twitter user is a bot | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | =head1 VERSION | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | Version 0.01 | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | =cut | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  | our $VERSION = '0.01'; | 
| 20 |  |  |  |  |  |  | our $itsabot_url = 'http://www.itsabot.com/User'; | 
| 21 |  |  |  |  |  |  | our @EXPORT = (); | 
| 22 |  |  |  |  |  |  | our @EXPORT_OK = qw(is_a_bot); | 
| 23 |  |  |  |  |  |  |  | 
| 24 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  | use WWW::ItsABot qw/is_a_bot/; | 
| 27 |  |  |  |  |  |  | my $username = 'foobar'; | 
| 28 |  |  |  |  |  |  | if ( is_a_bot($username) ) { | 
| 29 |  |  |  |  |  |  | print "$username is a bot\n"; | 
| 30 |  |  |  |  |  |  | } else { | 
| 31 |  |  |  |  |  |  | print "$username is not a bot\n"; | 
| 32 |  |  |  |  |  |  | } | 
| 33 |  |  |  |  |  |  |  | 
| 34 |  |  |  |  |  |  | =head1 AUTHOR | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | Jonathan Leto, C<<  >> | 
| 37 |  |  |  |  |  |  |  | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | =head2 is_a_bot($username) | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | Returns true is itsabot.com thinks $username is a bot, false otherwise. | 
| 42 |  |  |  |  |  |  |  | 
| 43 |  |  |  |  |  |  | =cut | 
| 44 |  |  |  |  |  |  |  | 
| 45 |  |  |  |  |  |  | sub is_a_bot($) | 
| 46 |  |  |  |  |  |  | { | 
| 47 | 3 |  |  | 3 | 1 | 56 | my ($username) = @_; | 
| 48 | 3 | 50 |  |  |  | 9 | croak "is_a_bot(): Username empty" unless $username; | 
| 49 | 3 |  |  |  |  | 12 | my $content = get("$itsabot_url/$username.csv"); | 
| 50 |  |  |  |  |  |  | # user,followers,friends,statuses,isabot,follow_ratio,followers_per_tweet | 
| 51 | 3 | 50 |  |  |  | 24 | if ( $content ) { | 
| 52 | 3 |  |  |  |  | 15 | my (@info) = split ',', $content; | 
| 53 | 3 | 100 |  |  |  | 8 | if (defined $info[4]) { | 
| 54 | 2 | 100 |  |  |  | 22 | return $info[4] =~ /true/i ? 1 : 0; | 
| 55 |  |  |  |  |  |  | } else { | 
| 56 | 1 |  |  |  |  | 22 | croak "is_a_bot(): user does not exist"; | 
| 57 |  |  |  |  |  |  | } | 
| 58 |  |  |  |  |  |  | } else { | 
| 59 | 0 |  |  |  |  |  | croak "is_a_bot(): did not get a response"; | 
| 60 |  |  |  |  |  |  | } | 
| 61 |  |  |  |  |  |  | } | 
| 62 |  |  |  |  |  |  |  | 
| 63 |  |  |  |  |  |  | =head1 BUGS | 
| 64 |  |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  | Please report any bugs or feature requests to C, or through | 
| 66 |  |  |  |  |  |  | the web interface at L.  I will be notified, and then you'll | 
| 67 |  |  |  |  |  |  | automatically be notified of progress on your bug as I make changes. | 
| 68 |  |  |  |  |  |  |  | 
| 69 |  |  |  |  |  |  |  | 
| 70 |  |  |  |  |  |  | =head1 SUPPORT | 
| 71 |  |  |  |  |  |  |  | 
| 72 |  |  |  |  |  |  | You can find documentation for this module with the perldoc command. | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  | perldoc WWW::ItsABot | 
| 75 |  |  |  |  |  |  |  | 
| 76 |  |  |  |  |  |  |  | 
| 77 |  |  |  |  |  |  | You can also look for information at: | 
| 78 |  |  |  |  |  |  |  | 
| 79 |  |  |  |  |  |  | =over 4 | 
| 80 |  |  |  |  |  |  |  | 
| 81 |  |  |  |  |  |  | =item * RT: CPAN's request tracker | 
| 82 |  |  |  |  |  |  |  | 
| 83 |  |  |  |  |  |  | L | 
| 84 |  |  |  |  |  |  |  | 
| 85 |  |  |  |  |  |  | =item * AnnoCPAN: Annotated CPAN documentation | 
| 86 |  |  |  |  |  |  |  | 
| 87 |  |  |  |  |  |  | L | 
| 88 |  |  |  |  |  |  |  | 
| 89 |  |  |  |  |  |  | =item * CPAN Ratings | 
| 90 |  |  |  |  |  |  |  | 
| 91 |  |  |  |  |  |  | L | 
| 92 |  |  |  |  |  |  |  | 
| 93 |  |  |  |  |  |  | =item * Search CPAN | 
| 94 |  |  |  |  |  |  |  | 
| 95 |  |  |  |  |  |  | L | 
| 96 |  |  |  |  |  |  |  | 
| 97 |  |  |  |  |  |  | =back | 
| 98 |  |  |  |  |  |  |  | 
| 99 |  |  |  |  |  |  |  | 
| 100 |  |  |  |  |  |  | =head1 ACKNOWLEDGEMENTS | 
| 101 |  |  |  |  |  |  |  | 
| 102 |  |  |  |  |  |  |  | 
| 103 |  |  |  |  |  |  | =head1 COPYRIGHT & LICENSE | 
| 104 |  |  |  |  |  |  |  | 
| 105 |  |  |  |  |  |  | Copyright 2009 Jonathan Leto, all rights reserved. | 
| 106 |  |  |  |  |  |  |  | 
| 107 |  |  |  |  |  |  | This program is free software; you can redistribute it and/or modify it | 
| 108 |  |  |  |  |  |  | under the same terms as Perl itself. | 
| 109 |  |  |  |  |  |  |  | 
| 110 |  |  |  |  |  |  |  | 
| 111 |  |  |  |  |  |  | =cut | 
| 112 |  |  |  |  |  |  |  | 
| 113 |  |  |  |  |  |  | 1.0; |