add prerun step to check user/channel

This commit is contained in:
deathbybandaid 2019-07-03 09:21:15 -04:00
parent 4b0343e5de
commit 66a03df210

View File

@ -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']: