[PerlWikiBot] SF.net SVN: perlwikibot: [25] trunk
Status: Pre-Alpha
Brought to you by:
rotemliss
|
From: <rot...@us...> - 2006-09-16 14:07:29
|
Revision: 25
http://svn.sourceforge.net/perlwikibot/?rev=25&view=rev
Author: rotemliss
Date: 2006-09-16 07:07:18 -0700 (Sat, 16 Sep 2006)
Log Message:
-----------
Allowing automated page deletions, and several fixes.
Modified Paths:
--------------
trunk/bot.pl
trunk/includes/actions.pm
trunk/includes/functions.pm
Modified: trunk/bot.pl
===================================================================
--- trunk/bot.pl 2006-09-16 13:28:27 UTC (rev 24)
+++ trunk/bot.pl 2006-09-16 14:07:18 UTC (rev 25)
@@ -37,12 +37,15 @@
for ( my $i = 0; $i <= $#pages; $i += 2 ) {
# Get title and action
my $title = $pages[$i];
- my $action = $configure::actions{ $pages[$i + 1] };
+ my $action = $pages[$i + 1];
+ my $actionName = $configure::actions{ $action };
# Execute the action (TODO: add move and delete)
- if ( $action eq "replace" ) {
- functions::replaceInPage( $title );
- } elsif ( $action eq "refresh" ) {
- functions::refreshPage( $title );
+ if ( $actionName eq "replace" ) {
+ functions::replaceInPage( $title, $action );
+ } elsif ( $actionName eq "refresh" ) {
+ functions::refreshPage( $title, $action );
+ } elsif ( $actionName eq "delete" ) {
+ functions::deletePage( $title, $action );
}
}
Modified: trunk/includes/actions.pm
===================================================================
--- trunk/includes/actions.pm 2006-09-16 13:28:27 UTC (rev 24)
+++ trunk/includes/actions.pm 2006-09-16 14:07:18 UTC (rev 25)
@@ -17,7 +17,7 @@
# Edit page
sub editPage {
# Get parameters
- my ( $title, $text, $editSummary ) = @_;
+ my ( $title, $text, $summary ) = @_;
print "Editing page $title...\n";
@@ -51,7 +51,7 @@
wpStarttime => $startTime,
wpEdittime => $editTime,
wpEditToken => $editToken,
- wpSummary => $editSummary,
+ wpSummary => $summary,
wpTextbox1 => $text,
wpMinoredit => 1,
],
@@ -75,12 +75,12 @@
# Move page
sub movePage {
# Get parameters
- my ( $title, $newTitle, $reason ) = @_;
+ my ( $oldTitle, $newTitle, $reason ) = @_;
- print "Moving page $title to $newTitle...\n";
+ print "Moving page $oldTitle to $newTitle...\n";
# Get the delete page contents
- my $page = http::getPage( "Special:Movepage/$title" );
+ my $page = http::getPage( "Special:Movepage/$oldTitle" );
# Get edit token
$page =~ /<input type='hidden' name='wpEditToken' value="([0-9,a-f]{32})" \/>/;
@@ -91,7 +91,7 @@
if ( $configure::sendPages == 1 ) {
http::postPage( "Special:Movepage", "submit",
[
- wpOldTitle => $title,
+ wpOldTitle => $oldTitle,
wpNewTitle => $newTitle,
wpReason => $reason,
wpEditToken => $editToken,
Modified: trunk/includes/functions.pm
===================================================================
--- trunk/includes/functions.pm 2006-09-16 13:28:27 UTC (rev 24)
+++ trunk/includes/functions.pm 2006-09-16 14:07:18 UTC (rev 25)
@@ -169,14 +169,15 @@
# Replace regular expressions in the page
sub replaceInPage {
# Get parameters
- my ($title) = @_;
+ my ( $title, $action ) = @_;
+ # Send page
if ( $configure::sendPages == 1 || $configure::sendPages == 2 ) {
# Get the edited page contents
- my $editedPage = actions::getPageContents( $title );
+ my $page = actions::getPageContents( $title );
# Set initial edit summary
- my $editSummary = $configure::initialEditSummaries{ $ARGV[0] };
+ my $summary = $configure::initialEditSummaries{ $ARGV[0] };
# Groups array
my @executedActions = filterActionsList( @configure::executedActions );
@@ -190,20 +191,20 @@
for ( my $i = 0; $i <= $#actions; $i++ ) {
my $action = $actions[$i];
my $search = $configure::texts{ $action };
- if ( $editedPage =~ /$search/ ) {
+ if ( $page =~ /$search/ ) {
my $replace = $configure::news{ $action };
- $editedPage =~ s/$search/$replace/g;
+ $page =~ s/$search/$replace/g;
if ( $replaced == 1 ) {
- $editSummary = "$editSummary, ";
+ $summary = "$summary, ";
}
- $editSummary = $editSummary.$configure::reasons{ $action };
+ $summary = $summary.$configure::reasons{ $action };
$replaced = 1;
}
}
# Edit page only of replaced something
if ( $replaced == 1 ) {
- actions::editPage( $title, $editedPage, $editSummary );
+ actions::editPage( $title, $page, $summary );
}
} else {
print "Replaced in page $title.\n";
@@ -213,8 +214,9 @@
# Refresh page
sub refreshPage {
# Get parameters
- my ( $title ) = @_;
+ my ( $title, $action ) = @_;
+ # Send page
if ( $configure::sendPages == 1 || $configure::sendPages == 2 ) {
actions::refreshPage( $title );
} else {
@@ -225,10 +227,11 @@
# Delete page
sub deletePage {
# Get parameters
- my ( $title ) = @_;
+ my ( $title, $action ) = @_;
+ # Send page
if ( $configure::sendPages == 1 || $configure::sendPages == 2 ) {
- actions::deletePage( $title );
+ actions::deletePage( $title, $configure::reasons{ $action } );
} else {
print "Deleted page $title.\n";
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|