test
This commit is contained in:
parent
f7473abd5e
commit
509e986221
@ -3,12 +3,7 @@ import functools
|
|||||||
from sopel_SpiceBot_Core_1 import sb
|
from sopel_SpiceBot_Core_1 import sb
|
||||||
|
|
||||||
from .comrun import ComRun
|
from .comrun import ComRun
|
||||||
# from .clean_trigger import clean_trigger
|
|
||||||
# from .validate_command import validate_command
|
|
||||||
# from .dispatch_multi import dispatch_multi
|
|
||||||
from .pipe_split import rebuild_pipes
|
from .pipe_split import rebuild_pipes
|
||||||
# from .command_args import command_args
|
|
||||||
# from .rule_match import rule_match
|
|
||||||
|
|
||||||
|
|
||||||
def prerun(rulematch=False):
|
def prerun(rulematch=False):
|
||||||
@ -46,7 +41,6 @@ def prerun(rulematch=False):
|
|||||||
trigger_command = sb.commands.get_command_from_trigger(trigger)
|
trigger_command = sb.commands.get_command_from_trigger(trigger)
|
||||||
if trigger_command != commands[0]["trigger_command"]:
|
if trigger_command != commands[0]["trigger_command"]:
|
||||||
trigger_dict = rebuild_pipes(commands)
|
trigger_dict = rebuild_pipes(commands)
|
||||||
print(trigger_dict)
|
|
||||||
sb.commands.dispatch(trigger_dict)
|
sb.commands.dispatch(trigger_dict)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@ -1,15 +0,0 @@
|
|||||||
import functools
|
|
||||||
|
|
||||||
|
|
||||||
def command_args():
|
|
||||||
"""This Detects --arguments to commands."""
|
|
||||||
|
|
||||||
def actual_decorator(function):
|
|
||||||
|
|
||||||
@functools.wraps(function)
|
|
||||||
def internal_command_args(bot, trigger, comrun, *args, **kwargs):
|
|
||||||
|
|
||||||
function(bot, trigger, comrun, *args, **kwargs)
|
|
||||||
|
|
||||||
return internal_command_args
|
|
||||||
return actual_decorator
|
|
||||||
@ -1,27 +0,0 @@
|
|||||||
import functools
|
|
||||||
|
|
||||||
from sopel_SpiceBot_Core_1 import sb
|
|
||||||
|
|
||||||
|
|
||||||
def dispatch_multi():
|
|
||||||
"""
|
|
||||||
This splits the given command by `&&` and re-dispatches it internally to the bot.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def actual_decorator(function):
|
|
||||||
|
|
||||||
@functools.wraps(function)
|
|
||||||
def internal_dispatch_multi(bot, trigger, comrun, *args, **kwargs):
|
|
||||||
|
|
||||||
# Get list of trigger command(s)
|
|
||||||
commands = sb.commands.get_commands_split(trigger, "&&")
|
|
||||||
|
|
||||||
if len(commands) == 1:
|
|
||||||
comrun.trigger_dict = commands[0]
|
|
||||||
function(bot, trigger, comrun, *args, **kwargs)
|
|
||||||
else:
|
|
||||||
for trigger_dict in commands:
|
|
||||||
sb.commands.dispatch(trigger_dict)
|
|
||||||
|
|
||||||
return internal_dispatch_multi
|
|
||||||
return actual_decorator
|
|
||||||
@ -1,49 +0,0 @@
|
|||||||
import functools
|
|
||||||
|
|
||||||
from sopel_SpiceBot_Core_1 import sb
|
|
||||||
|
|
||||||
|
|
||||||
def rule_match():
|
|
||||||
"""This Detects --arguments to commands."""
|
|
||||||
|
|
||||||
def actual_decorator(function):
|
|
||||||
|
|
||||||
@functools.wraps(function)
|
|
||||||
def internal_rule_match(bot, trigger, comrun, *args, **kwargs):
|
|
||||||
|
|
||||||
returnfunc = True
|
|
||||||
|
|
||||||
# Applies to non-command rule matching
|
|
||||||
if comrun.rulematch:
|
|
||||||
|
|
||||||
first_full_trigger_str = trigger.args[1]
|
|
||||||
|
|
||||||
if comrun.trigger_dict["trigger_type"] == "command":
|
|
||||||
commands_list = sb.commands.valid_sopel_commands
|
|
||||||
first_trigger_noprefix = first_full_trigger_str[1:]
|
|
||||||
first_trigger_command = first_trigger_noprefix.split(" ")[0]
|
|
||||||
|
|
||||||
elif comrun.trigger_dict["trigger_type"] == "nickname_command":
|
|
||||||
commands_list = sb.commands.valid_sopel_nickname_commands
|
|
||||||
first_trigger_noprefix = " ".join(first_full_trigger_str.split(" ")[1:])
|
|
||||||
first_trigger_command = first_trigger_noprefix.split(" ")[0]
|
|
||||||
|
|
||||||
elif comrun.trigger_dict["trigger_type"] == "action_command":
|
|
||||||
commands_list = sb.commands.valid_sopel_action_commands
|
|
||||||
first_trigger_noprefix = first_full_trigger_str
|
|
||||||
first_trigger_command = first_trigger_noprefix.split(" ")[0]
|
|
||||||
|
|
||||||
# Ignore if the command was caught
|
|
||||||
# handle if the command was triggered with && or | too close to the command
|
|
||||||
if comrun.trigger_dict["trigger_command"] in commands_list:
|
|
||||||
if first_trigger_command != comrun.trigger_dict["trigger_command"]:
|
|
||||||
sb.commands.dispatch(comrun.trigger_dict)
|
|
||||||
returnfunc = False
|
|
||||||
else:
|
|
||||||
returnfunc = False
|
|
||||||
|
|
||||||
if returnfunc:
|
|
||||||
function(bot, trigger, comrun, *args, **kwargs)
|
|
||||||
|
|
||||||
return internal_rule_match
|
|
||||||
return actual_decorator
|
|
||||||
Loading…
Reference in New Issue
Block a user