diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 29f96a4..73f6704 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -28,6 +28,10 @@ def prerun(t_command_type='module', t_command_subtype=None): @functools.wraps(function) def internal_prerun(bot, trigger, *args, **kwargs): + # Verify channel and user exist + verify_channel(trigger) + verify_user(trigger) + botcom = class_create('botcom') if t_command_type == "nickname": @@ -167,6 +171,29 @@ def prerun_query(t_command_type='module', t_command_subtype=None): return actual_decorator +def verify_user(trigger): + # Identify + nick_id = botusers.whois_ident(trigger.nick) + # Verify nick is in the all list + botusers.add_to_all(trigger.nick, nick_id) + # Verify nick is in the all list + botusers.add_to_current(trigger.nick, nick_id) + # set current nick + botusers.mark_current_nick(trigger.nick, nick_id) + # add joined channel to nick list + botusers.add_channel(trigger.sender, nick_id) + # mark user as online + botusers.mark_user_online(nick_id) + + +def verify_channel(trigger): + botchannels.add_channel(trigger.sender) + # Identify + nick_id = botchannels.whois_ident(trigger.nick) + # Verify nick is in the channel list + botchannels.add_to_channel(trigger.sender, trigger.nick, nick_id) + + def make_trigger_args(triggerargs_one, trigger_command_type='module'): trigger_args = spicemanip.main(triggerargs_one, 'create') if trigger_command_type in ['nickname']: