Implement Console messaging, fix mainloop initialization. Both done by Hashtags

This commit is contained in:
2025-11-02 01:09:03 +00:00
parent ab49cbf1bb
commit 3fc74df56e
7 changed files with 23 additions and 7 deletions

0
README.md Normal file → Executable file
View File

0
config/xss-config.py Normal file → Executable file
View File

24
main.py Normal file → Executable file
View File

@@ -1,6 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import asyncio import asyncio
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
import websockets import websockets
import json import json
from better_profanity import profanity from better_profanity import profanity
@@ -132,10 +133,25 @@ async def broadcast(message):
else: else:
await sendwithappropriate(client, clientdata, profanity.censor(message)) 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 # Start the WebSocket server
print("Serving...") print("Serving...")
start_server = websockets.serve(handle_client, "0.0.0.0", 8765) start_server = websockets.serve(handle_client, "0.0.0.0", 8765)
print("Adding to loop...") 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()

6
main.sh Normal file → Executable file
View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash
cd /scripts/chatserv cd /minespace/old-webchat-server
/scripts/chatserv_venv/bin/pip3 install -r requirements.txt /minespace/old-webchat-server/venv/bin/pip3 install -r requirements.txt
/scripts/chatserv_venv/bin/python3 main.py /minespace/old-webchat-server/venv/bin/python3 main.py

0
requirements.txt Normal file → Executable file
View File

0
wordlist/profanity_wordlist.txt Normal file → Executable file
View File

0
wordlist/readme.md Normal file → Executable file
View File