From 6b55d21f9166f9d6d2fed73db2150e4b32c352c4 Mon Sep 17 00:00:00 2001 From: swee Date: Fri, 6 Dec 2024 23:07:34 -0800 Subject: [PATCH] Update sweebot.py --- sweebot.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sweebot.py b/sweebot.py index 4f4617b..ae45b85 100644 --- a/sweebot.py +++ b/sweebot.py @@ -273,12 +273,18 @@ def restart(): irc2.irc_socket.close() irc3.irc_socket.close() exit(0) -def system(cmd, chan): +def system(cmd, chan, rstrip=False): try: p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + outpp = "" for line in iter(p.stdout.readline, b''): if text != "" and text != " ": - multiline(line.rstrip(), chan) + if not rstrip + multiline(line.rstrip(), chan) + else: + outpp += line.rstrip() + " " + if rstrip: + multiline(outpp[:-1]) p.stdout.close() p.wait() except FileNotFoundError: @@ -349,7 +355,7 @@ while True: irc.send_irc(channel, "tip, ping, whoami, perms, version, figlet, tdfiglet, cowsay, uptime, cc, joke, botsnack. (restart, join, part, shell, config, pull.) Use '$help (command)' for explanation.") elif command[0] == "$tip": - system(["/usr/games/fortune", "debian-hints"], channel) + system(["/usr/games/fortune", "debian-hints"], channel, True) elif command[0] == "$whoami": if perms != "":