From 94cda49a16bdc4554ad236436301c17cb8dfa2e3 Mon Sep 17 00:00:00 2001 From: nin0dev Date: Tue, 18 Jun 2024 01:07:04 -0400 Subject: [PATCH 1/3] Insane --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index 6ac1daa..92f1231 100644 --- a/main.py +++ b/main.py @@ -30,7 +30,7 @@ async def handle(websocket): # broadcast from vee EAS_MESSAGE = message.replace(f"MSG {TOKEN} ", "") websockets.broadcast(CONNECTIONS, f"MSG {EAS_MESSAGE}") - if message.startswith(f"CLEAR {TOKEN} "): + if message.startswith(f"CLEAR {TOKEN}"): # clear EAS_MESSAGE = "" await websocket.send(f"OK") From 9af8f7d3d64b697d4432bba847cdf97928273cde Mon Sep 17 00:00:00 2001 From: nin0dev Date: Tue, 18 Jun 2024 01:10:19 -0400 Subject: [PATCH 2/3] Added NULL response --- README.md | 5 +++-- main.py | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f750adf..e411238 100644 --- a/README.md +++ b/README.md @@ -18,11 +18,12 @@ You can send raw text to the WS server. This text is in form of commands: - `MSG {token} {message}` will set the message and broadcast it to all logged-in clients; - `CLEAR {token}` will clear the current message. -You may receive one of two packets while using the server: +You may receive one of three responses while using the server: - `MSG {message}` to indicate there's a new message. The client should react by showing an alert with the message. If no message is present, the packet will be `MSG` only. In this case, the client shouldn't react. - `OK` indicates the action was successful. The client should react by showing an alert telling the user so. +- `NULL` to indicate that no data is available. No client reaction is intended. ## Frontend -The frontend is a static HTML page and can be hosted on anything. \ No newline at end of file +The frontend is a static HTML page and can be hosted on anything. diff --git a/main.py b/main.py index e03437e..a4e044c 100644 --- a/main.py +++ b/main.py @@ -18,6 +18,9 @@ async def handle(websocket): CONNECTIONS.add(websocket) async for message in websocket: if message == "GET": + if EAS_MESSAGE == "": + await websocket.send("NULL") + return await websocket.send(f"MSG {EAS_MESSAGE}") if message.startswith(f"MSG {TOKEN} "): # broadcast from vee From 9111c63691a226065b18f362912e8e07a40beea5 Mon Sep 17 00:00:00 2001 From: nin0dev Date: Tue, 18 Jun 2024 01:10:59 -0400 Subject: [PATCH 3/3] idk what did i do --- front/index.html | 26 +++++++++++--------------- front/index.js | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 15 deletions(-) create mode 100644 front/index.js diff --git a/front/index.html b/front/index.html index 24ca5e7..154e3e6 100644 --- a/front/index.html +++ b/front/index.html @@ -3,7 +3,7 @@ - HTML 5 Boilerplate + Vencord EAS @@ -19,31 +19,27 @@

Vencord EAS Client

arrow_drop_down
- +
- +
-
-
- - -
- +
Logs
+

+ - \ No newline at end of file + diff --git a/front/index.js b/front/index.js new file mode 100644 index 0000000..10ecfa0 --- /dev/null +++ b/front/index.js @@ -0,0 +1,42 @@ +const socket = new WebSocket('wss://eas-ws.nin0.dev'); + +socket.onopen = function(event) { + log("Connection opened") +}; + +socket.onmessage = function(event) { + log("IN: " + event.data) + if(event.data.startsWith("MSG ")) { + alert(event.data.replace("MSG ", "")) + } +}; + +socket.onclose = function(event) { + alert("Connection has been closed, refresh the page."); +}; + +function sendMessage(message) { + socket.send(message); + log("OUT: " + message) +} + +function log(message) { + const logArea = document.getElementById("log"); + const newVal = message + "
" + logArea.innerHTML; + logArea.innerHTML = newVal; +} + +function processSend() { + const endpoint = document.getElementById("endpoint").value + if(endpoint == "get") { + sendMessage("GET") + } + const token = document.getElementById("token").value + const msg = document.getElementById("msg").value + if(endpoint == "msg") { + sendMessage(`MSG ${token} ${msg}`) + } + if(endpoint == "clear") { + sendMessage(`CLEAR ${token}`) + } +}