mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-24 11:42:52 +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
|
# These are the characters valid in a token. Everything printable except
|
||||||
# double-quote, left-bracket, and right-bracket.
|
# 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 = '"'
|
quotes = '"'
|
||||||
def __init__(self, tokens=''):
|
def __init__(self, tokens=''):
|
||||||
# Add a '|' to tokens to have the pipe syntax.
|
# Add a '|' to tokens to have the pipe syntax.
|
||||||
@ -207,15 +207,16 @@ class Tokenizer:
|
|||||||
token = lexer.get_token()
|
token = lexer.get_token()
|
||||||
if not token:
|
if not token:
|
||||||
break
|
break
|
||||||
elif token == '|':
|
elif token == '|' and conf.supybot.pipeSyntax():
|
||||||
if not args:
|
if not args:
|
||||||
raise SyntaxError, '"|" with nothing preceding'
|
raise SyntaxError, '"|" with nothing preceding'
|
||||||
ends.append(args)
|
ends.append(args)
|
||||||
args = []
|
args = []
|
||||||
elif token == '[':
|
elif conf.supybot.bracketSyntax():
|
||||||
args.append(self._insideBrackets(lexer))
|
if token == '[':
|
||||||
elif token == ']':
|
args.append(self._insideBrackets(lexer))
|
||||||
raise SyntaxError, 'Spurious "["'
|
elif token == ']':
|
||||||
|
raise SyntaxError, 'Spurious "["'
|
||||||
else:
|
else:
|
||||||
args.append(self._handleToken(token))
|
args.append(self._handleToken(token))
|
||||||
if ends:
|
if ends:
|
||||||
@ -235,10 +236,11 @@ def tokenize(s):
|
|||||||
try:
|
try:
|
||||||
if s != _lastTokenized:
|
if s != _lastTokenized:
|
||||||
_lastTokenized = s
|
_lastTokenized = s
|
||||||
|
tokens = ''
|
||||||
|
if conf.supybot.bracketSyntax():
|
||||||
|
tokens = '[]'
|
||||||
if conf.supybot.pipeSyntax():
|
if conf.supybot.pipeSyntax():
|
||||||
tokens = '|'
|
tokens = '%s|' % tokens
|
||||||
else:
|
|
||||||
tokens = ''
|
|
||||||
_lastTokenizeResult = Tokenizer(tokens).tokenize(s)
|
_lastTokenizeResult = Tokenizer(tokens).tokenize(s)
|
||||||
except ValueError, e:
|
except ValueError, e:
|
||||||
_lastTokenized = None
|
_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
|
messages. For safety purposes (so the bot can't possibly flood) it will
|
||||||
normally send everything in a single message."""))
|
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
|
supybot.register('pipeSyntax', registry.Boolean(False, """Supybot allows
|
||||||
nested commands; generally, commands are nested via square brackets. Supybot
|
nested commands. Enabling this option will allow nested commands with a syntax
|
||||||
can also provide a syntax more similar to UNIX pipes. The square bracket
|
similar to UNIX pipes, for example: 'bot: foo | bar'."""))
|
||||||
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]'."""))
|
|
||||||
|
|
||||||
supybot.reply.register('whenNotCommand', registry.Boolean(True, """
|
supybot.reply.register('whenNotCommand', registry.Boolean(True, """
|
||||||
Determines whether the bot will reply with an error message when it is
|
Determines whether the bot will reply with an error message when it is
|
||||||
|
Loading…
Reference in New Issue
Block a user