#!/usr/bin/env python3.2 # Marius Hoch; 2012-09-16 # Blocks users out of a list (torlist.txt), start with -dry for testing import wiki import sys config = { 'user' : 'You', 'pass' : 'Super secret', 'wiki' : 'itwiki', 'block_options' : {'expiry' : '1 second', 'reason' : 'testing', 'nocreate' : 'True'} } if len(sys.argv) > 1 and sys.argv[1] == '-dry': dry = True else: wmf_wikis = wiki.wmf(config['user'], config['pass'], login_wiki=config['wiki']) # Gather the block token only once over here, for performance reasons config['block_options'].update({'token' : wmf_wikis.get_token('block', 'User:' + config['user'], config['wiki'])}) dry = False f = open('torlist.txt', 'r') for line in f.readlines(): user = line.strip() if len(user) < 2: continue print('Bloqueando', user) if not dry: if wmf_wikis.block(user, config['block_options'], config['wiki']): print('Successo') else: print('Error')