User:Pibot/askbot

From RationalWiki
Jump to: navigation, search
use Perlwikipedia;
 
$user = 'Pibot'; my $pass = '*****';
$editor=Perlwikipedia->new($user);
 
$editor->set_wiki('rationalwiki.com','wiki');
 
$editor->{debug} = 1;
 
$source="RationalWiki:What is going on at ASK?";
$content=$editor->get_text($source);
 
@stuff=split(/\Q<!--askbot-->\E/,$content);
$threads=@stuff[1];
 
@sections=split(/\Q===\E/,$threads);
$num=scalar(@sections)-1;
$text=$sections[$num];
$num=$num-1;
$title=$sections[$num];
 
$content=~s/\=\=\=$title\=\=\=//;
$content=~s/\Q$text\E//;
 
$editor->login($user, $pass);
 
$editor->edit($source,$content,"Archiving",1);
 
##############################################
 
use Date::Calc qw(
     	Today Day_of_Week Days_in_Month
      Month_to_Text Day_of_Week_Abbreviation
    );
 
 
      my ($today_year, $today_month, $today_day)
        = Today;
 
      my $month_name = Month_to_Text($today_month);
 
$newmonth='==='.$month_name.' '.$today_year.'===';
$toptext='<!--POST NEXT ENTRY HERE. CHECK THE NUMBER OF THE PREVIOUS ONE BEFORE ADDING AN ENTRY. DO NOT REUSE A NUMBER OR LEAVE AN X IN PLACE!-->';
 
my $lastmonth = Month_to_Text($today_month-1);
    if ( $sections[2]=~/poll\=ask(.*?)\>/ ) {                               
        $lastnum=$1;
    }
 
$bottomtext='<!--'.$lastmonth.' ended with ask'.$lastnum.' -->';
 
$newsection=$newmonth."\n".$toptext."\n\n".$bottomtext;
 
$content=~s/\Q<!--askbot-->\E/<!--askbot-->\n$newsection/;
 
$editor->edit($source,$content,"New Month",1);
 
 
##############################################
 
@wigos=split(/\<vote\ poll\=ask/,$text);
$z=1;
while($wigos[$z]){
		@items=split(/(\ |\>)/,$wigos[$z]);
		$labelnum=$items[0];
		$text=~s/\Qpoll=ask$labelnum\E/poll=ask$labelnum closed=\"yes\"/;
		$z=$z+1;
}
 
$heading="===".$title."===";
 
$editor->edit("RationalWiki:What is going on at ASK?/".$title,$heading."\r".$text,"New archive",1);
Personal tools
Namespaces

Variants
Actions
Navigation
Community
Tools
support