User:ST47/ARB

#!/usr/bin/perl

use strict;
use Perlwikipedia;

open(PW, "/home/st47/pass");
my $pass=<PW>;
close PW;
chomp($pass);

my $editor=new Perlwikipedia('Bot/WP/EN/ST47/AccReqBot');
$editor->login('AccReqBot', $pass);

my $accreq=$editor->get_text('Wikipedia:Request an account');
while ($accreq=~/
	==\s?([^=\n]+)\s?==
	[^\{]+
	\Q{{account request\E
	[^\|]+
	\Q|username\E\s?=\s?
	([^\n]+)
	[^\|]+
	\Q|e-mail address\E\s?=\s?
	([^\n]+)
	[^\}]+
	\}\}
	(.*?)
	(?=(==|$))
/sgix){ 
	my $section=$1;
	my $username=$2;
	my $email=$3;
	my $content=$4;
	print "\n$username:";
	my $exists=&does_this_exist($username, $content);
	if ($exists eq "user") {
		&created($section, $username, $email, $content);
	} elsif ($exists eq "0") {
		&old($section, $content, $username);
	}

}
print "\nDone!\n";
my $log=$editor->get_text('User:ST47/ARBLog');
$editor->edit('User:ST47/ARBLog', '*Ran at ' . '~'x5 . '\n' . $log, 'Success!');

sub does_this_exist {
	my ($username, $content) = @_;

	if ($content =~ /\Q{{ACC|c}}\E/i) {
		print " {{ACC|c}}!";
		return "user";
	}

	my $res = $editor->{mech}->get('http://en.wikipedia.org/w/index.php?title=Special:Log/newusers&page=User:' . $username);
	my $log=$res->content;

	if ($log =~ /created new account/) {
		print " created by user";
		return "user";
	}
return 0;
}

sub created {
	my ($section, $username, $email, $content) = @_;
	my $accreq=$editor->get_text('Wikipedia:Request an account');
	my $accreqo=$accreq;
	print " removing $section";
	$accreq=~s/
		==\s?\Q$section\E\s?==
		[^\{]+
		\{\{
		[^\}]+
		\}\}
		.*?
		((?=(==|$)))
	/\1/six;
	if ($accreqo eq $accreq) {print " couldn't remove!"} else {
	$editor->edit('Wikipedia:Request an account', $accreq, "Removing $username, done.");


	my @Time=localtime;
	my $Monthn=$Time[4]+1;
	my $Month;
	if ($Monthn == 4) {$Month = "April"}
	if ($Monthn == 5) {$Month = "May"}
	if ($Monthn == 6) {$Month = "June"}
	my $Day=$Time[3];

	my $log=$editor->get_text("Wikipedia:Request an account/$Month 2007");
	unless ($log =~ /$username/) {
		$log=~s/\n{{Wikipedia:Request an account\/F/\n*{{useracc|$username}}\n{{Wikipedia:Request an account\/F/;
		$editor->edit("Wikipedia:Request an account/$Month 2007", $log, "Adding $username");
	
	my $talk = $editor -> get_text("User talk:$username");
	chomp $talk;
	$talk || $editor->edit("User talk:$username", '{' . '{sub' . 
'st:' . 'User:ST47/Welcome}} --~~' . '~~');

	}
	print " Archived";
}}


sub old {
	my ($section, $content, $username) = @_;
	if ($content =~ /
		\Q{{ACC|\E
		.+?
		\Q}}\E
		.+?
		..:..,\s(..?)\s\w+\s2007
	/ix) {
		my $day = $1;
		if (($day + 3) < (localtime[3])) {
			my $accreq=$editor->get_text('Wikipedia:Request an account');
			my $accreqo=$accreq;
			print " removing old $section";
			$accreq=~s/
				==\s?\Q$section\E\s?==
				.*?
				(==|$)
			/\1/six;
			if ($accreqo eq $accreq) {print " couldn't remove!"} else {
				$editor->edit('Wikipedia:Request an account', $accreq, "Removing $username, old.");
			}
		}
	}
}

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.