From 3fc74df56e569f20c3ea9dcf53d339b2f439c175 Mon Sep 17 00:00:00 2001 From: Ghost Fox Date: Sun, 2 Nov 2025 01:09:03 +0000 Subject: [PATCH] Implement Console messaging, fix mainloop initialization. Both done by Hashtags --- README.md | 0 config/xss-config.py | 0 main.py | 24 ++++++++++++++++++++---- main.sh | 6 +++--- requirements.txt | 0 wordlist/profanity_wordlist.txt | 0 wordlist/readme.md | 0 7 files changed, 23 insertions(+), 7 deletions(-) mode change 100644 => 100755 README.md mode change 100644 => 100755 config/xss-config.py mode change 100644 => 100755 main.py mode change 100644 => 100755 main.sh mode change 100644 => 100755 requirements.txt mode change 100644 => 100755 wordlist/profanity_wordlist.txt mode change 100644 => 100755 wordlist/readme.md diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/config/xss-config.py b/config/xss-config.py old mode 100644 new mode 100755 diff --git a/main.py b/main.py old mode 100644 new mode 100755 index 3ef6fe2..2a9b99c --- a/main.py +++ b/main.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import asyncio - +loop = asyncio.new_event_loop() +asyncio.set_event_loop(loop) import websockets import json from better_profanity import profanity @@ -132,10 +133,25 @@ async def broadcast(message): else: await sendwithappropriate(client, clientdata, profanity.censor(message)) - +# GLUE +#loop = asyncio.new_event_loop() +#asyncio.set_event_loop(loop) +import re,sys +async def ainput(string: str) -> str: + await asyncio.get_event_loop().run_in_executor( + None, lambda s=string: sys.stdout.write(s+' ')) + return await asyncio.get_event_loop().run_in_executor( + None, sys.stdin.readline) +async def glueer(): + while True: + st = await ainput("CONS>") + if st.startswith("say "): + await broadcast(re.sub("say ","CONSOLE: ",st)) # Start the WebSocket server print("Serving...") start_server = websockets.serve(handle_client, "0.0.0.0", 8765) print("Adding to loop...") -asyncio.get_event_loop().run_until_complete(start_server) -asyncio.get_event_loop().run_forever() + +loop.create_task(glueer()) +loop.run_until_complete(start_server) +loop.run_forever() diff --git a/main.sh b/main.sh old mode 100644 new mode 100755 index c5db3ac..47d1ef4 --- a/main.sh +++ b/main.sh @@ -1,4 +1,4 @@ #!/bin/bash -cd /scripts/chatserv -/scripts/chatserv_venv/bin/pip3 install -r requirements.txt -/scripts/chatserv_venv/bin/python3 main.py +cd /minespace/old-webchat-server +/minespace/old-webchat-server/venv/bin/pip3 install -r requirements.txt +/minespace/old-webchat-server/venv/bin/python3 main.py diff --git a/requirements.txt b/requirements.txt old mode 100644 new mode 100755 diff --git a/wordlist/profanity_wordlist.txt b/wordlist/profanity_wordlist.txt old mode 100644 new mode 100755 diff --git a/wordlist/readme.md b/wordlist/readme.md old mode 100644 new mode 100755