From a939d29537e8c486bbae32811341d6e9fa9385a2 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 3 May 2019 11:09:22 -0400 Subject: [PATCH] Update Messaging Logic --- sopel_modules/SpiceBot_Messaging/Messaging.py | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/sopel_modules/SpiceBot_Messaging/Messaging.py b/sopel_modules/SpiceBot_Messaging/Messaging.py index bfb3651..fd54f7c 100644 --- a/sopel_modules/SpiceBot_Messaging/Messaging.py +++ b/sopel_modules/SpiceBot_Messaging/Messaging.py @@ -28,24 +28,28 @@ def bot_command_hub(bot, trigger): triggerargs, triggercommand = sopel_triggerargs(bot, trigger, 'nickname_command') if not len(triggerargs): - bot.say("You must specify a channel.") + bot.say("You must specify a channel or nick.") return - channel = spicemanip.main(triggerargs, 1) - if not inlist(bot, channel.lower(), bot.memory['SpiceBot_Channels']['channels'].keys()) and channel != 'all': - bot.osd("Channel name {} not valid.".format(channel)) + target = spicemanip.main(triggerargs, 1) + if (target not in ['allchans', 'allnicks'] + and not inlist(bot, target.lower(), bot.memory['SpiceBot_Channels']['channels'].keys()) + and not inlist(bot, target.lower(), bot.users)): + bot.osd("Channel/nick name {} not valid.".format(target)) return triggerargs = spicemanip.main(triggerargs, '2+') - if channel == 'all': - channelsendlist = bot.channels.keys() + if target == 'allchans': + targetsendlist = bot.channels.keys() + elif target == 'allnicks': + targetsendlist = bot.users else: - channelsendlist = [channel] + targetsendlist = [target] botmessage = spicemanip.main(triggerargs, 0) if not botmessage: bot.say("You must specify a message to send.") return - bot.osd(botmessage, channelsendlist, triggercommand.upper()) + bot.osd(botmessage, targetsendlist, triggercommand.upper())