Skip to content

Instantly share code, notes, and snippets.

@mumumu
Created January 1, 2010 01:02
Show Gist options
  • Save mumumu/266996 to your computer and use it in GitHub Desktop.
Save mumumu/266996 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use warnings;
use Net::Twitter;
use Encode;
binmode(STDOUT, ":utf8");
my $ng_word_regex = decode("utf-8", "XXXXX");
my $sleep_time = 60;
my $nt = Net::Twitter->new(
traits => [qw/API::REST/],
username => 'username_or_mail_address',
password => 'user_password'
);
foreach my $i (1 .. 255) {
eval {
my $result = $nt->user_timeline({ page => $i });
print "digging my timeline page $i ....\n\n";
sleep($sleep_time);
foreach my $tweet (@$result) {
if ($tweet->{text} =~ /$ng_word_regex/) {
print "\n";
print "NG Word Detected! Do you want to delete this tweet? \n";
print "detected tweet is ... -> " . $tweet->{text} . " (y/n):";
if (<STDIN> =~ /y/i) {
eval {
my $status = $nt->destroy_status($tweet->{id});
};
if (my $err = $@) {
print "error occured deleting tweet ... " . $err->error . "\n";
} else {
print "deleted statues " . $tweet->{id} . "\n\n";
sleep($sleep_time);
}
} else {
print "inputted 'N' ... ignoring. \n\n";
}
}
}
};
if (my $err = $@) {
print "error occured when getting user timeline ... " . $err->error . "\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment