channel parting

This commit is contained in:
deathbybandaid 2019-05-09 13:05:00 -04:00
parent 4e11cc4e98
commit b3857cd96e
2 changed files with 16 additions and 16 deletions

View File

@ -53,16 +53,10 @@ 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_part_empty(bot)
bot.write(['LIST'])
bot.memory['SpiceBot_Channels']['ProcessLock'] = True
@ -89,16 +83,12 @@ 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")
bot_part_empty(bot)
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")
bot_part_empty(bot)
oldlist = list(bot.memory['SpiceBot_Channels']['channels'].keys())
bot.write(['LIST'])
bot.memory['SpiceBot_Channels']['ProcessLock'] = True
@ -118,13 +108,20 @@ 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")
bot_part_empty(bot)
except KeyError:
return
def bot_part_empty(bot):
ignorepartlist = []
if bot.config.SpiceBot_Logs.logging_channel:
ignorepartlist.append(bot.config.SpiceBot_Logs.logging_channel)
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")
@sopel.module.event('2001')
@sopel.module.rule('.*')
def bot_events_setup(bot, trigger):

View File

@ -11,6 +11,7 @@ from sopel_modules.SpiceBot_SBTools import (
sopel_triggerargs, inlist, channel_privs,
join_all_channels, channel_list_current,
)
from .Channels import bot_part_empty
@sopel.module.nickname_commands('channels', 'channel')
@ -56,6 +57,7 @@ def nickname_comand_channels(bot, trigger):
if not trigger.admin:
bot.osd("You do not have permission to update the channel listing.")
return
bot_part_empty(bot)
bot.write(['LIST'])
bot.osd(["[SpiceBot_Channels]", "I am now updating the channel listing for this server."])
bot.memory['SpiceBot_Channels']['ProcessLock'] = True
@ -64,6 +66,7 @@ def nickname_comand_channels(bot, trigger):
join_all_channels(bot)
foundchannelcount = len(bot.memory['SpiceBot_Channels']['channels'].keys())
bot.osd("[SpiceBot_Channels]", "Channel listing finished!", str(foundchannelcount) + " channel(s) found.")
bot_part_empty(bot)
return
elif commandused == 'topic':