|
1 | | -import pywikibot |
2 | | -import re |
| 1 | +from RemoveBase import RemoveBlocked |
3 | 2 |
|
4 | 3 | if __name__ == "__main__": |
5 | | - site = pywikibot.Site(fam="wikipedia", code="en", user="TheSandBot") |
6 | | - pattern = r'(?:User talk:)([^/\n]+)' |
7 | | - count = 0 |
8 | | - for page in pywikibot.Category(site, "Wikipedia usernames with possible policy issues").articles(): |
9 | | - if page.title() == "Template:Uw-corpname": |
10 | | - continue |
11 | | - m = re.search(pattern, str(page.title())) |
12 | | - user_raw = m.group(1) |
13 | | - user = pywikibot.User(site, user_raw) |
14 | | - if user.isBlocked(): |
15 | | - with open("block_removed_mar_14_2020.txt", 'a+') as f: |
16 | | - count += 1 |
17 | | - f.write(str(count) + " " + str(page.title()) + "\n") |
18 | | - page.text = page.text.replace("[[Category:Wikipedia usernames with possible policy issues|{{PAGENAME}}]]", |
19 | | - "") |
20 | | - page.save( |
21 | | - summary="Removing [[:Category:Wikipedia usernames with possible policy issues]] as user is blocked." + |
22 | | - " ([[Wikipedia:Bots/Requests for approval/TheSandBot 6|BRFA]])", minor=True, |
23 | | - botflag=True, force=True) |
24 | | - print("Saved " + str(page.title())) |
| 4 | + rmBlocked = RemoveBlocked(log_name="block_removed_apr_3_2020.txt", |
| 5 | + category="Wikipedia usernames with possible policy issues", |
| 6 | + target="[[Category:Wikipedia usernames with possible policy issues|{{PAGENAME}}]]", |
| 7 | + brfa="TheSandBot 6") |
| 8 | + try: |
| 9 | + rmBlocked.run() |
| 10 | + except KeyboardInterrupt: |
| 11 | + print("\n") |
0 commit comments