#!/usr/bin/env ruby # -*- coding: utf-8 -*- load 'mwapi.rb' require 'yaml' mw = MWApi.new('https://wiki.parabolagnulinux.org/api.php') credentials = YAML.load_file('credentials.yml') mw.login(credentials['username'], credentials['password']) aufrom = '' while not aufrom.nil? do audata = mw.query(:list => :allusers, :aulimit => 200, :aufrom => aufrom, :auprop => 'blockinfo') for user in audata['query']['allusers'] if user['blockid'].nil? deleted_edits = 0 # XXX actually is the number of deleted pages edited, not number of edits existing_edits = 0 drcontinue = '' while not drcontinue.nil? drdata = mw.query(:list => :deletedrevs, :druser => user['name'], :drlimit => 200) deleted_edits += drdata['query']['deletedrevs'].length drcontinue = nil end uccontinue = '' while not uccontinue.nil? ucdata = mw.query(:list => :usercontribs, :ucuser => user['name'], :uclimit => 200, :uccontinue => uccontinue) existing_edits += ucdata['query']['usercontribs'].length if ucdata['query-continue'].nil? uccontinue = nil else uccontinue = ucdata['query-continue']['usercontribs']['uccontinue'] end end print "Username: #{user['name']}\tdeleted: #{deleted_edits}\texisting: #{existing_edits}\n" else print "Username: #{user['name']}\tblockreason: #{user['blockreason']}\n" end end if audata['query-continue'].nil? aufrom = nil else aufrom = audata['query-continue']['allusers']['aufrom'] end end