This commit is contained in:
1 parent
f87d88db09
commit
d38015562a
5 files changed
+23
-14
No files matched your search
@@ -3,7 +3,7 @@ import random
|
||||
|
||||
from loon.web.users.state import user_threads
|
||||
|
||||
PLAYER_EVENT_SUFFIXES = ("died", "joined", "left")
|
||||
PLAYER_EVENT_SUFFIXES = ("died", "joined", "left", "kicked")
|
||||
|
||||
DEATH_BY_DAMAGE = {
|
||||
"fall": (
|
||||
@@ -79,7 +79,12 @@ async def marquee_handler(client, userdata, msg):
|
||||
except json.JSONDecodeError:
|
||||
return
|
||||
|
||||
username = data["player"]["username"]
|
||||
player = data.get("player")
|
||||
if not isinstance(player, dict):
|
||||
return
|
||||
username = player.get("username")
|
||||
if not username:
|
||||
return
|
||||
|
||||
if subtopic == "died":
|
||||
killer = data.get("killer")
|
||||
@@ -96,6 +101,9 @@ async def marquee_handler(client, userdata, msg):
|
||||
message = f"{username} died"
|
||||
elif subtopic == "joined":
|
||||
message = f"{username} joined the game"
|
||||
elif subtopic == "kicked":
|
||||
reason = data.get("reason")
|
||||
message = f"{username} was kicked: {reason}" if reason else f"{username} was kicked"
|
||||
else:
|
||||
message = f"{username} left the game"
|
||||
|
||||
|
||||
@@ -66,7 +66,10 @@ class MQTTManager:
|
||||
logger.info(f"[Received] {data}.")
|
||||
|
||||
for handler in self.handlers:
|
||||
await handler(client, userdata, msg)
|
||||
try:
|
||||
await handler(client, userdata, msg)
|
||||
except Exception as e:
|
||||
logger.error(f'Got exception: {e}')
|
||||
|
||||
asyncio.run_coroutine_threadsafe(handle_message(), self.loop)
|
||||
|
||||
|
||||
@@ -20,4 +20,4 @@ kwargs: dict = {}
|
||||
if url.startswith("sqlite"):
|
||||
kwargs["connect_args"] = {"check_same_thread": False}
|
||||
|
||||
engine = create_engine(url, echo=True, **kwargs)
|
||||
engine = create_engine(url, echo=settings.database.echo, **kwargs)
|
||||
Reference in new issue
Block a user