-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmembers.py
42 lines (34 loc) · 990 Bytes
/
members.py
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
import requests
import json
import datetime
from os import sys
from configparser import ConfigParser
import re
id_team = ''
if len(re.findall("s.py$", sys.argv[-1])) == 0:
id_team = sys.argv[-1]
else:
parser = ConfigParser()
parser.read("parameter.ini")
configObject = parser["TEAM-CONFIG"]
id_team = configObject["TeamID"]
if len(id_team) == 0:
id_team = input("Team:")
url = "https://lichess.org/api/team/" + id_team + "/users"
param = dict()
resp = requests.get(url=url,params=param)
list_resp = resp.text.splitlines()
data = list(map(lambda x: json.loads(x), list_resp))
fault_users = []
for i in data:
is_faulti = i.get("tosViolation")
if is_faulti:
user = i.get("username")
fault_users.append(user)
now = datetime.datetime.today()
date = now.strftime('%d.%m.%Y')
datei = open('blacklist.txt','a')
datei.write("\n\nIn the Team " + id_team + ", found at: " + date)
for i in fault_users:
print(i)
datei.write("\n" + i)