mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-02 17:29:22 +01:00
Fixed a nasty bug where pipe syntax would still work if it's disabled but
the pipe character is spaced out, as in: @foo | bar Also added supybot.bracketSyntax; defaults to True, don't worry. ;)
This commit is contained in:
parent
ffe0c5c5d9
commit
f08f875d3c
@ -169,7 +169,7 @@ class Tokenizer:
|
||||
#
|
||||
# These are the characters valid in a token. Everything printable except
|
||||
# double-quote, left-bracket, and right-bracket.
|
||||
validChars = string.ascii.translate(string.ascii, '\x00\r\n \t"[]')
|
||||
validChars = string.ascii.translate(string.ascii, '\x00\r\n \t"')
|
||||
quotes = '"'
|
||||
def __init__(self, tokens=''):
|
||||
# Add a '|' to tokens to have the pipe syntax.
|
||||
@ -207,12 +207,13 @@ class Tokenizer:
|
||||
token = lexer.get_token()
|
||||
if not token:
|
||||
break
|
||||
elif token == '|':
|
||||
elif token == '|' and conf.supybot.pipeSyntax():
|
||||
if not args:
|
||||
raise SyntaxError, '"|" with nothing preceding'
|
||||
ends.append(args)
|
||||
args = []
|
||||
elif token == '[':
|
||||
elif conf.supybot.bracketSyntax():
|
||||
if token == '[':
|
||||
args.append(self._insideBrackets(lexer))
|
||||
elif token == ']':
|
||||
raise SyntaxError, 'Spurious "["'
|
||||
@ -235,10 +236,11 @@ def tokenize(s):
|
||||
try:
|
||||
if s != _lastTokenized:
|
||||
_lastTokenized = s
|
||||
if conf.supybot.pipeSyntax():
|
||||
tokens = '|'
|
||||
else:
|
||||
tokens = ''
|
||||
if conf.supybot.bracketSyntax():
|
||||
tokens = '[]'
|
||||
if conf.supybot.pipeSyntax():
|
||||
tokens = '%s|' % tokens
|
||||
_lastTokenizeResult = Tokenizer(tokens).tokenize(s)
|
||||
except ValueError, e:
|
||||
_lastTokenized = None
|
||||
|
10
src/conf.py
10
src/conf.py
@ -175,11 +175,13 @@ the bot will send multi-message replies in a single messsage or in multiple
|
||||
messages. For safety purposes (so the bot can't possibly flood) it will
|
||||
normally send everything in a single message."""))
|
||||
|
||||
supybot.register('bracketSyntax', registry.Boolean(True, """Supybot allows
|
||||
nested commands. If this option is enabled users can nest commands using a
|
||||
bracket syntax, for example: 'bot: bar [foo]'."""))
|
||||
|
||||
supybot.register('pipeSyntax', registry.Boolean(False, """Supybot allows
|
||||
nested commands; generally, commands are nested via square brackets. Supybot
|
||||
can also provide a syntax more similar to UNIX pipes. The square bracket
|
||||
nesting syntax is always enabled, but when this value is True, users can also
|
||||
nest commands by saying 'bot: foo | bar' instead of 'bot: bar [foo]'."""))
|
||||
nested commands. Enabling this option will allow nested commands with a syntax
|
||||
similar to UNIX pipes, for example: 'bot: foo | bar'."""))
|
||||
|
||||
supybot.reply.register('whenNotCommand', registry.Boolean(True, """
|
||||
Determines whether the bot will reply with an error message when it is
|
||||
|
Loading…
Reference in New Issue
Block a user