use MediaWiki::Bot; our $VERSION = '0.7.0'; $editor=new MediaWiki::Bot('ST47', "&assert=user", "ST47"); open(FH, './pass'); $password=; chomp($password); close FH; $editor->login('ST47', $password); $|=1; print "Bot name? "; chomp($name=); print "Task number? "; chomp($tasknum=); print "Command? (trial, approve, deny, expire, oan) "; chomp($command=); print "Comment? "; chomp($comment=); $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=); $text=$editor->get_text("$prefix$name $tasknum"); $text.="\n*{{BotTrial$param}} $comment ~~~~"; $editor->edit("$prefix$name $tasknum", $text, "Approving $name for trial"); $brfat=$editor->get_text($brfa); if ($brfat=~s/(\{\{BRFA\|$name\|$tasknum.+)\n//i) { $template=$1; $template=~s/Open/Trial/i; $brfat=~s/NT-->\n/NT-->\n$template\n/i; $editor->edit($brfa, $brfat, "$name approved for trial"); } else { print "Couldn't edit BRFA\n"; } } if ($command eq "expire") { $text=$editor->get_text("$prefix$name $tasknum"); $text=~s/\[\[Category:Open.+\n//; $text="{{subst:BT|Expired}}\n".$text."\n*{{BotExpired}} $comment ~~~~\n{{subst:BB}}"; $editor->edit("$prefix$name $tasknum", $text, "$name has expired"); $brfat=$editor->get_text($brfa); if ($brfat=~s/(\{\{BRFA\|$name\|$tasknum.+)\n//i) { $template=$1; $template=~s/Open|Trial/Expired/i; $template=~s/\}/|~~~~~\}/; $brfat=~s/NE-->\n/NE-->\n$template\n/i; $editor->edit($brfa, $brfat, "$name has expired"); } else { print "Couldn't edit BRFA\n"; } } if ($command eq "deny") { $text=$editor->get_text("$prefix$name $tasknum"); $text=~s/\[\[Category:Open.+\n//; $text="{{subst:BT|Denied}}\n".$text."\n*{{BotDenied}} $comment ~~~~\n{{subst:BB}}"; $editor->edit("$prefix$name $tasknum", $text, "$name has been denied"); $brfat=$editor->get_text($brfa); if ($brfat=~s/(\{\{BRFA\|$name\|$tasknum.+)\n//i) { $template=$1; $template=~s/Open|Trial/Denied/i; $template=~s/\}/|~~~~~\}/; $brfat=~s/ND-->\n/ND-->\n$template\n/i; $editor->edit($brfa, $brfat, "$name has been denied"); } else { print "Couldn't edit BRFA\n"; } } if ($command eq "approve") { if ($tasknum=~/./) { print "Needs flag? "; $needsflag=; chomp($needsflag); } $text=$editor->get_text("$prefix$name $tasknum"); $text=~s/\[\[Category:Open.+\n//; $text="{{subst:BT|Approved}}\n".$text."\n*{{BotApproved}} $comment ~~~~\n{{subst:BB}}"; $editor->edit("$prefix$name $tasknum", $text, "Approving $name"); $brfat=$editor->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->get_text($approved); $brfaat=~s/-->\n/-->\n$template\n/i; $editor->edit($brfa, $brfat, "$name approved"); $editor->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->get_text("$prefix$name $tasknum"); $text.="\n*{{OperatorAssistanceNeeded}} $comment ~~~~"; $editor->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