-
Notifications
You must be signed in to change notification settings - Fork 1
/
restClient.py
36 lines (25 loc) · 1.05 KB
/
restClient.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
import requests
import json
import config
class RestClient:
def __init__(self, name, passw):
self.content = []
self.login(name, passw)
def login(self, name : str, passw : str):
self.content.append({'command': 'login', 'login': name, 'passMD5': passw})
def ban(self, address : str, reason : str):
self.content.append({'command': 'ban', 'address': address, 'reason': reason})
def unban(self, address : str):
self.content.append({'command': 'unban', 'address': address})
def banlist(self):
self.content.append({'command': 'banlist'})
def savebans(self):
self.content.append({'command': 'savebans'})
def send(self):
r = requests.post(config.serverAddr, cert=config.cert, data=json.dumps({'content': self.content}), verify=config.rootCA)
print(json.dumps({'content': self.content}))
return {'code': r.status_code, 'response': r.text}
if __name__ == "__main__":
rest = RestClient(*config.accounts['178539252563443712'])
rest.banlist()
print(rest.send())