mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-10 21:50:59 -05:00
channel parting
This commit is contained in:
parent
4e11cc4e98
commit
b3857cd96e
@ -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):
|
||||
|
||||
@ -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':
|
||||
|
||||
Loading…
Reference in New Issue
Block a user