Benutzer:MelancholieBot/globalNotif.pl
Erscheinungsbild
- !/usr/bin/perl
use LWP::UserAgent; use HTML::Entities; $pythonV = "/usr/local/bin/python2.5";
- Usage: perl globalNotif.pl 0 0 20081027 "forced comment" wikipedia "en,de,w:als,wikt"
- Change: User name, $force?
$checkBLocks = $ARGV[0];#0|1 $checkChange = $ARGV[1];#0|1 $date = $ARGV[2];#UTC $comment = $ARGV[3];#0 $only = $ARGV[4];#0 $skip = $ARGV[5]; $nice = "nice ";
unless (-e "isRunning.tmp") {
$timeStamp = "";
if (-e "logs/timestamp.log") {
open OTSP, "logs/timestamp.log";
while (<OTSP>) {
if ($_ =~ /^(.+)$/) {$timeStamp = $1;}
}
close OTSP;
}
for (my $i = 1; $i <= 1; $i++) {# redo if API disabled/error; get Username/trust
$url = "http://meta.wikimedia.org/w/api.php?action=query&format=xml&prop=revisions&titles=Global_notifications&rvprop=timestamp|user|comment&rvlimit=1";
$file = "timestamp.xml";
$userAgent = LWP::UserAgent->new();
$userAgent->agent("WikimediaNotificationBot");
$httpRequest = HTTP::Request->new("GET", $url);
$serverResponse = $userAgent->request($httpRequest, $file);
if ($serverResponse->is_error()) {
print "Error code: ", $serverResponse->code(), "\n";
print "Error message: ", $serverResponse->message(), "\n";
if ($serverResponse->code() !~ /^(301|302|307|401|403|404|500|503)$/) {#...
sleep(60);#++/*2
redo;
}
}
}
open TSP, "timestamp.xml";
while (<TSP>) {
if ($_ =~ /<rev user="Melancholie" timestamp="([^"]+)" comment="([^"]+)" \/>/ && $1 ne $timeStamp) {
$timeStamp = $1;
$lastChange = $1;
$givenComment = $2;
$lastChange =~ s/[-T:Z]//g;
$diff = $date-$lastChange;
if ($diff >= 7000) {#_½h
open NTSP, ">logs/timestamp.log";
print NTSP $timeStamp;
close NTSP;
if ($givenComment =~ /^(notify|publish|update|synch?|synchroni[sz]e) ?([;,!]|$)/) {
$hasChanged = 1;
$action = $1;
if ($givenComment =~ /&/) {decode_entities($givenComment);}
if ($givenComment =~ /\$/) {$givenComment =~ s/(\$)/\\$1/g;}
if (($comment eq "" || $comment eq 0) && $givenComment =~ /; ?(summary|comment)[:=] *["']([^\r\n]+?)["'] ?([;,!]|$)/) {
$comment = $2;
}
if (($only eq "" || $only eq 0) && $givenComment =~ /; ?only[:=] *["']?([^;]+)["']? ?([;,!]|$)/) {
$only = $1;
}
if (($skip eq "" || $skip eq 0) && $givenComment =~ /; ?(skip|not)[:=] *["']?([^;]+)["']? ?([;,!]|$)/) {
$skip = $2;
}
}
}
}
}
close TSP;
unlink ("timestamp.xml");
} if ($hasChanged) {
$tpN = 0;
for (my $t = 1; $t <= 1; $t++) {
$url = "http://meta.wikimedia.org/w/index.php?title=Talk:Global_notifications&oldid=cur&action=raw&ctype=text/css&smaxage=1&maxage=1";
$file = "centralTalk.tmp";
$userAgent = LWP::UserAgent->new();
$userAgent->agent("WikimediaNotificationBot");
$httpRequest = HTTP::Request->new("GET", $url);
$serverResponse = $userAgent->request($httpRequest, $file);
if ($serverResponse->is_error()) {
print "Error code: ", $serverResponse->code(), "\n";
print "Error message: ", $serverResponse->message(), "\n";
if ($serverResponse->code() !~ /^(301|302|307|401|403|404|500|503)$/) {#...
sleep(60);#++/*2
redo;
}
}
}
open TMP, "centralTalk.tmp";
$item = 0;
while (<TMP>) {
if ($item < 99 && $_ =~ /^== *([^=])([^\r\n]+?)([^=]) *== *$/) {
$item++;
$isTalk = 1;
$topics{"$1$2$3"} = 1;
} elsif ($_ =~ /^ *\/\* *([^\r\n]+) *\*\/ *$/ || $_ =~ /\[\[User:/) {#skip server errors (cache?)
$isTalk = 1;
}
}
close TMP;
unlink ("centralTalk.tmp");
for (my $j = 1; $j <= 1; $j++) {
$url = "http://meta.wikimedia.org/w/index.php?title=Global_notifications&oldid=cur&action=raw&ctype=text/css&smaxage=1&maxage=1";
$file = "globalNotif.tmp";
$userAgent = LWP::UserAgent->new();
$userAgent->agent("WikimediaNotificationBot");
$httpRequest = HTTP::Request->new("GET", $url);
$serverResponse = $userAgent->request($httpRequest, $file);
if ($serverResponse->is_error()) {
print "Error code: ", $serverResponse->code(), "\n";
print "Error message: ", $serverResponse->message(), "\n";
if ($serverResponse->code() !~ /^(301|302|307|401|403|404|500|503)$/) {#...
sleep(60);#++/*2
redo;
}
}
}
open TMP, "globalNotif.tmp";
open OUT, ">globalNotif.dat";
print OUT "\#START\n\#TITLE=User:WikimediaNotifier/notifications\#\n";print OUT "
\nVorlage:\$wikix";
} elsif ($isEnd && $_ !~ /^ *()? *\}\}/) {
undef($isEnd);
} elsif ($isEnd && $_ =~ /^ *()? *(\}\})/) {
print OUT "$2\n";
}
if ($isNotif && $isContent) {#ToDo: Only if .../var| -- ...!
$RAM = $_;
$RAM =~ s/\{\{ *([Tt]emplate|[Mm]sg)?:? *([Gg]lobal[_ ]notifications)?\/var/{{subst:User:WikimediaNotifier\/self.js/g;
$RAM =~ s/\{\{ *([Tt]emplate|[Mm]sg)?:? *([Gg]lobal[_ ]notifications)?\/(change|update)d? *\|/{{:User:WikimediaNotifier\/updated|/g;#inclusion+move-safe path
$RAM =~ s/(\[|:|=)([sS]pecies):[Ww]ikispecies:/$1$2:Project:/g;
$RAM =~ s/(\[\[|\||:) *([Ww]iki)?species[^ :-_\.\/=\|\]]*(:|=) */$1$\species$4/g;
$RAM =~ s/(\[\[|\||[^bnqsvw]:) *[Ww]iki([bnqsvw])[^ :-_\.\/=\|\]]+(:|=) */$1$2$3/g;
$RAM =~ s/(\[|:|=)([cC]ommons):[Cc]ommons:/$1$2:Project:/g;
$RAM =~ s/(\[\[|\||:) *([Ww]iki)?commons?[^ :-_\.\/=\|\]]*(:|=) */$1$\commons$3/g;
$RAM =~ s/(\[\[|\||:) *c(:|=|\|) */$1$\commons$2/g;#cs=lang
$RAM =~ s/(\[|:|=)([wW]ikt|[wW]iktionary):[Ww]iktionary:/$1$2:Project:/g;
$RAM =~ s/(\[\[|\||:) *[Ww]ikt[^ :-_\.\/=\|\]]+(:|=) */$1$\wikt$2/g;
$RAM =~ s/\| *([^ :-_\.\/=\|\]]{2,}):(commons|wikt)[^=]*=/|$2:$1=/g;
$RAM =~ s/\| *([^ :-_\.\/=\|\]]{2,}):([bnqsvw]) *=/|$2:$1=/g;
#Now, having correct/best order [project,lang]:
#|link=m:n:Wikinews doesn't work, but "Project" does:
$RAM =~ s/(\[\[|=):?([bnqsvw]):([Ww]iki)(books|news|quote|source|versity|pedia):/$1$\m:$2:Project:/g;
$RAM =~ s/(\[\[|=):?([bnqsvw]):([^:]+):([Ww]iki)(books|news|quote|source|versity|pedia):/$1$\m:$2:$3:Project:/g;
$RAM =~ s/(\[\[|=):?(wikt):(Project):/$1$\m:$2:$3:/g;#|~>localNotif.pl?
$RAM =~ s/(\[\[|=):?(wikt):(\||\]\])/$1$\m:$2:Main_Page$3/g;#|~>localNotif.pl?
$RAM =~ s/(\[\[|=):?(wikt):([^:]+):(Project):/$1$\m:$2:$3:$4:/g;#|~>localNotif.pl?
$RAM =~ s/(\[\[|=):?(wikt):([^:]+):(\||\]\])/$1$\m:$2:$3:Main_Page$3/g;#|~>localNotif.pl?
$RAM =~ s/(\[\[|=):?(commons|species):(Project):/$1$\m:$2:$3:/g;#|~>localNotif.pl!
$RAM =~ s/(\[\[|=):?(commons|species):(\||\]\])/$1$\m:$2:Main_Page$3/g;#|~>localNotif.pl!
$RAM =~ s/\| *(default|standard) *=/|else=/g;
$RAM =~ s/\[\[ *([^:<\#])/[[meta:$1/g;
$RAM =~ s/\[\[meta:(File|Image|Media) *: */[[$1:/ig;
$RAM =~ s/< ?nowiki ?> ?\[\[meta:/<nowiki>[[/ig;
$RAM =~ s/\[\[meta:([bcmnqsvw])(eta|ommons|ikt|ugzilla|ediazilla|etawikipedia)? *: */[[$1$2:/ig;
$RAM =~ s/\[\[meta *: *m(eta|etawikipedia)? *: */[[meta:/ig;#...once more
$RAM =~ s/\[\[ *: *(File|Image|Media|Category) *: */[[::$1:/ig;
$RAM =~ s/\[\[ *: *([a-z]{2,3}): */[[::$1:/g;
$RAM =~ s/\[\[ *: */[[/g;
print OUT $RAM;
} elsif ($isNotif && $_ =~ /^ *\|* *[Cc]ontent *= *([^\r\n]{0,32766}) */) {#ToDo: Only if .../var| ...
$isContent = 1;
$RAM = $1;
$RAM =~ s/\{\{ *([Tt]emplate|[Mm]sg)?:? *([Gg]lobal[_ ]notifications)?\/var/{{subst:User:WikimediaNotifier\/self.js/g;
$RAM =~ s/\{\{ *([Tt]emplate|[Mm]sg)?:? *([Gg]lobal[_ ]notifications)?\/(change|update)d? *\|/{{:User:WikimediaNotifier\/updated|/g;#inclusion+move-safe path
$RAM =~ s/(\[|:|=)([sS]pecies):[Ww]ikispecies:/$1$2:Project:/g;
$RAM =~ s/(\[\[|\||:) *([Ww]iki)?species[^ :-_\.\/=\|\]]*(:|=) */$1$\species$4/g;
$RAM =~ s/(\[\[|\||[^bnqsvw]:) *[Ww]iki([bnqsvw])[^ :-_\.\/=\|\]]+(:|=) */$1$2$3/g;
$RAM =~ s/(\[|:|=)([cC]ommons):[Cc]ommons:/$1$2:Project:/g;
$RAM =~ s/(\[\[|\||:) *([Ww]iki)?commons?[^ :-_\.\/=\|\]]*(:|=) */$1$\commons$3/g;
$RAM =~ s/(\[\[|\||:) *c(:|=|\|) */$1$\commons$2/g;#cs=lang
$RAM =~ s/(\[|:|=)([wW]ikt|[wW]iktionary):[Ww]iktionary:/$1$2:Project:/g;
$RAM =~ s/(\[\[|\||:) *[Ww]ikt[^ :-_\.\/=\|\]]+(:|=) */$1$\wikt$2/g;
$RAM =~ s/\| *([^ :-_\.\/=\|\]]{2,}):(commons|wikt)[^=]*=/|$2:$1=/g;
$RAM =~ s/\| *([^ :-_\.\/=\|\]]{2,}):([bnqsvw]) *=/|$2:$1=/g;
#Now, having correct/best order [project,lang]:
#|link=m:n:Wikinews doesn't work, but "Project" does:
$RAM =~ s/(\[\[|=):?([bnqsvw]):([Ww]iki)(books|news|quote|source|versity|pedia):/$1$\m:$2:Project:/g;
$RAM =~ s/(\[\[|=):?([bnqsvw]):([^:]+):([Ww]iki)(books|news|quote|source|versity|pedia):/$1$\m:$2:$3:Project:/g;
$RAM =~ s/(\[\[|=):?(wikt):(Project):/$1$\m:$2:$3:/g;#|~>localNotif.pl?
$RAM =~ s/(\[\[|=):?(wikt):(\||\]\])/$1$\m:$2:Main_Page$3/g;#|~>localNotif.pl?
$RAM =~ s/(\[\[|=):?(wikt):([^:]+):(Project):/$1$\m:$2:$3:$4:/g;#|~>localNotif.pl?
$RAM =~ s/(\[\[|=):?(wikt):([^:]+):(\||\]\])/$1$\m:$2:$3:Main_Page$3/g;#|~>localNotif.pl?
$RAM =~ s/(\[\[|=):?(commons|species):(Project):/$1$\m:$2:$3:/g;#|~>localNotif.pl!
$RAM =~ s/(\[\[|=):?(commons|species):(\||\]\])/$1$\m:$2:Main_Page$3/g;#|~>localNotif.pl!
$RAM =~ s/\| *(default|standard) *=/|else=/g;
$RAM =~ s/\[\[ *([^:<\#])/[[meta:$1/g;
$RAM =~ s/\[\[meta:(File|Image|Media) *: */[[$1:/ig;
$RAM =~ s/< ?nowiki ?> ?\[\[meta:/<nowiki>[[/ig;
$RAM =~ s/\[\[meta:([bcmnqsvw])(eta|ommons|ikt|ugzilla|ediazilla|etawikipedia)? *: */[[$1$2:/ig;
$RAM =~ s/\[\[meta *: *m(eta|etawikipedia)? *: */[[meta:/ig;#...once more
$RAM =~ s/\[\[ *: *(File|Image|Media|Category) *: */[[::$1:/ig;
$RAM =~ s/\[\[ *: *([a-z]{2,3}): */[[::$1:/g;
$RAM =~ s/\[\[ *: */[[/g;
print OUT "|content = $RAM\n";
}
}
print OUT "\n|";
$pos = -1;
foreach (@topic) {
$pos++;
if ($_ ne "Wikimedia notification system") {
print OUT "\n\#$_";#meta:Global_notifications
}
$topic[$pos] = "";
}
print OUT "\n}}\n";
print OUT "\#STOP";
close OUT;
print TLK "\#STOP";
close TLK;
close TMP;
unlink ("globalNotif.tmp");
unlink ("globalEdit.sh");
$update = 0;
if ($comment ne "" && $comment ne 0) {
$summaryFallback = $comment;
} elsif ($newTopic && $action eq "notify") {
$summaryFallback = "\*\*\*\* \[\[m:Global_notifications\|global announcement(s)\]\] \*\*\*\*";#\[\[Special:Inexistent\|\*\*\*\*\]\] ... \[\[Special:Nonexistent\|\*\*\*\*\]\]
} else {
$update = 1;
$summaryFallback = "\[\[m:Global_notifications\|update\]\]";
}
$furtherTopics = "";
if ($summaryTopic && $topics{$summaryTopic} =~ /(^|,)all(,|$)/) {#...those going to all; Rest+ToDo see below
if ($summaryTopic2 && $topics{$summaryTopic2} =~ /(^|,)all(,|$)/) {
$furtherTopics = "; \[\[User:WikimediaNotifier/notifications\#$summaryTopic2\|$summaryTopic2\]\]";
}
if ($summaryTopic3 && $topics{$summaryTopic3} =~ /(^|,)all(,|$)/) {
$furtherTopics = "$furtherTopics; \[\[User:WikimediaNotifier/notifications\#$summaryTopic3\|$summaryTopic3\]\]";
}
$summary = "\*\*\*\* \[\[User:WikimediaNotifier/notifications\#$summaryTopic\|$summaryTopic\]\]$furtherTopics \*\*\*\*";#\[\[Special:Inexistent\|\*\*\*\*\]\] ... \[\[Special:Nonexistent\|\*\*\*\*\]\]
$minor = "";#=$newTopic
} else {
$summary = $summaryFallback;
$minor = " -minor";
}
$force = " -force";
if ($notVeryFirst) {#skip server errors (cache?)
open PY, ">user-config.py";
print PY "family = 'meta\'\n";
print PY "mylang = 'meta'\n";
print PY "password_file = \".globalNotifiers\"\n";
print PY "notify_unflagged_bot = False\n";
print PY "solve_captcha = False\n";
print PY "use_diskcache = True\n";
print PY "use_api_login = True\n";
print PY "minthrottle = 1\n";
print PY "maxthrottle = 2\n";
print PY "put_throttle = 3\n";
print PY "noisysleep = 180\n";
open SH, ">globalEdit.tmp";
print SH "\#!/bin/bash\n";
print SH "$nice$\perl globalRSS.pl $update\n";
print SH "mv user-config.py user-config_notif.py\n";
print SH "mv user-config_notifRSS.py user-config.py\n";
print SH "$nice$pythonV pagefromfile.py \"-family:meta\" \"-lang:meta\" -file:GN.rss -force -include -minor -start:\"<\\?xml version\" -titlestart:\"\\?title=\" -titleend:\"&action=raw\" -end:\"</rss>\" -summary:\"update\"\n";
print SH "mv user-config.py user-config_notifRSS.py\n";
print SH "mv user-config_notif.py user-config.py\n";
print SH "$nice$\perl globalPing.pl\n";
# meta.wikimedia.org
print PY "usernames['meta']['meta'] = 'WikimediaNotifier'\n";
if ($isTalk && $newTopic) {
if ($checkBLocks eq 1) {
print SH "$nice$\perl checkBLocks.pl meta wikimedia\n";
}
if ($checkChange eq 1) {
print SH "$nice$\perl checkChange.pl meta wikimedia\n";
}
print SH "$nice$pythonV pagefromfile.py \"-family:meta\" \"-lang:meta\" -file:centralTalk.txt -appendbottom -notitle$minor -start:\"\#START\" -titlestart:\"\#TITLE=\" -titleend:\"\#\" -end:\"\#STOP\" -summary:\"in progress\"\n";
}
print SH "rm -f centralTalk.txt\n";
##########################################################################################################
# test.wikipedia.org
print PY "usernames['test']['test'] = 'WikimediaNotifier'\n";
if ($checkBLocks eq 1) {
print SH "$nice$\perl checkBLocks.pl test wikipedia\n";
}
if ($checkChange eq 1) {
print SH "$nice$\perl checkChange.pl test wikipedia\n";
}
if ((($only eq "" || $only eq 0) || $only =~ /(^|[,;]) *test *([,;]|$)/) && ($skip eq "" || $skip !~ /(^|[,;]) *test *([,;]|$)/)) {
print SH "$nice$\perl localNotif.pl test.wikipedia\n";
print SH "$nice$pythonV pagefromfile.py \"-family:test\" \"-lang:test\" -file:globalNotif.txt$force -notitle$minor -start:\"\#START\" -titlestart:\"\#TITLE=\" -titleend:\"\#\" -end:\"\#STOP\" -summary:\"$summary\"\n";
}
# commons.wikimedia.org
print PY "usernames['commons']['commons'] = 'WikimediaNotifier'\n";
if ($checkBLocks eq 1) {
print SH "$nice$\perl checkBLocks.pl commons wikimedia\n";
}
if ($checkChange eq 1) {
print SH "$nice$\perl checkChange.pl commons wikimedia\n";
}
if ((($only eq "" || $only eq 0) || $only =~ /(^|[,;]) *commons *([,;]|$)/) && ($skip eq "" || $skip !~ /(^|[,;]) *commons *([,;]|$)/)) {
print SH "$nice$\perl localNotif.pl commons.wikimedia\n";
print SH "$nice$pythonV pagefromfile.py \"-family:commons\" \"-lang:commons\" -file:globalNotif.txt$force -notitle$minor -start:\"\#START\" -titlestart:\"\#TITLE=\" -titleend:\"\#\" -end:\"\#STOP\" -summary:\"$summary\"\n";
}
# incubator.wikimedia.org
print PY "usernames['incubator']['incubator'] = 'WikimediaNotifier'\n";
if ($checkBLocks eq 1) {
print SH "$nice$\perl checkBLocks.pl incubator wikimedia\n";
}
if ($checkChange eq 1) {
print SH "$nice$\perl checkChange.pl incubator wikimedia\n";
}
if ((($only eq "" || $only eq 0) || $only =~ /(^|[,;]) *incubator *([,;]|$)/) && ($skip eq "" || $skip !~ /(^|[,;]) *incubator *([,;]|$)/)) {
print SH "$nice$\perl localNotif.pl incubator.wikimedia\n";
print SH "$nice$pythonV pagefromfile.py \"-family:incubator\" \"-lang:incubator\" -file:globalNotif.txt$force -notitle$minor -start:\"\#START\" -titlestart:\"\#TITLE=\" -titleend:\"\#\" -end:\"\#STOP\" -summary:\"$summary\"\n";
}
# species.wikimedia.org
print PY "usernames['species']['species'] = 'WikimediaNotifier'\n";
if ($checkBLocks eq 1) {
print SH "$nice$\perl checkBLocks.pl species wikimedia\n";
}
if ($checkChange eq 1) {
print SH "$nice$\perl checkChange.pl species wikimedia\n";
}
if ((($only eq "" || $only eq 0) || $only =~ /(^|[,;]) *species *([,;]|$)/) && ($skip eq "" || $skip !~ /(^|[,;]) *species *([,;]|$)/)) {
print SH "$nice$\perl localNotif.pl species.wikimedia\n";
print SH "$nice$pythonV pagefromfile.py \"-family:species\" \"-lang:species\" -file:globalNotif.txt$force -notitle$minor -start:\"\#START\" -titlestart:\"\#TITLE=\" -titleend:\"\#\" -end:\"\#STOP\" -summary:\"$summary\"\n";
}
# beta.wikiversity.org
print PY "usernames['wikiversity']['beta'] = 'WikimediaNotifier'\n";
if ($checkBLocks eq 1) {
print SH "$nice$\perl checkBLocks.pl beta wikiversity\n";
}
if ($checkChange eq 1) {
print SH "$nice$\perl checkChange.pl beta wikiversity\n";
}
if ((($only eq "" || $only eq 0) || $only =~ /(^|[,;]) *wikiversity *([,;]|$)/) && ($skip eq "" || $skip !~ /(^|[,;]) *wikiversity *([,;]|$)/)) {
print SH "$nice$\perl localNotif.pl beta.wikiversity\n";
print SH "$nice$pythonV pagefromfile.py \"-family:wikiversity\" \"-lang:beta\" -file:globalNotif.txt$force -notitle$minor -start:\"\#START\" -titlestart:\"\#TITLE=\" -titleend:\"\#\" -end:\"\#STOP\" -summary:\"$summary\"\n";
}
# www.wikisource.org
print PY "usernames['wikisource']['-'] = 'WikimediaNotifier'\n";
if ($checkBLocks eq 1) {
print SH "$nice$\perl checkBLocks.pl www wikisource\n";
}
if ($checkChange eq 1) {
print SH "$nice$\perl checkChange.pl www wikisource\n";
}
if ((($only eq "" || $only eq 0) || $only =~ /(^|[,;]) *wikisource *([,;]|$)/) && ($skip eq "" || $skip !~ /(^|[,;]) *wikisource *([,;]|$)/)) {
print SH "$nice$\perl localNotif.pl www.wikisource\n";
print SH "$nice$pythonV pagefromfile.py \"-family:wikisource\" \"-lang:-\" -file:globalNotif.txt$force -notitle$minor -start:\"\#START\" -titlestart:\"\#TITLE=\" -titleend:\"\#\" -end:\"\#STOP\" -summary:\"$summary\"\n";
}
# ...mediawiki,i18n,omegawiki
#
# Language projects
$url = "http://meta.wikimedia.org/w/api.php?action=sitematrix&format=xml";
$userAgent = LWP::UserAgent->new();
$userAgent->agent("WikimediaNotificationBot");
$httpRequest = HTTP::Request->new("GET", $url);
$serverResponse = $userAgent->request($httpRequest, "siteMatrix.xml");
if ($serverResponse->is_error()) {
$serverError = 1;
} else {
open XML, "siteMatrix.xml";
open TXT, ">siteMatrix.txt";
while (defined($in = <XML>)) {
$out = $in;
$out =~ s/<site url=/\n<site url=/g;
print TXT $out;
}
close TXT;
close XML;
open WSM, "siteMatrix.txt";
while(<WSM>) {
if ($_ =~ /<site url="http:\/\/([^\.]+)\.([^\.]+)\./) {
$found = 1;
$wLang = $1;
$prDom = $2;
print PY "usernames['$prDom\']['$wLang\'] = 'WikimediaNotifier'\n";
#if ($prDom eq "wikipedia") {
# $file = "globalNotif_w.txt";
#} elsif ($prDom eq "wiktionary") {
# $file = "globalNotif_wikt.txt";
#} elsif ($prDom eq "wikibooks") {
# $file = "globalNotif_b.txt";
#} elsif ($prDom eq "wikiquote") {
# $file = "globalNotif_q.txt";
#} elsif ($prDom eq "wikisource") {
# $file = "globalNotif_s.txt";
#} elsif ($prDom eq "wikinews") {
# $file = "globalNotif_n.txt";
#} elsif ($prDom eq "wikiversity") {
# $file = "globalNotif_v.txt";
#}
#if ($wLang eq "als") {
# $file =~ s/\.txt$//;
# $file = "$file$\_als.txt";#gsw
#} elsif ($wLang eq "simple") {
# $file =~ s/\.txt$//;
# $file = "$file$\_simple.txt";#en
#} elsif ($wLang eq "be-x-old") {
# $file =~ s/\.txt$//;
# $file = "$file$\_be-x-old.txt";#be-tarask
#} elsif ($wLang eq "roa-rup") {
# $file =~ s/\.txt$//;
# $file = "$file$\_roa-rup.txt";#rup
#}
#...$file
if ($checkBLocks eq 1) {
print SH "$nice$\perl checkBLocks.pl $wLang $prDom +status\n";#3=switch
}
if ($checkChange eq 1) {
print SH "$nice$\perl checkChange.pl $wLang $prDom\n";
}
unless (-e "families/locked_$wLang$prDom.txt") {
if ((($only eq "" || $only eq 0) || $only =~ /(^|[,;]) *$prDom *([,;]|$)/) && ($skip eq "" || $skip !~ /(^|[,;]) *$prDom *([,;]|$)/)) {
print SH "$nice$\perl localNotif.pl $wLang.$prDom\n";
if ($prDom eq "wikipedia" && $summaryTopic =~ /^[Tt]ranslation of the [Ww]eek$/) {
$wikiSummary = "\*\*\*\* \[\[m:Translation_of_the_week\|translation request\]\] \*\*\*\*";#\[\[Special:Inexistent\|\*\*\*\*\]\] ... \[\[Special:Nonexistent\|\*\*\*\*\]\]
$wikiMinor = "";
} elsif (($prDom eq "wikipedia" && $topics{$summaryTopic} =~ /(^|,)w(,|$)/) || ($prDom eq "wikibooks" && $topics{$summaryTopic} =~ /(^|,)b(,|$)/) || ($prDom eq "wiktionary" && $topics{$summaryTopic} =~ /(^|,)wikt(,|$)/) || ($prDom eq "wikinews" && $topics{$summaryTopic} =~ /(^|,)n(,|$)/) || ($prDom eq "wikisource" && $topics{$summaryTopic} =~ /(^|,)s(,|$)/) || ($prDom eq "wikiquote" && $topics{$summaryTopic} =~ /(^|,)q(,|$)/) || ($prDom eq "wikiversity" && $topics{$summaryTopic} =~ /(^|,)v(,|$)/)) {#...overall[+Commons/singles]? See above!? || ToDo: if it's in $summaryTopic2,3?
$wikiSummary = "\*\*\*\* \[\[User:WikimediaNotifier/notifications\#$summaryTopic\|$summaryTopic\]\]$furtherTopics \*\*\*\*";#\[\[Special:Inexistent\|\*\*\*\*\]\] ... \[\[Special:Nonexistent\|\*\*\*\*\]\]
$wikiMinor = "";
} else {
$wikiSummary = $summary;#...thus send some-wikis-only messages without additional minor changes!
$wikiMinor = $minor;#...therefore send some-wikis-only messages without additional minor changes!
}
print SH "$nice$pythonV pagefromfile.py \"-family:$prDom\" \"-lang:$wLang\" -file:globalNotif.txt$force -notitle$wikiMinor -start:\"\#START\" -titlestart:\"\#TITLE=\" -titleend:\"\#\" -end:\"\#STOP\" -summary:\"$wikiSummary\"\n";
}
}
}
}
close WSM;
unlink ("siteMatrix.txt");
}
unlink ("siteMatrix.xml");
print SH "rm -f globalNotif.txt\n";
print SH "rm -f globalNotif.dat\n";
close PY;
close SH;
}
if ($serverError || !$found) {
unlink ("globalEdit.tmp");
open SH, ">globalEdit.tmp";
print SH "\#!/bin/bash\n";
print SH "exit 0\n";
close SH;
} else {
chmod 0700, 'user-config.py';
}
} else {
open SH, ">globalEdit.tmp"; print SH "\#!/bin/bash\n"; print SH "exit 0\n"; close SH;
} chmod 0700, 'globalEdit.tmp';