From d01985eea6ce0a3d8ddf9a6ed637de54777bde1e Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Mon, 4 Mar 2024 23:12:32 -0500 Subject: [PATCH] fix(pterodactyl): removed a bunch of useless/redundant logging statements --- pterodactyl/websocket.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/pterodactyl/websocket.py b/pterodactyl/websocket.py index decc2c7..926d47e 100644 --- a/pterodactyl/websocket.py +++ b/pterodactyl/websocket.py @@ -167,38 +167,31 @@ async def check_if_server_message(text: str) -> Union[bool, str]: return False async def check_if_chat_message(text: str) -> Union[bool, dict]: - logger.debug("Checking if message is a chat message") regex = await config.chat_regex() match: Optional[re.Match[str]] = re.match(regex, text) if match: groups = {"username": match.group(1), "message": match.group(2)} logger.debug("Message is a chat message\n%s", json.dumps(groups)) return groups - logger.debug("Message is not a chat message") return False async def check_if_join_message(text: str) -> Union[bool, str]: - logger.debug("Checking if message is a join message") regex = await config.join_regex() match: Optional[re.Match[str]] = re.match(regex, text) if match: logger.debug("Message is a join message") return match.group(1) - logger.debug("Message is not a join message") return False async def check_if_leave_message(text: str) -> Union[bool, str]: - logger.debug("Checking if message is a leave message") regex = await config.leave_regex() match: Optional[re.Match[str]] = re.match(regex, text) if match: logger.debug("Message is a leave message") return match.group(1) - logger.debug("Message is not a leave message") return False async def check_if_achievement_message(text: str) -> Union[bool, dict]: - logger.debug("Checking if message is an achievement message") regex = await config.achievement_regex() match: Optional[re.Match[str]] = re.match(regex, text) if match: @@ -207,9 +200,8 @@ async def check_if_achievement_message(text: str) -> Union[bool, dict]: groups["challenge"] = True else: groups["challenge"] = False - logger.debug("Message is an achievement message\n%s", json.dumps(groups)) + logger.debug("Message is an achievement message") return groups - logger.debug("Message is not an achievement message") return False async def get_info(username: str) -> Optional[dict]: @@ -218,7 +210,7 @@ async def get_info(username: str) -> Optional[dict]: async with aiohttp.ClientSession() as session: async with session.get(f"https://playerdb.co/api/player/{endpoint}/{username}") as response: if response.status == 200: - logger.debug("Player info retrieved for %s\n%s", username, json.dumps(await response.json())) + logger.debug("Player info retrieved for %s", username) return await response.json() logger.error("Failed to retrieve player info for %s: %s", username, response.status) return None @@ -234,7 +226,7 @@ async def send_chat_discord(coginstance: Pterodactyl, username: str, message: st await webhook.send(content=message, username=username, avatar_url=avatar_url, allowed_mentions=discord.AllowedMentions(everyone=False, roles=False, users=True)) logger.debug("Chat message sent to Discord") else: - logger.debug("Chat channel not set. Skipping sending chat message to Discord") + logger.warn("Chat channel not set. Skipping sending chat message to Discord") async def generate_join_leave_embed(username: str, join: bool) -> discord.Embed: embed = discord.Embed() @@ -261,7 +253,7 @@ async def generate_achievement_embed(username: str, achievement: str, challenge: return embed def mask_ip(string: str) -> str: - def check(match): + def check(match: re.Match[str]): ip = match.group(0) masked_ip = '.'.join(r'\*' * len(octet) for octet in ip.split('.')) return masked_ip