Alias & Aka: Add memory and nesting limits. Closes GH-525.

This commit is contained in:
Valentin Lorentz 2013-11-27 17:38:02 +01:00
parent 4c24f30504
commit ddbadcafff
2 changed files with 12 additions and 1 deletions

View File

@ -299,6 +299,8 @@ class Aka(callbacks.Plugin):
if biggestDollar or biggestAt: if biggestDollar or biggestAt:
args = getArgs(args, required=biggestDollar, optional=biggestAt, args = getArgs(args, required=biggestDollar, optional=biggestAt,
wildcard=wildcard) wildcard=wildcard)
max_len = conf.supybot.reply.maximumLength()
args = list(map(lambda x:x[:max_len], args))
def regexpReplace(m): def regexpReplace(m):
idx = int(m.group(1)) idx = int(m.group(1))
return args[idx-1] return args[idx-1]
@ -331,6 +333,9 @@ class Aka(callbacks.Plugin):
ret = True ret = True
return (ret, new_tokens) return (ret, new_tokens)
(ret, tokens) = everythingReplace(tokens) (ret, tokens) = everythingReplace(tokens)
if maxNesting and irc.nested+1 > maxNesting:
irc.error(_('You\'ve attempted more nesting than is '
'currently allowed on this bot.'), Raise=True)
self.Proxy(irc, msg, tokens) self.Proxy(irc, msg, tokens)
if biggestDollar and (wildcard or biggestAt): if biggestDollar and (wildcard or biggestAt):
flexargs = _(' at least') flexargs = _(' at least')

View File

@ -178,6 +178,8 @@ def makeNewAlias(name, alias):
if biggestDollar or biggestAt: if biggestDollar or biggestAt:
args = getArgs(args, required=biggestDollar, optional=biggestAt, args = getArgs(args, required=biggestDollar, optional=biggestAt,
wildcard=wildcard) wildcard=wildcard)
max_len = conf.supybot.reply.maximumLength()
args = list(map(lambda x:x[:max_len], args))
def regexpReplace(m): def regexpReplace(m):
idx = int(m.group(1)) idx = int(m.group(1))
return args[idx-1] return args[idx-1]
@ -212,7 +214,11 @@ def makeNewAlias(name, alias):
return True return True
return False return False
everythingReplace(tokens) everythingReplace(tokens)
self.Proxy(irc, msg, tokens) maxNesting = conf.supybot.commands.nested.maximum()
if maxNesting and irc.nested+1 > maxNesting:
irc.error(_('You\'ve attempted more nesting than is '
'currently allowed on this bot.'), Raise=True)
self.Proxy(irc, msg, tokens, nested=irc.nested+1)
flexargs = '' flexargs = ''
if biggestDollar and (wildcard or biggestAt): if biggestDollar and (wildcard or biggestAt):
flexargs = _(' at least') flexargs = _(' at least')