<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">use MediaWiki::Bot;
our $VERSION = '0.7.0';
$editor=new MediaWiki::Bot('ST47', "&amp;assert=user", "ST47");
open(FH, './pass');
$password=&lt;FH&gt;;
chomp($password);
close FH;
$editor-&gt;login('ST47', $password);
$|=1;

print "Bot name? ";
chomp($name=&lt;STDIN&gt;);
print "Task number? ";
chomp($tasknum=&lt;STDIN&gt;);
print "Command? (trial, approve, deny, expire, oan) ";
chomp($command=&lt;STDIN&gt;);
print "Comment? ";
chomp($comment=&lt;STDIN&gt;);

$prefix="Wikipedia:Bots/Requests for approval/";
$brfa="Wikipedia:Bots/Requests for approval";
$approved="Wikipedia:Bots/Requests for approval/Approved";

if ($command eq "trial") {
	print "Param? ";
	chomp($param=&lt;STDIN&gt;);
	$text=$editor-&gt;get_text("$prefix$name $tasknum");
	$text.="\n*{{BotTrial$param}} $comment ~~~~";
	$editor-&gt;edit("$prefix$name $tasknum", $text, "Approving $name for trial");
	$brfat=$editor-&gt;get_text($brfa);
	if ($brfat=~s/(\{\{BRFA\|$name\|$tasknum.+)\n//i) {
		$template=$1;
		$template=~s/Open/Trial/i;
		$brfat=~s/NT--&gt;\n/NT--&gt;\n$template\n/i;
		$editor-&gt;edit($brfa, $brfat, "$name approved for trial");
	} else {
		print "Couldn't edit BRFA\n";
	}
}

if ($command eq "expire") {
	$text=$editor-&gt;get_text("$prefix$name $tasknum");
	$text=~s/&lt;noinclude&gt;\[\[Category:Open.+\n//;
	$text="{{subst:BT|Expired}}\n".$text."\n*{{BotExpired}} $comment ~~~~\n{{subst:BB}}";
	$editor-&gt;edit("$prefix$name $tasknum", $text, "$name has expired");
	$brfat=$editor-&gt;get_text($brfa);
	if ($brfat=~s/(\{\{BRFA\|$name\|$tasknum.+)\n//i) {
		$template=$1;
		$template=~s/Open|Trial/Expired/i;
		$template=~s/\}/|~~~~~\}/;
		$brfat=~s/NE--&gt;\n/NE--&gt;\n$template\n/i;
		$editor-&gt;edit($brfa, $brfat, "$name has expired");
	} else {
		print "Couldn't edit BRFA\n";
	}
}

if ($command eq "deny") {
	$text=$editor-&gt;get_text("$prefix$name $tasknum");
	$text=~s/&lt;noinclude&gt;\[\[Category:Open.+\n//;
	$text="{{subst:BT|Denied}}\n".$text."\n*{{BotDenied}} $comment ~~~~\n{{subst:BB}}";
	$editor-&gt;edit("$prefix$name $tasknum", $text, "$name has been denied");
	$brfat=$editor-&gt;get_text($brfa);
	if ($brfat=~s/(\{\{BRFA\|$name\|$tasknum.+)\n//i) {
		$template=$1;
		$template=~s/Open|Trial/Denied/i;
		$template=~s/\}/|~~~~~\}/;
		$brfat=~s/ND--&gt;\n/ND--&gt;\n$template\n/i;
		$editor-&gt;edit($brfa, $brfat, "$name has been denied");
	} else {
		print "Couldn't edit BRFA\n";
	}
}

if ($command eq "approve") {
	if ($tasknum=~/./) {
		print "Needs flag? ";
		$needsflag=&lt;STDIN&gt;;
		chomp($needsflag);
	}
	$text=$editor-&gt;get_text("$prefix$name $tasknum");
	$text=~s/&lt;noinclude&gt;\[\[Category:Open.+\n//;
	$text="{{subst:BT|Approved}}\n".$text."\n*{{BotApproved}} $comment ~~~~\n{{subst:BB}}";
	$editor-&gt;edit("$prefix$name $tasknum", $text, "Approving $name");
	$brfat=$editor-&gt;get_text($brfa);
	if ($brfat=~s/(\{\{BRFA\|$name\|$tasknum.+)\n//i) {
		$template=$1;
		if ($tasknum=~/./ and not $needsflag) {
			$template=~s/Open|Trial/Flagged/i;
			$template=~s/BRFA/subst:BRFAA/i;
		} else {
			$template=~s/Open|Trial/Approved/i;
		}
		$template=~s/\}/|~~~~~\}/;
		$brfaat=$editor-&gt;get_text($approved);
		$brfaat=~s/--&gt;\n/--&gt;\n$template\n/i;
		$editor-&gt;edit($brfa, $brfat, "$name approved");
		$editor-&gt;edit($approved, $brfaat, "$name approved");
	} else {
		print "Couldn't edit BRFA\n";
	}
}

if ($command eq "oan") {
	unless ($comment=~/./) {$comment="What's the status of this bot request?"}
	$text=$editor-&gt;get_text("$prefix$name $tasknum");
	$text.="\n*{{OperatorAssistanceNeeded}} $comment ~~~~";
	$editor-&gt;edit("$prefix$name $tasknum", $text, "Requesting operator response");
}

=head1 NAME

BAGscript, a Wikipedia bot for use by BAG members who wish to automate 
their tasks.

=pod SCRIPT CATEGORIES

Web

=cut

</pre></body></html>