forked from cswimr/SeaCogs
fix(pterodactyl): don't call config 28 qunintillion times for no reason in the websocket message handler
This commit is contained in:
parent
4c603eea46
commit
40b846123f
1 changed files with 18 additions and 21 deletions
|
@ -52,18 +52,18 @@ async def establish_websocket_connection(coginstance: Pterodactyl) -> None:
|
|||
if await config.mask_ip() is True:
|
||||
content = mask_ip(content)
|
||||
|
||||
channel = coginstance.bot.get_channel(await config.console_channel())
|
||||
if channel is not None:
|
||||
console_channel = coginstance.bot.get_channel(await config.console_channel())
|
||||
chat_channel = coginstance.bot.get_channel(await config.chat_channel())
|
||||
if console_channel is not None:
|
||||
if content.startswith('['):
|
||||
pagified_content = pagify(content, delims=[" ", "\n"])
|
||||
for page in pagified_content:
|
||||
await channel.send(content=page, allowed_mentions=discord.AllowedMentions.none())
|
||||
await console_channel.send(content=page, allowed_mentions=discord.AllowedMentions.none())
|
||||
|
||||
server_message = await check_if_server_message(content)
|
||||
if server_message:
|
||||
channel = coginstance.bot.get_channel(await config.chat_channel())
|
||||
if channel is not None:
|
||||
await channel.send(server_message if len(server_message) < 2000 else server_message[:1997] + '...', allowed_mentions=discord.AllowedMentions.none())
|
||||
if chat_channel is not None:
|
||||
await chat_channel.send(server_message if len(server_message) < 2000 else server_message[:1997] + '...', allowed_mentions=discord.AllowedMentions.none())
|
||||
|
||||
chat_message = await check_if_chat_message(content)
|
||||
if chat_message:
|
||||
|
@ -75,30 +75,27 @@ async def establish_websocket_connection(coginstance: Pterodactyl) -> None:
|
|||
|
||||
join_message = await check_if_join_message(content)
|
||||
if join_message:
|
||||
channel = coginstance.bot.get_channel(await config.chat_channel())
|
||||
if channel is not None:
|
||||
if coginstance.bot.embed_requested(channel):
|
||||
await channel.send(embed=await generate_join_leave_embed(join_message, True))
|
||||
if chat_channel is not None:
|
||||
if coginstance.bot.embed_requested(chat_channel):
|
||||
await chat_channel.send(embed=await generate_join_leave_embed(join_message, True))
|
||||
else:
|
||||
await channel.send(f"{join_message} joined the game", allowed_mentions=discord.AllowedMentions.none())
|
||||
await chat_channel.send(f"{join_message} joined the game", allowed_mentions=discord.AllowedMentions.none())
|
||||
|
||||
leave_message = await check_if_leave_message(content)
|
||||
if leave_message:
|
||||
channel = coginstance.bot.get_channel(await config.chat_channel())
|
||||
if channel is not None:
|
||||
if coginstance.bot.embed_requested(channel):
|
||||
await channel.send(embed=await generate_join_leave_embed(leave_message, False))
|
||||
if chat_channel is not None:
|
||||
if coginstance.bot.embed_requested(chat_channel):
|
||||
await chat_channel.send(embed=await generate_join_leave_embed(leave_message, False))
|
||||
else:
|
||||
await channel.send(f"{leave_message} left the game", allowed_mentions=discord.AllowedMentions.none())
|
||||
await chat_channel.send(f"{leave_message} left the game", allowed_mentions=discord.AllowedMentions.none())
|
||||
|
||||
achievement_message = await check_if_achievement_message(content)
|
||||
if achievement_message:
|
||||
channel = coginstance.bot.get_channel(await config.chat_channel())
|
||||
if channel is not None:
|
||||
if coginstance.bot.embed_requested(channel):
|
||||
await channel.send(embed=await generate_achievement_embed(achievement_message['username'], achievement_message['achievement'], achievement_message['challenge']))
|
||||
if chat_channel is not None:
|
||||
if coginstance.bot.embed_requested(chat_channel):
|
||||
await chat_channel.send(embed=await generate_achievement_embed(achievement_message['username'], achievement_message['achievement'], achievement_message['challenge']))
|
||||
else:
|
||||
await channel.send(f"{achievement_message['username']} has {'completed the challenge' if achievement_message['challenge'] else 'made the advancement'} {achievement_message['achievement']}")
|
||||
await chat_channel.send(f"{achievement_message['username']} has {'completed the challenge' if achievement_message['challenge'] else 'made the advancement'} {achievement_message['achievement']}")
|
||||
|
||||
if message['event'] == 'status':
|
||||
old_status = await config.current_status()
|
||||
|
|
Loading…
Reference in a new issue