From 9139adef706f29265f51ae017b6b96df9b80de9c Mon Sep 17 00:00:00 2001 From: BuildTools Date: Fri, 24 Dec 2021 13:38:32 -0500 Subject: [PATCH] merry kurisumasu --- .gitignore | 2 ++ disc_api.py | 29 +++++++++++++++++++++++++++++ main.py | 15 +++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 .gitignore create mode 100644 disc_api.py create mode 100644 main.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..feae5c1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.pyc +__pycache__ \ No newline at end of file diff --git a/disc_api.py b/disc_api.py new file mode 100644 index 0000000..ab26202 --- /dev/null +++ b/disc_api.py @@ -0,0 +1,29 @@ +gateway_opcodes = { # https://discord.com/developers/docs/topics/opcodes-and-status-codes#gateway-gateway-opcodes + 0: "dispatch", + 1: "heartbeat", + 2: "identify", + 3: "presence_update", + 4: "voice_state_update", + 6: "resume", + 7: "reconnect", + 8: "request_guild_members", + 9: "invalid_session", + 10: "hello", + 11: "heartbeat_ack" +} +gateway_close_event_codes = { # https://discord.com/developers/docs/topics/opcodes-and-status-codes#gateway-gateway-close-event-codes + 4000: "We're not sure what went wrong. Try reconnecting?", + 4001: "You sent an invalid Gateway opcode or an invalid payload for an opcode. Don't do that!", + 4002: "You sent an invalid payload to us. Don't do that!", + 4003: "You sent us a payload prior to identifying.", + 4004: "The account token sent with your identify payload is incorrect.", + 4005: "You sent more than one identify payload. Don't do that!", + 4007: "The sequence sent when resuming the session was invalid. Reconnect and start a new session.", + 4008: "Woah nelly! You're sending payloads to us too quickly. Slow it down! You will be disconnected on receiving this.", + 4009: "Your session timed out. Reconnect and start a new one.", + 4010: "You sent us an invalid shard when identifying.", + 4011: "The session would have handled too many guilds - you are required to shard your connection in order to connect.", + 4012: "You sent an invalid version for the gateway.", + 4013: "You sent an invalid intent for a Gateway Intent. You may have incorrectly calculated the bitwise value.", + 4014: "You sent a disallowed intent for a Gateway Intent. You may have tried to specify an intent that you have not enabled or are not approved for." +} diff --git a/main.py b/main.py new file mode 100644 index 0000000..f607c0e --- /dev/null +++ b/main.py @@ -0,0 +1,15 @@ +import websockets, asyncio, json +import disc_api +class client(): + def __init__(self): + pass + async def shit(): + # 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 + async with websockets.connect("wss://gateway.discord.gg/?encoding=json&v=9") as ws: # they seem to be fond of making new versions randomly and still supporting old ones? + while True: # they may or may not drop support for this soon + data = (await ws.recv()) + print(data) + break + def run(): + asyncio.run(shit())