Channels: Update configuration for channel JOIN ignoring

This commit is contained in:
deathbybandaid 2019-05-02 10:17:44 -04:00
parent 1c9c6908fb
commit e70b1f5c20

View File

@ -5,7 +5,7 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi
# sopel imports # sopel imports
import sopel.module import sopel.module
from sopel.tools import stderr from sopel.tools import stderr
from sopel.config.types import StaticSection, ValidatedAttribute from sopel.config.types import StaticSection, ValidatedAttribute, ListAttribute
from sopel.module import OP, ADMIN, VOICE, OWNER, HALFOP from sopel.module import OP, ADMIN, VOICE, OWNER, HALFOP
HOP = HALFOP HOP = HALFOP
@ -23,6 +23,7 @@ class SpiceBot_Channels_MainSection(StaticSection):
announcenew = ValidatedAttribute('announcenew', default=False) announcenew = ValidatedAttribute('announcenew', default=False)
joinall = ValidatedAttribute('joinall', default=False) joinall = ValidatedAttribute('joinall', default=False)
operadmin = ValidatedAttribute('operadmin', default=False) operadmin = ValidatedAttribute('operadmin', default=False)
chanignore = ListAttribute('chanignore')
def configure(config): def configure(config):
@ -30,6 +31,7 @@ def configure(config):
config.SpiceBot_Channels.configure_setting('announcenew', 'SpiceBot_Channels Announce New Channels') config.SpiceBot_Channels.configure_setting('announcenew', 'SpiceBot_Channels Announce New Channels')
config.SpiceBot_Channels.configure_setting('announcenew', 'SpiceBot_Channels JOIN New Channels') config.SpiceBot_Channels.configure_setting('announcenew', 'SpiceBot_Channels JOIN New Channels')
config.SpiceBot_Channels.configure_setting('announcenew', 'SpiceBot_Channels OPER ADMIN MODE') config.SpiceBot_Channels.configure_setting('announcenew', 'SpiceBot_Channels OPER ADMIN MODE')
config.SpiceBot_Channels.configure_setting('chanignore', 'SpiceBot_Channels Ignore JOIN for channels')
def setup(bot): def setup(bot):
@ -71,17 +73,20 @@ def trigger_channel_list_initial(bot, trigger):
# JOIN # JOIN
if bot.config.SpiceBot_Channels.joinall: if bot.config.SpiceBot_Channels.joinall:
for channel in bot.memory['SpiceBot_Channels']['channels'].keys(): for channel in bot.memory['SpiceBot_Channels']['channels'].keys():
if channel not in bot.channels.keys(): if channel not in bot.channels.keys() and channel not in bot.config.SpiceBot_Channels.chanignore:
bot.write(('JOIN', bot.nick, bot.memory['SpiceBot_Channels']['channels'][channel]['name'])) bot.write(('JOIN', bot.nick, bot.memory['SpiceBot_Channels']['channels'][channel]['name']))
if channel not in bot.channels.keys(): if channel not in bot.channels.keys():
bot.write(('SAJOIN', bot.nick, bot.memory['SpiceBot_Channels']['channels'][channel]['name'])) bot.write(('SAJOIN', bot.nick, bot.memory['SpiceBot_Channels']['channels'][channel]['name']))
# Chan ADMIN +a # Chan ADMIN +a
for channel in bot.channels.keys(): for channel in bot.channels.keys():
if channel not in bot.config.SpiceBot_Channels.chanignore:
if bot.config.SpiceBot_Channels.operadmin: if bot.config.SpiceBot_Channels.operadmin:
if not bot.channels[channel].privileges[bot.nick] < ADMIN: if not bot.channels[channel].privileges[bot.nick] < ADMIN:
bot.write(('SAMODE', channel, "+a", bot.nick)) bot.write(('SAMODE', channel, "+a", bot.nick))
channel_privs(bot, channel) channel_privs(bot, channel)
else:
bot.part(channel)
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']["*"]
@ -104,17 +109,20 @@ def trigger_channel_list_initial(bot, trigger):
# JOIN # JOIN
if bot.config.SpiceBot_Channels.joinall: if bot.config.SpiceBot_Channels.joinall:
for channel in bot.memory['SpiceBot_Channels']['channels'].keys(): for channel in bot.memory['SpiceBot_Channels']['channels'].keys():
if channel not in bot.channels.keys(): if channel not in bot.channels.keys() and channel not in bot.config.SpiceBot_Channels.chanignore:
bot.write(('JOIN', bot.nick, bot.memory['SpiceBot_Channels']['channels'][channel]['name'])) bot.write(('JOIN', bot.nick, bot.memory['SpiceBot_Channels']['channels'][channel]['name']))
if channel not in bot.channels.keys(): if channel not in bot.channels.keys():
bot.write(('SAJOIN', bot.nick, bot.memory['SpiceBot_Channels']['channels'][channel]['name'])) bot.write(('SAJOIN', bot.nick, bot.memory['SpiceBot_Channels']['channels'][channel]['name']))
# Chan ADMIN +a # Chan ADMIN +a
for channel in bot.channels.keys(): for channel in bot.channels.keys():
if channel not in bot.config.SpiceBot_Channels.chanignore:
if bot.config.SpiceBot_Channels.operadmin: if bot.config.SpiceBot_Channels.operadmin:
if not bot.channels[channel].privileges[bot.nick] < ADMIN: if not bot.channels[channel].privileges[bot.nick] < ADMIN:
bot.write(('SAMODE', channel, "+a", bot.nick)) bot.write(('SAMODE', channel, "+a", bot.nick))
channel_privs(bot, channel) channel_privs(bot, channel)
else:
bot.part(channel)
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']["*"]