SHARE
TWEET

Untitled

a guest Mar 17th, 2018 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/perl
  2.  
  3. use strict;
  4. use warnings;
  5. use Net::Twitter;
  6. use Encode;
  7.  
  8. binmode(STDOUT, ":utf8");
  9.  
  10. my $ng_word_regex = decode("utf-8", "XXXXX");
  11. my $sleep_time = 60;
  12. my $nt = Net::Twitter->new(
  13.     traits   => [qw/API::REST/],
  14.     username => 'username_or_mail_address',
  15.     password => 'user_password'
  16. );
  17.  
  18. foreach my $i (1 .. 255) {
  19.  
  20.     eval {
  21.         my $result = $nt->user_timeline({ page => $i });
  22.         print "digging my timeline page $i ....\n\n";
  23.         sleep($sleep_time);
  24.  
  25.         foreach my $tweet (@$result) {
  26.             if ($tweet->{text} =~ /$ng_word_regex/) {
  27.                 print "\n";
  28.                 print "NG Word Detected! Do you want to delete this tweet? \n";
  29.                 print "detected tweet is ... -> " . $tweet->{text} . " (y/n):";
  30.                 if (<STDIN> =~ /y/i) {
  31.                     eval {
  32.                         my $status = $nt->destroy_status($tweet->{id});
  33.                     };
  34.                     if (my $err = $@) {
  35.                         print "error occured deleting tweet ... " . $err->error . "\n";
  36.                     } else {
  37.                         print "deleted statues " . $tweet->{id} . "\n\n";
  38.                         sleep($sleep_time);
  39.                     }
  40.                 } else {
  41.                     print "inputted 'N' ... ignoring. \n\n";                
  42.                 }
  43.             }
  44.         }
  45.     };
  46.     if (my $err = $@) {
  47.         print "error occured when getting user timeline ... " . $err->error . "\n";
  48.     }
  49. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top