From 3e06c6586453d5c592f3391d2ac0056c49568f86 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 2 Jun 2014 12:26:24 -0400 Subject: mv user-whitelist.rb show-user-whitelist.rb, have autoban.sh update files --- autoban.sh | 27 ++++++++++++++++++++------- show-user-whitelist.rb | 25 +++++++++++++++++++++++++ user-whitelist.rb | 25 ------------------------- 3 files changed, 45 insertions(+), 32 deletions(-) create mode 100755 show-user-whitelist.rb delete mode 100755 user-whitelist.rb diff --git a/autoban.sh b/autoban.sh index d234f25..137fa72 100755 --- a/autoban.sh +++ b/autoban.sh @@ -1,10 +1,23 @@ #!/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) | +cached=false +if [[ $1 == --cached ]]; then + cached=true +fi + +for file in show-user-whitelist show-edit-counts; do + if [[ ! -f "${file}.txt" ]] || ! $cached; then + echo "Updating ${file}.txt" + ./${file}.rb > ${file}.txt + fi +done + +comm -13 \ + <(sort show-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/show-user-whitelist.rb b/show-user-whitelist.rb new file mode 100755 index 0000000..a9d3060 --- /dev/null +++ b/show-user-whitelist.rb @@ -0,0 +1,25 @@ +#!/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']) + +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.rb b/user-whitelist.rb deleted file mode 100755 index a9d3060..0000000 --- a/user-whitelist.rb +++ /dev/null @@ -1,25 +0,0 @@ -#!/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']) - -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 -- cgit v1.2.2