From df915da6d433942ad1d03d1588cca5557ac9ab29 Mon Sep 17 00:00:00 2001 From: Jordyn Date: Sat, 14 Mar 2026 21:41:34 -0500 Subject: [PATCH] Added command for clearning the send queue and cleaned up code Mainly I moved the command specific code from the giant message handling if statement into separate functions which are called dynamically depending on name. I moved some functions around to have a basic structure as commented in Server(). --- main.py | 161 ++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 110 insertions(+), 51 deletions(-) diff --git a/main.py b/main.py index c515882..4a93313 100755 --- a/main.py +++ b/main.py @@ -11,6 +11,12 @@ import queue import config class Server(): + # Order of functions in Server(): + # - Public API (non underscored functions and __init__) + # - Thread targets + # - Internal helper functions (message parsing, message handling, etc) + # - Bot commands (pid, die, etc) + # Setup the IRC related things such as user details and prefixes # This function also sets up the threading events and queues def __init__(self, realname, nickname, channels, command_prefix = "$!", bot_prefix = "$$", opper_nicknames = []): @@ -170,6 +176,50 @@ class Server(): if self._going_down.is_set(): print("[RECVTHREAD] Quitting due to thread condition!") + # This is where we actually run the RCE commands and pipe the output + # back to IRC. + # + # No temp files here + def _handle_command(self, cmd, target_channel): + print(f"[CMDTHREAD] Running CMD {cmd}!") + proc = subprocess.Popen(cmd, shell = True, stdout = subprocess.PIPE, stderr = subprocess.STDOUT, stdin = subprocess.DEVNULL, + start_new_session=True, text=False) + + # Calculate maximum message size + # 512 bytes is max IRC message with