From 4e11cc4e98aa0c92c2f87c93ff9a6ee2501eab20 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Thu, 9 May 2019 13:00:10 -0400 Subject: [PATCH] channel parting --- sopel_modules/SpiceBot_Channels/Channels.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sopel_modules/SpiceBot_Channels/Channels.py b/sopel_modules/SpiceBot_Channels/Channels.py index 8263bfb..7e972d5 100644 --- a/sopel_modules/SpiceBot_Channels/Channels.py +++ b/sopel_modules/SpiceBot_Channels/Channels.py @@ -53,9 +53,17 @@ def shutdown(bot): def trigger_channel_list_initial(bot, trigger): bot_events_recieved(bot, trigger.event) + ignorepartlist = [] + if bot.config.SpiceBot_Logs.logging_channel: + ignorepartlist.append(bot.config.SpiceBot_Logs.logging_channel) + # Unkickable bot.write(('SAMODE', bot.nick, '+q')) + for channel in bot.channels.keys(): + if len(bot.channels[channel].privileges.keys()) == 1 and channel not in ignorepartlist: + bot.part(channel, "Leaving Empty Channel") + bot.write(['LIST']) bot.memory['SpiceBot_Channels']['ProcessLock'] = True @@ -81,9 +89,16 @@ def trigger_channel_list_initial(bot, trigger): if "*" in bot.memory['SpiceBot_Channels']['channels']: del bot.memory['SpiceBot_Channels']['channels']["*"] + for channel in bot.channels.keys(): + if len(bot.channels[channel].privileges.keys()) == 1 and channel not in ignorepartlist: + bot.part(channel, "Leaving Empty Channel") + while True: try: time.sleep(1800) + for channel in bot.channels.keys(): + if len(bot.channels[channel].privileges.keys()) == 1 and channel not in ignorepartlist: + bot.part(channel, "Leaving Empty Channel") oldlist = list(bot.memory['SpiceBot_Channels']['channels'].keys()) bot.write(['LIST']) bot.memory['SpiceBot_Channels']['ProcessLock'] = True @@ -103,6 +118,9 @@ def trigger_channel_list_initial(bot, trigger): if "*" in bot.memory['SpiceBot_Channels']['channels']: del bot.memory['SpiceBot_Channels']['channels']["*"] + for channel in bot.channels.keys(): + if len(bot.channels[channel].privileges.keys()) == 1 and channel not in ignorepartlist: + bot.part(channel, "Leaving Empty Channel") except KeyError: return