move recursion scan after alias setup, and do another after alias replace

This commit is contained in:
Brian S. Stephan 2010-12-17 16:12:45 -06:00
parent 1fe9575502
commit 107b754a0d
1 changed files with 14 additions and 10 deletions

View File

@ -34,13 +34,6 @@ class Alias(Module):
an internal bot command and run it.
"""
# search for recursions, which will search for recursions, which ...
what = self.try_recursion(connection, event, nick, userhost, None, what, admin_unlocked)
# done searching for recursions in this level. we will now operate on
# whatever recursion-satisfied string we have, checking for alias and
# running module commands
# first see if the aliases are being directly manipulated via add/remove
whats = what.split(' ')
try:
@ -69,6 +62,13 @@ class Alias(Module):
except NoOptionError: pass
except NoSectionError: pass
# search for recursions, which will search for recursions, which ...
what = self.try_recursion(connection, event, nick, userhost, None, what, admin_unlocked)
# done searching for recursions in this level. we will now operate on
# whatever recursion-satisfied string we have, checking for alias and
# running module commands
# now that that's over, try doing alias work
try:
alias_list = self.config.options(self.__class__.__name__)
@ -78,10 +78,14 @@ class Alias(Module):
alias_re = re.compile(alias)
if alias_re.search(what):
command = re.sub(alias, self.config.get(self.__class__.__name__, alias), what)
# we found an alias for our given string, doing a replace and running it against
# each module
# we found an alias for our given string, doing a replace
# need to do another recursion scan
command = self.try_recursion(connection, event, nick, userhost, None, command, admin_unlocked)
# running it against each module
for module in self.modlist:
ret = module.do(connection, event, nick, userhost, replypath, command, admin_unlocked)
ret = module.do(connection, event, nick, userhost, None, command, admin_unlocked)
if ret is not None:
# a module had a result for us, post-alias, so return it
# TODO: scan all modules with compounding results