-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrfx-tally.php
92 lines (72 loc) · 2.45 KB
/
rfx-tally.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
ini_set('memory_limit','16M');
define('PILLAR','PILLAR');
require_once('/home/soxred93/pillar/trunk/class.pillar.php');
require_once('/home/soxred93/textdiff/textdiff.php');
require_once('/home/soxred93/rfalib3.php');
$pillar = Pillar::ini_launch('/home/soxred93/configs/rfx-tally.cfg');
$site = $pillar->cursite;
$enablepage = "User:SoxBot/Run/Tally";
try {
$run = new Page($site,$enablepage);
$run = $run->get_text();
} catch (PillarException $e) {
die( "Got an error when getting the enable page.\n" );
}
if( !preg_match( '/(enable|yes|run|go|start)/i', $run ) ) {
die( "Bot is disabled.\n" );
}
$name = "Wikipedia:Requests for adminship";
try {
//$rfa_main = new Page($site,$name);
$open_rfxs = $site->get_embeddedin("Template:Rfatally",50,$continue,$namespace = 4);
} catch (PillarException $e) {
die();
}
print_r($open_rfxs);
/*$rfa_main_text = $rfa_main->get_text();
preg_match_all('/\{\{Wikipedia:(.*?)\}\}/', $rfa_main_text, $open_rfxs);
$open_rfxs = $open_rfxs[1];*/
$tallys = array();
foreach( $open_rfxs as $open_rfx ) {
if( in_array( $open_rfx, array( 'Wikipedia:Requests for adminship/Front matter', 'Wikipedia:Requests for adminship/bureaucratship', 'Wikipedia:Requests for adminship' ) ) ) continue;
if( !preg_match( '/Wikipedia:Requests for (admin|bureaucrat)ship/i', $open_rfx ) ) continue;
//$open_rfx = str_replace(array('Wikipedia:Requests for adminship/','Wikipedia:Requests for bureaucratship/'),'',$open_rfx);
$myRFA = new RFA();
try {
$rfa_page = new Page($site,/*$name.'/'.*/$open_rfx);
} catch (PillarException $e) {
continue;
}
$rfa_text = $rfa_page->get_text();
$result = $myRFA->analyze($rfa_text);
if ($result !== TRUE) {
continue;
}
$opposes = 0;
foreach( $myRFA->oppose as $oppose ) {
//if( $oppose['name'] != 'DougsTech' && !preg_match('/User:DougsTech\/RFAreason1/i', $oppose['context'] ) ) {
$opposes++;
echo "YA\n";
//}
}
$tally = count($myRFA->support).'/'.$opposes.'/'.count($myRFA->neutral);
$open_rfx = str_replace(array('Wikipedia:Requests for adminship/','Wikipedia:Requests for bureaucratship/'),'',$open_rfx);
$tallys[$open_rfx] = $tally;
}
$out = "{{#switch: {{{1|{{SUBPAGENAME}}}}}\n";
foreach( $tallys as $rfa => $tally ) {
$out .= "|$rfa= ($tally)\n";
}
$out .= "|#default= (0/0/0)\n}}";
echo $out;
try {
$tally_page = new Page($site,"User:X!/Tally");
} catch (PillarException $e) {
die();
}
try {
$tally_page->put($out,"Updating RFA tally",true);
} catch (PillarException $e) {
}
?>