mirror of
https://github.com/nexy7574/LCC-bot.git
synced 2024-09-19 18:16:34 +01:00
Fix websocket
This commit is contained in:
parent
a8c0508eac
commit
b54c1ffc19
2 changed files with 8 additions and 1 deletions
|
@ -385,6 +385,7 @@ class Events(commands.Cog):
|
||||||
}
|
}
|
||||||
# dumped = json.dumps(payload, separators=(",", ":"))
|
# dumped = json.dumps(payload, separators=(",", ":"))
|
||||||
self.bot.bridge_queue.put_nowait(payload)
|
self.bot.bridge_queue.put_nowait(payload)
|
||||||
|
print("Added %s to queue" % payload)
|
||||||
|
|
||||||
if message.channel.name == "pinboard":
|
if message.channel.name == "pinboard":
|
||||||
if message.type == discord.MessageType.pins_add:
|
if message.type == discord.MessageType.pins_add:
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import asyncio
|
||||||
import ipaddress
|
import ipaddress
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
@ -318,7 +319,12 @@ async def bridge_recv(ws: WebSocket, secret: str = Header(None)):
|
||||||
|
|
||||||
await ws.accept()
|
await ws.accept()
|
||||||
while True:
|
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:
|
try:
|
||||||
await ws.send_json(data)
|
await ws.send_json(data)
|
||||||
except WebSocketDisconnect:
|
except WebSocketDisconnect:
|
||||||
|
|
Loading…
Reference in a new issue