Merge branch 'master' of https://git.nin0.dev/nin0/VencordEAS
This commit is contained in:
commit
1f28c7cbba
3 changed files with 28 additions and 7 deletions
28
README.md
Normal file
28
README.md
Normal file
|
@ -0,0 +1,28 @@
|
|||
# Vencord EAS
|
||||
|
||||
This is the repo for both the frontend and backend for the Vencord Emergency Alert System.
|
||||
|
||||
## Installation
|
||||
|
||||
You run the server by:
|
||||
1. Installing the `websockets` and `python-dotenv` packages;
|
||||
1. Making a `.env` file;
|
||||
1. Adding a line with `TOKEN={token}`, with `{token}` being any string that'll be used to broadcast messages;
|
||||
1. Running `python main.py`.
|
||||
|
||||
## Usage
|
||||
|
||||
You can send raw text to the WS server. This text is in form of commands:
|
||||
|
||||
- `GET` will reply with a message response;
|
||||
- `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:
|
||||
|
||||
- `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.
|
||||
|
||||
## Frontend
|
||||
|
||||
The frontend is a static HTML page and can be hosted on anything.
|
0
bot.py
0
bot.py
7
main.py
7
main.py
|
@ -17,13 +17,6 @@ async def handle(websocket):
|
|||
if websocket not in CONNECTIONS:
|
||||
CONNECTIONS.add(websocket)
|
||||
async for message in websocket:
|
||||
# parse message
|
||||
if message == "HI":
|
||||
# new client said hi
|
||||
if message == "":
|
||||
await websocket.send("HI")
|
||||
else:
|
||||
await websocket.send(f"HI {EAS_MESSAGE}")
|
||||
if message == "GET":
|
||||
await websocket.send(f"MSG {EAS_MESSAGE}")
|
||||
if message.startswith(f"MSG {TOKEN} "):
|
||||
|
|
Reference in a new issue