-
Notifications
You must be signed in to change notification settings - Fork 2
/
editnotice-bot.pl
executable file
·69 lines (59 loc) · 1.42 KB
/
editnotice-bot.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/perl -w
use strict;
no strict 'refs';
use English;
use Encode;
use utf8;
use MediaWiki::Bot;
use Data::Dumper;
binmode STDOUT, ":utf8";
my %credentials = load_credentials('wiki_botconf.txt');
my $host = ( $credentials{host} // 'he.wikisource.org' );
print "HOST $host USER $credentials{username}\n";
my $bot = MediaWiki::Bot->new({
host => $host,
agent => sprintf('PerlWikiBot/%s',MediaWiki::Bot->VERSION),
login_data => \%credentials,
assert => 'bot',
protocol => 'https',
debug => 2,
}) or die "Error login...\n";
my $cat = 'קטגוריה:בוט חוקים';
my @pages = $bot->get_pages_in_category($cat);
my ($noticepage, $text, $id);
foreach my $page (@pages) {
next if ($page =~ /^משתמש:/);
$noticepage = "Mediawiki:Editnotice-0-$page";
$id = $bot->get_id($noticepage);
$text = $bot->get_text($noticepage);
print "PAGE '$page': ";
if ($id) {
print "DEL, ";
$bot->delete($noticepage, 'מיותר');
} else {
print "NONE, ";
}
$noticepage = "Mediawiki:Editnotice-116-$page";
$id = $bot->get_id($noticepage);
$text = $bot->get_text($noticepage);
if ($id) {
print "DEL.\n";
$bot->delete($noticepage, 'מיותר');
} else {
print "NONE.\n";
}
}
exit 0;
1;
sub load_credentials {
my %obj;
my $_ = shift;
open( my $FIN, $_ ) || die "Cannot open file \"$_\"!\n";
while (<$FIN>) {
if (m/^ *(.*?) *= *(.*?) *$/) {
$obj{$1} = $2;
}
}
close($FIN);
return %obj;
}