mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-13 15:09:54 -05:00
don't stay in empty channels
This commit is contained in:
parent
4311d69520
commit
c6fb848998
@ -65,8 +65,6 @@ def trigger_channel_list_initial(bot, trigger):
|
|||||||
# Unkickable
|
# Unkickable
|
||||||
bot.write(('SAMODE', bot.nick, '+q'))
|
bot.write(('SAMODE', bot.nick, '+q'))
|
||||||
|
|
||||||
bot_part_empty(bot)
|
|
||||||
|
|
||||||
bot.write(['LIST'])
|
bot.write(['LIST'])
|
||||||
bot.memory['SpiceBot_Channels']['ProcessLock'] = True
|
bot.memory['SpiceBot_Channels']['ProcessLock'] = True
|
||||||
|
|
||||||
@ -84,7 +82,6 @@ def trigger_channel_list_initial(bot, trigger):
|
|||||||
channel_list_current(bot)
|
channel_list_current(bot)
|
||||||
foundchannelcount = len(bot.memory['SpiceBot_Channels']['channels'].keys())
|
foundchannelcount = len(bot.memory['SpiceBot_Channels']['channels'].keys())
|
||||||
bot_logging(bot, 'SpiceBot_Channels', "Channel listing finished! " + str(foundchannelcount) + " channel(s) found.")
|
bot_logging(bot, 'SpiceBot_Channels', "Channel listing finished! " + str(foundchannelcount) + " channel(s) found.")
|
||||||
botevents.trigger(bot, botevents.BOT_CHANNELS, "SpiceBot_Channels")
|
|
||||||
|
|
||||||
join_all_channels(bot)
|
join_all_channels(bot)
|
||||||
chanadmin_all_channels(bot)
|
chanadmin_all_channels(bot)
|
||||||
@ -92,12 +89,16 @@ def trigger_channel_list_initial(bot, trigger):
|
|||||||
if "*" in bot.memory['SpiceBot_Channels']['channels']:
|
if "*" in bot.memory['SpiceBot_Channels']['channels']:
|
||||||
del bot.memory['SpiceBot_Channels']['channels']["*"]
|
del bot.memory['SpiceBot_Channels']['channels']["*"]
|
||||||
|
|
||||||
bot_part_empty(bot)
|
botevents.trigger(bot, botevents.BOT_CHANNELS, "SpiceBot_Channels")
|
||||||
|
|
||||||
|
|
||||||
|
@sopel.module.event(botevents.BOT_CHANNELS)
|
||||||
|
@sopel.module.rule('.*')
|
||||||
|
def trigger_channel_list_recurring(bot, trigger):
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
time.sleep(1800)
|
time.sleep(1800)
|
||||||
bot_part_empty(bot)
|
|
||||||
oldlist = list(bot.memory['SpiceBot_Channels']['channels'].keys())
|
oldlist = list(bot.memory['SpiceBot_Channels']['channels'].keys())
|
||||||
bot.write(['LIST'])
|
bot.write(['LIST'])
|
||||||
bot.memory['SpiceBot_Channels']['ProcessLock'] = True
|
bot.memory['SpiceBot_Channels']['ProcessLock'] = True
|
||||||
@ -117,15 +118,19 @@ def trigger_channel_list_initial(bot, trigger):
|
|||||||
|
|
||||||
if "*" in bot.memory['SpiceBot_Channels']['channels']:
|
if "*" in bot.memory['SpiceBot_Channels']['channels']:
|
||||||
del bot.memory['SpiceBot_Channels']['channels']["*"]
|
del bot.memory['SpiceBot_Channels']['channels']["*"]
|
||||||
bot_part_empty(bot)
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def bot_part_empty(bot):
|
@sopel.module.event(botevents.BOT_CHANNELS)
|
||||||
|
@sopel.module.rule('.*')
|
||||||
|
def bot_part_empty(bot, trigger):
|
||||||
|
"""Don't stay in empty channels"""
|
||||||
ignorepartlist = []
|
ignorepartlist = []
|
||||||
if bot.config.SpiceBot_Logs.logging_channel:
|
if bot.config.SpiceBot_Logs.logging_channel:
|
||||||
ignorepartlist.append(bot.config.SpiceBot_Logs.logging_channel)
|
ignorepartlist.append(bot.config.SpiceBot_Logs.logging_channel)
|
||||||
|
while True:
|
||||||
for channel in bot.channels.keys():
|
for channel in bot.channels.keys():
|
||||||
if len(bot.channels[channel].privileges.keys()) == 1 and channel not in ignorepartlist:
|
if len(bot.channels[channel].privileges.keys()) == 1 and channel not in ignorepartlist:
|
||||||
bot.part(channel, "Leaving Empty Channel")
|
bot.part(channel, "Leaving Empty Channel")
|
||||||
|
|||||||
@ -11,7 +11,6 @@ from sopel_modules.SpiceBot_SBTools import (
|
|||||||
sopel_triggerargs, inlist, channel_privs,
|
sopel_triggerargs, inlist, channel_privs,
|
||||||
join_all_channels, channel_list_current,
|
join_all_channels, channel_list_current,
|
||||||
)
|
)
|
||||||
from .Channels import bot_part_empty
|
|
||||||
|
|
||||||
|
|
||||||
@botevents.check_ready([botevents.BOT_LOADED])
|
@botevents.check_ready([botevents.BOT_LOADED])
|
||||||
@ -55,7 +54,7 @@ def nickname_comand_channels(bot, trigger):
|
|||||||
if not trigger.admin:
|
if not trigger.admin:
|
||||||
bot.osd("You do not have permission to update the channel listing.")
|
bot.osd("You do not have permission to update the channel listing.")
|
||||||
return
|
return
|
||||||
bot_part_empty(bot)
|
|
||||||
bot.write(['LIST'])
|
bot.write(['LIST'])
|
||||||
bot.osd(["[SpiceBot_Channels]", "I am now updating the channel listing for this server."])
|
bot.osd(["[SpiceBot_Channels]", "I am now updating the channel listing for this server."])
|
||||||
bot.memory['SpiceBot_Channels']['ProcessLock'] = True
|
bot.memory['SpiceBot_Channels']['ProcessLock'] = True
|
||||||
@ -64,7 +63,7 @@ def nickname_comand_channels(bot, trigger):
|
|||||||
join_all_channels(bot)
|
join_all_channels(bot)
|
||||||
foundchannelcount = len(bot.memory['SpiceBot_Channels']['channels'].keys())
|
foundchannelcount = len(bot.memory['SpiceBot_Channels']['channels'].keys())
|
||||||
bot.osd("[SpiceBot_Channels]", "Channel listing finished!", str(foundchannelcount) + " channel(s) found.")
|
bot.osd("[SpiceBot_Channels]", "Channel listing finished!", str(foundchannelcount) + " channel(s) found.")
|
||||||
bot_part_empty(bot)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
elif commandused == 'topic':
|
elif commandused == 'topic':
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user