mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-12 22:49:53 -05:00
mayhaps
This commit is contained in:
parent
79262479a9
commit
b2066c2c93
@ -23,11 +23,7 @@ class BotPrerun():
|
|||||||
def prerun(self, trigger_command_type='module'):
|
def prerun(self, trigger_command_type='module'):
|
||||||
def actual_decorator(function):
|
def actual_decorator(function):
|
||||||
@functools.wraps(function)
|
@functools.wraps(function)
|
||||||
def internal_prerun(bot, trigger, *args, **kwargs):
|
def prerun_gen(bot, trigger, *args, **kwargs):
|
||||||
|
|
||||||
# Bots can't run commands
|
|
||||||
if Identifier(trigger.nick) == bot.nick:
|
|
||||||
return
|
|
||||||
|
|
||||||
# Primary command used for trigger, and a list of all words
|
# Primary command used for trigger, and a list of all words
|
||||||
trigger_args, trigger_command = self.trigger_args(trigger.args[1], trigger_command_type)
|
trigger_args, trigger_command = self.trigger_args(trigger.args[1], trigger_command_type)
|
||||||
@ -45,22 +41,23 @@ class BotPrerun():
|
|||||||
|
|
||||||
# Create dict listings for trigger.sb
|
# Create dict listings for trigger.sb
|
||||||
argsdict_list = self.trigger_argsdict_list(argsdict_default, and_split)
|
argsdict_list = self.trigger_argsdict_list(argsdict_default, and_split)
|
||||||
|
return argsdict_list
|
||||||
|
|
||||||
# Run the function for all splits
|
argsdictlist = prerun_gen
|
||||||
for argsdict in argsdict_list:
|
# Run the function for all splits
|
||||||
|
for argsdict in argsdictlist:
|
||||||
|
|
||||||
|
@functools.wraps(function)
|
||||||
|
def internal_prerun(bot, trigger, *args, **kwargs):
|
||||||
trigger.sb = copy.deepcopy(argsdict)
|
trigger.sb = copy.deepcopy(argsdict)
|
||||||
trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb["args"])
|
trigger.sb["args"], trigger.sb["hyphen_arg"] = self.trigger_hyphen_args(trigger.sb["args"])
|
||||||
|
if not trigger.sb["hyphen_arg"]:
|
||||||
def newfunc(bot, trigger, *args, **kwargs):
|
# check if anything prohibits the nick from running the command
|
||||||
if not trigger.sb["hyphen_arg"]:
|
if self.trigger_runstatus(bot, trigger):
|
||||||
# check if anything prohibits the nick from running the command
|
function(bot, trigger, *args, **kwargs)
|
||||||
if self.trigger_runstatus(bot, trigger):
|
else:
|
||||||
function(bot, trigger, *args, **kwargs)
|
self.trigger_hyphen_arg_handler(bot, trigger)
|
||||||
else:
|
internal_prerun
|
||||||
self.trigger_hyphen_arg_handler(bot, trigger)
|
|
||||||
functools.partial(newfunc)(bot, trigger, *args, **kwargs)
|
|
||||||
|
|
||||||
return internal_prerun
|
|
||||||
return actual_decorator
|
return actual_decorator
|
||||||
|
|
||||||
def trigger_args(self, triggerargs_one, trigger_command_type='module'):
|
def trigger_args(self, triggerargs_one, trigger_command_type='module'):
|
||||||
@ -158,6 +155,10 @@ class BotPrerun():
|
|||||||
|
|
||||||
def trigger_runstatus(self, bot, trigger):
|
def trigger_runstatus(self, bot, trigger):
|
||||||
|
|
||||||
|
# Bots can't run commands
|
||||||
|
if Identifier(trigger.nick) == bot.nick:
|
||||||
|
return False
|
||||||
|
|
||||||
# don't run commands that are disabled in channels
|
# don't run commands that are disabled in channels
|
||||||
if not trigger.is_privmsg:
|
if not trigger.is_privmsg:
|
||||||
disabled_list = spicedb.get_channel_value(bot, trigger.sender, 'disabled_commands', 'commands') or {}
|
disabled_list = spicedb.get_channel_value(bot, trigger.sender, 'disabled_commands', 'commands') or {}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user