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