From 08e040d2b79213e5632492f0b6f5e34924a99e4f Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 2 Jun 2014 12:01:01 -0400 Subject: It's been a while since I made a commit --- autoban.sh | 10 ++++++++++ autopatrol.rb | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ mwapi.rb | 5 +++-- scratch.rb | 36 +++++++++++++++++++++++++++++------- show-edit-counts.rb | 7 ++----- user-whitelist.rb | 26 ++++++++++++++++++++++++++ user-whitelist.txt | 16 ++++++++++++++++ 7 files changed, 136 insertions(+), 14 deletions(-) create mode 100755 autoban.sh create mode 100755 autopatrol.rb create mode 100755 user-whitelist.rb diff --git a/autoban.sh b/autoban.sh new file mode 100755 index 0000000..d234f25 --- /dev/null +++ b/autoban.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +comm -13 <(sort user-whitelist.txt) <( + < show-edit-counts.txt \ + grep -v 'blockreason:' | + grep -v 'total_editcount: 0\b' | + grep 'existing_editcount: 0\b' | + cut -d $'\t' -f1 | cut -d ' ' -f2- | + sort) | +./block-users.rb "Spammer (Autodetected: has made edits, but only to deleted pages)" diff --git a/autopatrol.rb b/autopatrol.rb new file mode 100755 index 0000000..cabc875 --- /dev/null +++ b/autopatrol.rb @@ -0,0 +1,50 @@ +#!/usr/bin/env ruby +# -*- coding: utf-8 -*- + +load 'mwapi.rb' +require 'yaml' +require 'pp' + +mw = MWApi.new('https://wiki.parabolagnulinux.org/api.php') +credentials = YAML.load_file('credentials.yml') +mw.login(credentials['username'], credentials['password']) + +print "Finding autopatrol users...\n" +users = [] +aufrom = '' +while not aufrom.nil? do + audata = mw.query( + :list => :allusers, + :aurights => :autopatrol, + :aulimit => 5000, + :aufrom => aufrom) + users.concat(audata['query']['allusers']) + aufrom = (audata['query-continue'].nil?) ? nil : audata['query-continue']['allusers']['aufrom'] +end + +print "Finding unpatrolled edits by autopatrol users...\n" +changes = [] +users.each do |user| + print " -> #{user['name']}\n" + rccontinue = '' + while not rccontinue.nil? + query = { + :list => :recentchanges, + :rcuser => user['name'], + :rclimit => 5000, + :rcshow => '!patrolled', + :rctoken => :patrol, + } + if rccontinue.length > 0 + query.merge!({:rccontinue => rccontinue}) + end + rcdata = mw.query(query) + changes.concat(rcdata['query']['recentchanges']) + rccontinue = (rcdata['query-continue'].nil?) ? nil : rcdata['query-continue']['recentchanges']['rccontinue'] + end +end + +changes.each do |change| + print "Patrolling change #{change['rcid']} to #{change['title']}\n" + mw.patrol({:rcid => change['rcid'], :token => change['patroltoken']}) +end diff --git a/mwapi.rb b/mwapi.rb index ff7e798..2a3ae61 100644 --- a/mwapi.rb +++ b/mwapi.rb @@ -2,7 +2,7 @@ require 'rest_client' require 'json' #require 'open-uri' -require 'pp' + class MWApi def initialize(api) @api = api @@ -114,7 +114,8 @@ class MWApi end def watch end - def patrol + def patrol(params = {}) + post(params.merge({:action => :patrol})) end def import end diff --git a/scratch.rb b/scratch.rb index 2c3bcf6..f52a562 100755 --- a/scratch.rb +++ b/scratch.rb @@ -58,6 +58,7 @@ mw.login(credentials['username'], credentials['password']) /Gamma Blue/i, /Garcinia/i, /Jeffraham/i, + /Jillian Michaels/i, /Jordan Fusion/i, /Jordan Retro/i, /Kate Spade/i, @@ -77,23 +78,28 @@ mw.login(credentials['username'], credentials['password']) /\bpc games? (free|crack)/i, /crack pc/i, # health topics + /(body|excess) weight/i, + /Arrhythmia/i, + /Cardiovascular/, + /P90X/, /Resistance Band/i, /diabetes/i, + /dr oz/i, /elliptical (equipment|machines?)/i, - /fat burning/i, + /fat (burning|loss)/i, /health care/i, /heart (disease|attack)/i, + /herbalife/i, /more wellness/i, /pilates/i, + /prescription/i, /skin care/i, - /weight loss/i, - /(body|excess) weight/i, - /Arrhythmia/i, - /Cardiovascular/, + /weight[ -](loss|reduction)/i, # sex topics /\b(sex|adult) cam/i, /\b(male|breast) enhancement\b/i, /\bpenis\b/i, + /viagra/i, # other topics /\b(coffee|tea) extract\b/i, /\b(good|quality) social media\b/i, @@ -109,7 +115,8 @@ mw.login(credentials['username'], credentials['password']) /\bipage (web)?host/i, /\bmen.?s (fashion|casual wear|health)\b/i, /\brap beats\b/i, - /\bsearch engine marketing\b/i, + /\breal estate\b/i, + /\bsearch engine (marketing|optimization)\b/i, /\bsocial media strategy\b/i, /\bvigorous motivators\b/i, # formats @@ -119,7 +126,22 @@ mw.login(credentials['username'], credentials['password']) /1st Impressions in/i, /The (Selection|Choice|Decision) of the .* Is Your/i, # unsorted - /\b(jerseys?|vegan|shit|marketing|finance|footwear|shoes|muscle|lesbian|islamist|bodybuilding|nfl|nba|ejaculation|wholesale|nike|Hypertension|sherbet|bankrupt|stairlifts?|outfits|surcharges?)\b/i, + /\b(chinchilla|jerseys?|vegan|shit|marketing|finance|footwear|shoes|muscle|lesbian|islamist|bodybuilding|nfl|nba|ejaculation|wholesale|nike|Hypertension|sherbet|bankrupt|stairlifts?|outfits|casinos?|surcharges?)\b/i, + /(Plombier|Serrurier) paris/i, + /Possum (Removalist|Infestation)/i, + /Google Pagerank/i, + /Twitter follower/i, + /jewellery/i, + /auto insurance/i, + /apartment moves/i, + /goji berr(ies|y)/i, + /affiliate advertising/i, + /hemorrhoids/i, + /furniture removal/i, + /cash online/i, + /Braun 5270/i, + /Focus T25/i, + /pay[ -]per[ -]click/i ] def kw(title) diff --git a/show-edit-counts.rb b/show-edit-counts.rb index 6065abd..6d3febb 100755 --- a/show-edit-counts.rb +++ b/show-edit-counts.rb @@ -1,9 +1,8 @@ #!/usr/bin/env ruby # -*- coding: utf-8 -*- -load 'mwapi.rb' +load './mwapi.rb' require 'yaml' -require 'pp' mw = MWApi.new('https://wiki.parabolagnulinux.org/api.php') credentials = YAML.load_file('credentials.yml') @@ -18,9 +17,7 @@ while not aufrom.nil? do :auprop => 'blockinfo|editcount|registration', :aulimit => 5000, :aufrom => aufrom) - for user in audata['query']['allusers'] - userqueue.push(user) - end + userqueue.concat(audata['query']['allusers']) aufrom = (audata['query-continue'].nil?) ? nil : audata['query-continue']['allusers']['aufrom'] end diff --git a/user-whitelist.rb b/user-whitelist.rb new file mode 100755 index 0000000..f6891a9 --- /dev/null +++ b/user-whitelist.rb @@ -0,0 +1,26 @@ +#!/usr/bin/env ruby +# -*- coding: utf-8 -*- + +load 'mwapi.rb' +require 'yaml' +require 'pp' + +mw = MWApi.new('https://wiki.parabolagnulinux.org/api.php') +credentials = YAML.load_file('credentials.yml') +mw.login(credentials['username'], credentials['password']) + +users = [] +aufrom = '' +while not aufrom.nil? do + audata = mw.query( + :list => :allusers, + :aurights => :autopatrol, + :aulimit => 5000, + :aufrom => aufrom) + users.concat(audata['query']['allusers']) + aufrom = (audata['query-continue'].nil?) ? nil : audata['query-continue']['allusers']['aufrom'] +end + +users.each do |user| + print "#{user['name']}\n" +end diff --git a/user-whitelist.txt b/user-whitelist.txt index 8534ce5..5636806 100644 --- a/user-whitelist.txt +++ b/user-whitelist.txt @@ -1,5 +1,8 @@ +Airon90 Alfplayer Aurelien +Brendan +Coadde Danilovboas Djs ElkyDori @@ -8,25 +11,38 @@ Emulatorman Encyclomundi Erkan Yilmaz Fauno +Fowlslegs Gaming4JC GNUtoo Habiloid Habstinat +Icarious Jaycee +Jbranso Jbsys Jorginho +Jpgg Jyaworski Kobe Leth Lukeshu +Monphey +Mtjm +Nicoals +Opticnerve Otyugh +Parabolawiki Quiliro +Rakyi Sayurlodeh Sergi Shackra Smile4ever Smv +Svitostar +Sysfu T67t67 T67t67t67 +Xihh Xylon Zykotick9 -- cgit v1.2.3