User:Bot ishmael/Deleting old hi-res icons

Script to delete the old hi-res skill icons. Can be easily modified for generic mass deletions by passing input file and delete summary as command-line arguments.


 * 1) !/usr/bin/perl

use MediaWiki; use MediaWiki::page; use Data::Dumper; use URI::Escape qw(uri_escape_utf8 uri_escape); use warnings; use strict;

$| = 1; #Flush!

open (IFP, "old_hires.txt") or die "can't open input file: $!\n";
 * 1) Open the file with the list of pages to delete

open (OFP, ">>$0.log") or die "can't open log file: $!\n"; print OFP "\n", "="x20, "\n"; {	my ($sec, $min, $hour, $day, $mon, $year) = (localtime)[0,1,2,3,4,5]; printf OFP "$0 starting at %2d:%02d:%02d %4d-%02d-%02d\n", $hour, $min, $sec, $year+1900, $mon+1, $day; }
 * 1) Open log file

my $username = "Bot ishmael"; print "Enter password for $username: "; my $password = <>; chomp $password;
 * 1) Require user to type password at command prompt (don't save it in this file)

my $c = MediaWiki->new; $c->setup ({      'bot' => {'user' => $username, 'pass' => $password},      'wiki' => {'host' => 'guildwars.wikia.com', 'path' => ''}      }) || die "Failed to log in\n";
 * 1) Setup module (automatically logs in)

$password = ""; undef $password;
 * 1) Blank password so it's not sitting in memory

while () { chomp $_; my $page = $c->get($_, 'rw');

# Set delete reason $page->{'summary'} = "BOT: Deleting old hi-res icons"; print "Deleting $_..."; # Delete page $page->delete; # Log deletion print OFP "*Deleted &#91;$_&#93;\n"; print "*Deleted\n"; sleep 10; }

{	my ($sec, $min, $hour, $day, $mon, $year) = (localtime)[0,1,2,3,4,5]; printf OFP "\n$0 finishing at %2d:%02d:%02d %4d-%02d-%02d\n", $hour, $min, $sec, $year+1900, $mon+1, $day; } close(OFP); close(IFP);