User:Paddy3118/Bye spam
- Not a task!
Downloads RC Recent changes; finds all the new User/User talk pages; displays them one at a time in a browser then gives you the option of deleting them.
If you choose to delete then creates/appends to an iMacro script that when run deletes their User page and blocks their account.
Python
Extensive testing starts now, and it is really a first draft with embedded stuff that will only work for me.
<lang python># -*- coding: utf-8 -*- """ Created on Sat Jun 22 10:12:01 2013
@author: Paddy """
import re import webbrowser as wb
import urllib
- Read RecentChanges
opener = urllib.FancyURLopener({}) f = opener.open("http://rosettacode.org/mw/index.php?title=Special:RecentChanges&limit=100") recent = f.read()
with open(r'C:\Users\Paddy\Google Drive\Code\recent.txt', 'w') as f2:
f2.write(recent)
- Split into list of [('new page type', 'username'), ] pairs
new_usert = [line.split('"')[-2][6:].split(':')
for line in re.findall(r<abbr class=.newpage. title.*?<a href=".*?", recent) if '"/wiki/User_talk:' in line or '"/wiki/User:' in line]
if new_usert:
# for new pages: give option to delete them and block their user via created iMacro script with open(r'C:\Users\Paddy\Documents\iMacros\Macros\RC_byspam.iim', 'w') as f3: f3.write(VERSION BUILD=6011206 RECORDER=CR\n) for newu in new_usert: pagetype, username = newu # Show new page and see if it needs deletion wb.open_new_tab("http://rosettacode.org/wiki/" + ':'.join(newu)) deluser = raw_input('Scrub Page %s & User %s ? [n]/y: ' % tuple(newu)) # if deluser== 'y': print 'Set to delete Page %s User %s' % tuple(newu) f3.write(
URL GOTO=http://rosettacode.org/wiki/Special:Block/%s TAG POS=1 TYPE=SELECT FORM=ACTION:http://rosettacode.org/wiki/Special:Block/%s ATTR=ID:mw-input-wpExpiry CONTENT=%%infinite TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:http://rosettacode.org/wiki/Special:Block/%s ATTR=ID:mw-input-wpReason-other CONTENT=Twerp<SP>spamming<SP>links. TAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:http://rosettacode.org/wiki/Special:Block/%s ATTR=VALUE:Block<SP>this<SP>user\n
% tuple([username] * 4)) # Delete User Talk Page f3.write(
URL GOTO=http://rosettacode.org/mw/index.php?title=%s:%s&action=delete TAG POS=1 TYPE=A ATTR=TXT:Delete TAG POS=1 TYPE=INPUT:TEXT FORM=ID:deleteconfirm ATTR=ID:wpReason CONTENT=Spamming<SP>links<SP>to<SP>other<SP>sites. TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:deleteconfirm ATTR=ID:wpConfirmB
% tuple(newu)) print 'Macro %s created/updated' % f3.name
else:
print 'No new User pages found in last 100 edits'
</lang>