mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-13 06:59:53 -05:00
test functionality split
This commit is contained in:
parent
954928f528
commit
8fc5862bb5
@ -5,6 +5,7 @@ This is the SpiceBot Prerun system.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import functools
|
import functools
|
||||||
|
import copy
|
||||||
import spicemanip
|
import spicemanip
|
||||||
|
|
||||||
|
|
||||||
@ -16,35 +17,52 @@ class BotPrerun():
|
|||||||
def actual_decorator(function):
|
def actual_decorator(function):
|
||||||
@functools.wraps(function)
|
@functools.wraps(function)
|
||||||
def internal_prerun(bot, trigger, *args, **kwargs):
|
def internal_prerun(bot, trigger, *args, **kwargs):
|
||||||
prerun_split = self.trigger_args(bot, trigger, trigger_command_type)
|
|
||||||
for argsdict in prerun_split:
|
argsdict_default = {}
|
||||||
|
argsdict_default["type"] = trigger_command_type
|
||||||
|
|
||||||
|
# Primary command used for trigger, and a list of all words
|
||||||
|
trigger_args, trigger_command = self.trigger_args(trigger.args[1], trigger_command_type)
|
||||||
|
argsdict_default["com"] = trigger_command
|
||||||
|
|
||||||
|
# split into && groupings
|
||||||
|
and_split = self.and_split(trigger_args)
|
||||||
|
|
||||||
|
# Create dict listings for trigger.sb
|
||||||
|
argsdict_list = self.argsdict_create(argsdict_default, and_split)
|
||||||
|
|
||||||
|
# Run the function for all splits
|
||||||
|
for argsdict in argsdict_list:
|
||||||
trigger.sb = argsdict
|
trigger.sb = argsdict
|
||||||
function(bot, trigger, *args, **kwargs)
|
function(bot, trigger, *args, **kwargs)
|
||||||
|
|
||||||
return
|
return
|
||||||
return internal_prerun
|
return internal_prerun
|
||||||
return actual_decorator
|
return actual_decorator
|
||||||
|
|
||||||
def trigger_args(self, bot, trigger, trigger_command_type='module_command'):
|
def trigger_args(self, triggerargs_one, trigger_command_type='module_command'):
|
||||||
|
trigger_args = spicemanip.main(triggerargs_one, 'create')
|
||||||
trigger_args = spicemanip.main(trigger.args[1], 'create')
|
|
||||||
if trigger_command_type in ['nickname', 'nickname_command', 'nickname_commands']:
|
if trigger_command_type in ['nickname', 'nickname_command', 'nickname_commands']:
|
||||||
trigger_command = spicemanip.main(trigger_args, 2).lower()
|
trigger_command = spicemanip.main(trigger_args, 2).lower()
|
||||||
trigger_args = spicemanip.main(trigger_args, '3+', 'list')
|
trigger_args = spicemanip.main(trigger_args, '3+', 'list')
|
||||||
else:
|
else:
|
||||||
trigger_command = spicemanip.main(trigger_args, 1).lower()[1:]
|
trigger_command = spicemanip.main(trigger_args, 1).lower()[1:]
|
||||||
trigger_args = spicemanip.main(trigger_args, '2+', 'list')
|
trigger_args = spicemanip.main(trigger_args, '2+', 'list')
|
||||||
|
return trigger_args, trigger_command
|
||||||
|
|
||||||
# Handle && splittings
|
def and_split(self, trigger_args):
|
||||||
trigger_args_list_split = spicemanip.main(trigger_args, "split_&&")
|
trigger_args_list_split = spicemanip.main(trigger_args, "split_&&")
|
||||||
if not len(trigger_args_list_split):
|
if not len(trigger_args_list_split):
|
||||||
trigger_args_list_split.append([])
|
trigger_args_list_split.append([])
|
||||||
|
return trigger_args_list_split
|
||||||
|
|
||||||
|
def argsdict_list(self, argsdict_default, prerun_and_split):
|
||||||
prerun_split = []
|
prerun_split = []
|
||||||
for trigger_args_list in trigger_args_list_split:
|
for trigger_args_list in prerun_and_split:
|
||||||
|
argsdict = copy.deepcopy(argsdict_default)
|
||||||
trigger_args_part = spicemanip.main(trigger_args_list, 'create')
|
trigger_args_part = spicemanip.main(trigger_args_list, 'create')
|
||||||
argsdict = {"com": trigger_command, "args": trigger_args_part, "type": trigger_command_type}
|
argsdict["args"] = trigger_args_part
|
||||||
prerun_split.append(argsdict)
|
prerun_split.append(argsdict)
|
||||||
|
|
||||||
return prerun_split
|
return prerun_split
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user