diff --git a/.gitignore b/.gitignore index a9a8efc..8726ab3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.pyc __pycache__ -.vscode \ No newline at end of file +.vscode +config.json \ No newline at end of file diff --git a/client.py b/client.py index f5fc131..ede78e3 100644 --- a/client.py +++ b/client.py @@ -3,13 +3,14 @@ from random import randint import disc_api from grim_logger import glog, glog_level class client(): - def __init__(self, token): + def __init__(self, config_path = "config.json"): self.logger = glog(level = glog_level.TRACE) self.ws = None self.last_sequence = None self.session_id = None - self.token = token self.user = None + with open(config_path, "r") as conf_fd: + self.config = json.loads(conf_fd.read()) async def shit(self): # https://discord.com/developers/docs/topics/gateway#connecting-to-the-gateway # you're supposed to ask an HTTP endpoint what the ws gateway is but the docs didnt tell me the domain after 1sec so HAHA NOPE @@ -33,13 +34,13 @@ class client(): asyncio.get_event_loop().create_task(self.heartbeat(interval)) await asyncio.sleep(1) # https://discord.com/developers/docs/topics/gateway#identify-example-identify - await self.ws.send(json.dumps({"op":2, "d":{"token":self.token, "intents": 513, "properties":{"$os":"linux", "browser":"mdbf", "device":"mdbf"}}})) + await self.ws.send(json.dumps({"op":2, "d":{"token":self.config["token"], "intents": 513, "properties":{"$os":"linux", "browser":"mdbf", "device":"mdbf"}}})) else: # https://discord.com/developers/docs/topics/gateway#identify-example-identify - await self.ws.send(json.dumps({"op":6, "d":{"token":self.token, "session_id":self.session_id, "seq":self.last_sequence}})) + await self.ws.send(json.dumps({"op":6, "d":{"token":self.config["token"], "session_id":self.session_id, "seq":self.last_sequence}})) async def op_invalid_session(self, res): await asyncio.sleep(randint(1, 5)) # try again - await self.ws.send(json.dumps({"op":2, "d":{"token":self.token, "intents": 513, "properties":{"$os":"linux", "browser":"mdbf", "device":"mdbf"}}})) + await self.ws.send(json.dumps({"op":2, "d":{"token":self.config["token"], "intents": 513, "properties":{"$os":"linux", "browser":"mdbf", "device":"mdbf"}}})) async def op_dispatch(self, res): if res["t"] == "READY": self.session_id = res["d"]["session_id"] diff --git a/config.json b/config.json new file mode 100644 index 0000000..97a8a12 --- /dev/null +++ b/config.json @@ -0,0 +1,3 @@ +{ + "token": "YOUR_TOKEN_HERE" +} \ No newline at end of file diff --git a/main.py b/main.py index 392fa5d..0545c39 100644 --- a/main.py +++ b/main.py @@ -1,3 +1,3 @@ from client import client -olive = client("OTIxMDg0ODA3Mjk4MDU2MjAz.YbtxEg.NxS1h63qKDeTn_4voc2Axa_QIFI") +olive = client() olive.run() \ No newline at end of file