Page Menu
Home
GitPull.it
Search
Configure Global Search
Log In
Files
F15173608
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..08b48a1
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+# credentials
+config.php
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..c73388b
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "boz-mw"]
+ path = boz-mw
+ url = https://github.com/valerio-bozzolan/boz-mw
diff --git a/bot.php b/bot.php
new file mode 100755
index 0000000..7834cc1
--- /dev/null
+++ b/bot.php
@@ -0,0 +1,90 @@
+#!/usr/bin/php
+<?php
+include 'boz-mw/autoload.php';
+include 'config.php';
+
+defined( 'MARKADMINS_PAGE' ) or exit( "fill config" );
+
+// groups on Meta
+$META_GROUPS = [
+ 'S' => 'steward',
+];
+
+// groups on Italian Wikipedia
+$WIT_GROUPS = [
+ 'B' => 'bureaucrat',
+ 'CU' => 'checkuser',
+ 'A' => 'sysop',
+ 'AI' => 'interface-admin',
+];
+
+// all groups
+$GROUPS = array_merge( $META_GROUPS, $WIT_GROUPS );
+
+// user list
+$users = [];
+
+// counter indexed by group name
+$counts = [];
+foreach( $GROUPS as $group ) {
+ $counts[ $group ] = 0;
+}
+
+// choosen wikis
+$wit = \wm\WikipediaIt::getInstance();
+
+$lists = [
+ 'allusers',
+ 'globalallusers',
+]
+
+// fetch all the sysops, checkusers, etc. from Italian wikipedia
+// https://it.wikipedia.org/w/api.php?action=help&modules=query%2Ballusers
+$results = $wit->createQuery( [
+ 'action' => 'query',
+ 'list' => $lists,
+
+ // allusers
+ 'auprop' => 'groups',
+ 'augroup' => array_values( $WIT_GROUPS ),
+ 'aulimit' => 400,
+
+ // globalallusers
+ 'agugroup' => 'steward',
+ 'agulimit' => 200,
+] );
+
+// query continuation
+foreach( $results->getGenerator() as $result ) {
+ foreach( $lists as $list ) {
+ foreach( $result->query->{ $list } as $user ) {
+ $name = $user->name;
+ $users[ $name ] = isset( $users[ $name ] ) ? $users[ $name ] : [];
+ if( isset( $user->groups ) ) {
+ foreach( $user->groups as $group ) {
+ $legend = array_search( $group, $GROUPS, true );
+ if( $legend ) {
+ $users[ $name ][] = $legend;
+ $counts[ $group ]++;
+ }
+ }
+ }
+ }
+ }
+}
+
+// stats message
+$stats = [];
+foreach( $counts as $group => $count ) {
+ $stats[] = "$group: $count";
+}
+$stats = implode( ", ", $stats );
+
+$wit->login();
+$wit->edit( [
+ 'title' => MARKADMINS_PAGE,
+ 'summary' => "Bot: aggiornamento elenco utenti: $stats",
+ 'text' => json_encode( [ 'legend' => $GROUPS, 'users' => $users ] ),
+ 'contentformat' => 'application/json',
+ 'bot' => 1,
+] );
diff --git a/boz-mw b/boz-mw
new file mode 160000
index 0000000..68863fd
--- /dev/null
+++ b/boz-mw
@@ -0,0 +1 @@
+Subproject commit 68863fdc736787f2fe59d55011c283695fdf455b
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Nov 19, 01:59 (1 d, 1 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2263710
Default Alt Text
(2 KB)
Attached To
Mode
R31 Italian Wikipedia Mark Admins (backup)
Attached
Detach File
Event Timeline