[PerlWikiBot] SF.net SVN: perlwikibot: [35] trunk
Status: Pre-Alpha
Brought to you by:
rotemliss
From: <rot...@us...> - 2007-03-03 13:27:36
|
Revision: 35 http://svn.sourceforge.net/perlwikibot/?rev=35&view=rev Author: rotemliss Date: 2007-03-03 05:27:36 -0800 (Sat, 03 Mar 2007) Log Message: ----------- Use the sysop account only when 'sysop' is specified as a parameter. Modified Paths: -------------- trunk/README trunk/bot.pl trunk/includes/functions.pm Modified: trunk/README =================================================================== --- trunk/README 2007-03-03 12:08:10 UTC (rev 34) +++ trunk/README 2007-03-03 13:27:36 UTC (rev 35) @@ -10,7 +10,4 @@ Now copy the files "configure.sample" and "runtime.sample" in the folder "config" to the names "configure.pm" and "runtime.pm", and configure them. You should first go to the configure file, then define the servers, then the actions, then go to the runtime file and define there what actions to execute, and most importantly - set "$sendPages" to 1, after the tests. -After that, you can run the file "bot.pl", with the parameter of the site name. In later times, you can edit the configure file when you want to change the actions, and always edit the run-time file to enable and disable the page sends, and to define the actions to do. - -Tips: -* Don't execute both sysop and non-sysop actions, because the sysop account will be used, even if it doesn't have a bot flag. +After that, you can run the file "bot.pl", with the parameter of the site name, and the parameter "sysop" if you want to use the sysop user (if you don't use it, actions which require sysop rights won't be executed). In later times, you can edit the configure file when you want to change the actions, and always edit the run-time file to enable and disable the page sends, and to define the actions to do. Modified: trunk/bot.pl =================================================================== --- trunk/bot.pl 2007-03-03 12:08:10 UTC (rev 34) +++ trunk/bot.pl 2007-03-03 13:27:36 UTC (rev 35) @@ -19,6 +19,13 @@ die "No server name set - please set server name!\n"; } +my $sysop; +if ( $ARGV[1] eq "sysop" ) { + $sysop = 1; +} else { + $sysop = 0; +} + # Show notes about the sending pages configuration if ( $configure::sendPages == 0 ) { print "Note: There will be no changes in the real server. Please set sendPages to 1 to do them.\n"; @@ -28,11 +35,11 @@ # Log in to the server only if you have to do some stuff in the server if ( $configure::sendPages == 1 || $configure::sendPages == 2 ) { - functions::login(); + functions::login( $sysop ); } # All the matching pages in the XML file -my @pages = functions::getMatchingPages(); +my @pages = functions::getMatchingPages( $sysop ); # Execute actions of all the pages for ( my $i = 0; $i <= $#pages; $i += 2 ) { Modified: trunk/includes/functions.pm =================================================================== --- trunk/includes/functions.pm 2007-03-03 12:08:10 UTC (rev 34) +++ trunk/includes/functions.pm 2007-03-03 13:27:36 UTC (rev 35) @@ -7,6 +7,9 @@ # Get all the pages matching specific restrictions sub getMatchingPages { + # Parameters + my $sysop = @_; + # Get the pages my $pages = mwdump->new( "dumps/".$configure::xmlFiles{ $ARGV[0] } ); @@ -15,8 +18,8 @@ die "Unable to handle any case setting besides \"first-letter\".\n"; } - # Get the executed actions of the specified server - my @possibleActions = filterActionsList( @configure::executedActions ); + # Get the executed actions of the specified server and user + my @possibleActions = filterActionsList( $sysop, @configure::executedActions ); # An array contains all the pages my @matchingPages; @@ -101,13 +104,13 @@ # Filter actions list to the specified script server sub filterActionsList { # Get parameters - my @originalList = @_; + my ( $sysop, @originalList ) = @_; # Go over the actions list, and filter the actions which are not in the current server my @newList; my $counter = 0; for ( my $i = 0; $i <= $#originalList; $i++ ) { - if ( $configure::actionServers{ $originalList[$i] } eq $ARGV[0] ) { + if ( $configure::actionServers{ $originalList[$i] } eq $ARGV[0] && ( $sysop == 1 || $configure::actions ne "delete" ) ) { $newList[$counter++] = $originalList[$i]; } } @@ -117,23 +120,9 @@ # Log in sub login { - # Is sysop finally required? - my $sysop = 0; + # Get parameters + my ( $sysop ) = @_; - # Go through the array, and check if sysop permission is needed. - for ( my $i = 0; $i <= $#configure::executedActions; $i++ ) { - my $action = $configure::actions{ $configure::executedActions[$i] }; - if ( $action eq "replace" ) { - # Continue - } elsif ($action eq "refresh") { - # Continue - } elsif ($action eq "delete") { - $sysop = 1; - } elsif ($action eq "move") { - # Continue - } - } - # Get user name and password my ( $username, $password ); if ( $sysop == 1 ) { @@ -169,9 +158,9 @@ # Set initial edit summary my $summary = $configure::initialEditSummaries{ $ARGV[0] }; - # Groups array - my @executedActions = filterActionsList( @configure::executedActions ); - my @bywayActions = filterActionsList( @configure::bywayActions ); + # Groups array (assume non-sysop, as it doesn't matter for edits) + my @executedActions = filterActionsList( 0, @configure::executedActions ); + my @bywayActions = filterActionsList( 0, @configure::bywayActions ); my @actions = ( @executedActions, @bywayActions ); # Replaced something at all? Flag to check This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |