From 4ae2f5b4cecf00fd2362ba1849eee09c25a6a569 Mon Sep 17 00:00:00 2001 From: Swee Date: Sat, 9 Nov 2024 23:58:06 -0800 Subject: [PATCH] Update sweebot.py --- sweebot.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/sweebot.py b/sweebot.py index 1c4c795..d0ca5b3 100644 --- a/sweebot.py +++ b/sweebot.py @@ -168,7 +168,7 @@ irc = bot_irc() irc2 = bot_irc() irc3 = bot_irc() irc.connect_irc( - server_irc, port_irc, channel_irc, botnick_irc, botpass_irc, botnickpass_irc + server_irc, port_irc, channel_irc, botnick_irc, botpass_irc, botnickpass_irc + "/A" ) sbconfig = config() threes = [":3", ":3c", "uwu", "owo", "/ᐠ。ꞈ。ᐟ\\", "(✿◠‿◠)"] @@ -184,13 +184,13 @@ def update(): update() def irci2(): irc2.connect_irc( - server_irc, port_irc, channel_irc, "sweeB0t", botpass_irc, botnickpass_irc + "/secondary" + server_irc, port_irc, channel_irc, "sweeB0t", botpass_irc, botnickpass_irc + "/B" ) while True: irc2.ping() def irci3(): irc3.connect_irc( - server_irc, port_irc, channel_irc, "swe3Bot", botpass_irc, botnickpass_irc + "/tertiary" + server_irc, port_irc, channel_irc, "swe3Bot", botpass_irc, botnickpass_irc + "/C" ) while True: irc3.ping() @@ -217,6 +217,13 @@ def multiline(text, channel): sleep(1) irc.send_irc(channel, replace_color_codes(t)) times += 1 +from sys import argv, exit +def restart(): + irc.irc_socket.close() + irc2.irc_socket.close() + irc3.irc_socket.close() + ossystem("python " + " ".join(argv)) + exit(0) def system(cmd, chan): try: p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) @@ -317,7 +324,7 @@ while True: if perms == "full" or "reboot" in perms.split(",") or "restart" in perms.split(","): irc.send_irc(channel, nick + ": Restarting bot...") sleep(1) - ossystem("sudo systemctl restart sweebot") + restart() else: irc.send_irc(channel, nick + ": Permission denied.") block+=1