From 56e8aee3ceff6460995cd165c91af3cc0cdf0707 Mon Sep 17 00:00:00 2001 From: Sebastian Silva Date: Sat, 17 Aug 2013 08:54:59 +0000 Subject: initial commit --- diff --git a/spamblaster.py b/spamblaster.py new file mode 100644 index 0000000..5cbd2af --- /dev/null +++ b/spamblaster.py @@ -0,0 +1,39 @@ +#!/bin/env python3 + +import mwapi + +host = "http://pe.sugarlabs.org/" # can be any mediawiki, +api_path = "wiki/api.php" # just point to its API + +pages = mwapi.MWApi( host, api_path ) +pages.login ("YOURUSER", "YOURPASS") +edittoken = pages.get_tokens()['edittoken'] + +offset = 0 + +while offset>-1: + + print ("Here is a batch of lonely pages") + result = pages.get ( action="query", + list="querypage", + qppage="Lonelypages", + qplimit=500, + qpoffset=offset) + + for page in result['query']['querypage']['results']: + print (page['value']) + + print ('delete all (y/[n])?') + response = input() + + offset = result['query-continue']['querypage']['qpoffset'] + + if response=='y': + for page in result['query']['querypage']['results']: + pages.post ( action='delete', + title=page['value'], + reason='Spamblaster', + token=edittoken) + print ("deleted " + page['title']) + + print ("\n\n") diff --git a/spammerblocker.py b/spammerblocker.py new file mode 100644 index 0000000..056c57e --- /dev/null +++ b/spammerblocker.py @@ -0,0 +1,46 @@ +#!/bin/env python3 + +import mwapi + +host = "http://pe.sugarlabs.org/" +api_path = "wiki/api.php" + +users = mwapi.MWApi( host, api_path ) +users.login ("YOURUSER", "YOURPASS") +edittoken = users.get_tokens()['edittoken'] + +offset = None + +while offset!=-1: + + print ("Here is a batch of users") + result = users.get ( action="query", + list="allusers", + aulimit=50, + auprop='editcount|registration', + aufrom=offset) + + for user in result['query']['allusers']: + print ("%s (%s edits) from %s" % + (user['name'], user['editcount'], user['registration'])) + + print ('type users to not block, separated by comma') + protected = input() + protected = protected.split(',') + + print ('following users will be spared: ', protected) + print ('block the rest (y/[n])?') + response = input() + + offset = result['query-continue']['allusers']['aufrom'] + + if response=='y': + for user in result['query']['allusers']: + if user['name'] not in protected: + users.post ( action='block', + user=user['name'], + reason='Spammer blocker', + token=edittoken) + + print ("blocked " + user['name']) + print ("\n\n") -- cgit v0.9.1