Fix websocket

This commit is contained in:
Nexus 2023-06-29 12:59:15 +01:00
parent a8c0508eac
commit b54c1ffc19
Signed by: nex
GPG key ID: 0FA334385D0B689F
2 changed files with 8 additions and 1 deletions

View file

@ -385,6 +385,7 @@ class Events(commands.Cog):
}
# dumped = json.dumps(payload, separators=(",", ":"))
self.bot.bridge_queue.put_nowait(payload)
print("Added %s to queue" % payload)
if message.channel.name == "pinboard":
if message.type == discord.MessageType.pins_add:

View file

@ -1,3 +1,4 @@
import asyncio
import ipaddress
import sys
@ -318,7 +319,12 @@ async def bridge_recv(ws: WebSocket, secret: str = Header(None)):
await ws.accept()
while True:
data = await app.state.bot.bridge_queue.get()
try:
data = app.state.bot.bridge_queue.get_nowait()
except asyncio.QueueEmpty:
await asyncio.sleep(0.5)
continue
try:
await ws.send_json(data)
except WebSocketDisconnect: