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