-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinfinity_blocked_ips.py
More file actions
46 lines (35 loc) · 937 Bytes
/
infinity_blocked_ips.py
File metadata and controls
46 lines (35 loc) · 937 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/python2.7
# -*- coding: utf-8 -*-
#Autor: Antoine "0x010C" Lamielle
#Date: 3 March 2018
#License: GNU GPL v3
import sys
import time
import json
import requests
import urllib
import pywiki
def get_infinity_blocked_ips(self):
response = self.request({
"action": "query",
"format": "json",
"list": "blocks",
"bklimit": "max",
"bkshow": "ip|!temp"
})["query"]["blocks"]
return response
pywiki.Pywiki.get_infinity_blocked_ips = get_infinity_blocked_ips
# Main
def main():
pw = pywiki.Pywiki("frwiki-NeoBOT")
pw.login()
result = pw.get_infinity_blocked_ips()
if len(result) == 0:
return;
ips = []
for block in result:
ips += ["* {{ip|"+block["user"]+"}}"]
wikitext = u"{{subst:Utilisateur:NeoBot/IPs bloquées indéfiniment|nb="+str(len(ips))+"|list="+"\n".join(ips)+"}}"
pw.append(u"Wikipédia:Requête aux administrateurs", wikitext, u"bot: IPs bloquées indéfiniment")
print wikitext
main()