User:ClueBot II/wikiprojectarchival.js

Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
set %tmp '';
set %cm '';
getcategorymembers %tmp "\n" 'WikiProjects';
varappend %cm %tmp;
set %count $gettok(%cm,"\n",0);
while (%count == 500) {
	getcategorymembers %tmp "\n" 'WikiProjects' $gettok(%tmp,"\n",500);
	varappend %cm $cat("\n",%tmp);
	set %count $gettok(%cm,"\n",0);
}
set %pages '';
foreach %cm "\n" %page {
	if ($gettok(%page,':',1,2) == 'Wikipedia') {
		set %name $gettok(%page,':',2,2);
		if ($strpos(%name,'/') == (-1)) {
			getmodifiedtime %pmod %page;
			if (($time(0) - %pmod) >= 5184000) {
				getmodifiedtime %tmod $cat('Wikipedia talk:',%name);
				if (($time(0) - %tmod) >= 5184000) {
					pageget %page %data;
					if ($stripos(%data,'{{inactive}}') == (-1)) {
						varprepend %data "{{inactive}}\n";
					}
					set %data $pregreplace(%data,'/\[\[Category:WikiProjects(\|[^\x5d]*)?\]\]/i','');
					pageset %page %data 'Tagging inactive WikiProject. (BOT)';
				}
			}
		}
	}
}