test
This commit is contained in:
parent
52ceb5eb64
commit
7305a75fe7
@ -153,9 +153,12 @@ class Commands():
|
||||
else:
|
||||
return False
|
||||
|
||||
def is_rulematch(self, function, command_type):
|
||||
def is_catchall(self, function, command_type):
|
||||
"""Determine if function could be called with a rule match"""
|
||||
rulematch = False
|
||||
command_aliases = self.get_command_aliases
|
||||
return '(.*)' in command_aliases
|
||||
|
||||
def get_command_aliases(self, function, command_type):
|
||||
if command_type == "command":
|
||||
if hasattr(function, 'commands'):
|
||||
command_aliases = function.commands
|
||||
@ -165,9 +168,7 @@ class Commands():
|
||||
elif command_type == "action_command":
|
||||
if hasattr(function, 'action_commands'):
|
||||
command_aliases = function.action_commands
|
||||
if '(.*)' in command_aliases:
|
||||
rulematch = True
|
||||
return rulematch
|
||||
return command_aliases
|
||||
|
||||
def get_commands_nosplit(self, trigger):
|
||||
commands = []
|
||||
|
||||
@ -17,15 +17,15 @@ def prerun():
|
||||
# we are going to redispatch commands
|
||||
# This will give sopel the appearance of recieving individual commands
|
||||
if comrun.is_multi_command:
|
||||
if not comrun.is_rulematch:
|
||||
if not comrun.is_catchall:
|
||||
sb.commands.dispatch(comrun.command)
|
||||
elif comrun.is_rulematch and comrun.has_command_been_sanitized:
|
||||
elif comrun.is_catchall and comrun.has_command_been_sanitized:
|
||||
sb.commands.dispatch(comrun.command)
|
||||
|
||||
for trigger_dict in comrun.commands[1:]:
|
||||
if not comrun.is_rulematch:
|
||||
if not comrun.is_catchall:
|
||||
sb.commands.dispatch(trigger_dict)
|
||||
elif comrun.is_rulematch and comrun.has_command_been_sanitized:
|
||||
elif comrun.is_catchall and comrun.has_command_been_sanitized:
|
||||
sb.commands.dispatch(trigger_dict)
|
||||
return
|
||||
|
||||
@ -39,13 +39,17 @@ def prerun():
|
||||
sb.commands.dispatch(trigger_dict)
|
||||
return
|
||||
|
||||
if comrun.is_rulematch and comrun.is_real_command:
|
||||
# Block the catch-all from running a command twice
|
||||
if comrun.is_catchall and comrun.is_real_command:
|
||||
return
|
||||
elif comrun.is_rulematch and not comrun.is_real_command:
|
||||
|
||||
# The command is not valid
|
||||
if comrun.is_catchall and not comrun.is_real_command:
|
||||
bot.say("Invalid command: %s" % comrun.command["trigger_command"])
|
||||
return
|
||||
|
||||
print(trigger.match)
|
||||
# At this point, we update the re.match for trigger
|
||||
trigger = rebuild_trigger(comrun, trigger)
|
||||
|
||||
# Run function
|
||||
function(bot, trigger, comrun, *args, **kwargs)
|
||||
@ -57,6 +61,11 @@ def prerun():
|
||||
return actual_decorator
|
||||
|
||||
|
||||
def rebuild_trigger(comrun, trigger):
|
||||
print(trigger.match)
|
||||
return trigger
|
||||
|
||||
|
||||
def rebuild_pipes(commands):
|
||||
|
||||
repipe_trigger_dict = commands[0]
|
||||
@ -100,8 +109,8 @@ class ComRun():
|
||||
return sb.commands.what_command_type(self.trigger)
|
||||
|
||||
@property
|
||||
def is_rulematch(self):
|
||||
return sb.commands.is_rulematch(self.function, self.command_type)
|
||||
def is_catchall(self):
|
||||
return sb.commands.is_catchall(self.function, self.command_type)
|
||||
|
||||
@property
|
||||
def is_multi_command(self):
|
||||
@ -142,10 +151,11 @@ class ComRun():
|
||||
|
||||
@property
|
||||
def has_command_been_sanitized(self):
|
||||
|
||||
trigger_command = sb.commands.get_command_from_trigger(self.trigger)
|
||||
|
||||
if trigger_command != self.command["trigger_command"]:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
@property
|
||||
def re_match(self):
|
||||
return
|
||||
|
||||
Loading…
Reference in New Issue
Block a user