User:ImplSearchBot/Code: Difference between revisions

From Rosetta Code
m (User:Short Circuit/ImplSearchBot moved to User:ImplSearchBot/ImplSearchBot: Moved to the user created for it.)
(No difference)

Revision as of 03:04, 19 February 2009

<lang perl>#!/usr/bin/perl use strict; use MediaWiki::Bot;

my $editor = MediaWiki::Bot->new("ImplSearchBot/1.0.0");

print "Created editor...trying to set wiki.\n";

$editor->set_wiki('rosettacode.org','w');

print "Set Wiki...trying to log in.\n";

unless("Success" == $editor->login($username,$password)) {

 die "Unable to login: " . $editor->errstr;

}

print "Logged in...getting tasks\n";

my @alltasks = $editor->get_pages_in_category('Category:Programming Tasks');

print "Got all the tasks...getting the languages.\n"; my @alllanguages = $editor->get_pages_in_category('Category:Programming Languages');

foreach my $language (@alllanguages) {

 $language =~ s/Category://;

}

print "Filling langtaskmap\n"; my %langtaskmap;

foreach my $language (@alllanguages) {

 my %lang = map {$_, 1} $editor->get_pages_in_category("Category:$language");
 $langtaskmap{$language} = \%lang;

}

print "Beginning edit cycle\n"; foreach my $language (@alllanguages) {

 my $pagename = "Tasks not implemented in $language";
 print "Preparing data for:$pagename\n";
 my $pagedata = "

The code that drives these pages is under active development, and formatting issues may be present. However, the result set itself should be accurate to within fifteen minutes of the last viewing.

These are currently not implemented in $language. Please implement if you can. If any tasks are not possible or too complex in $language, they will not be on this list. To mark a task as such, add {{omit from|$language}} to that task.

\n";
 foreach my $taskname (@alltasks)
 {
   unless(exists $langtaskmap{$language}->{$taskname})
   {
     $pagedata .= "* $taskname\n";
   }
 }
 print "Editing:$pagename\n";
 $editor->edit($pagename, $pagedata, "Bot:Updating list of unimplemented tasks.", 1);

}</lang>