mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-04 08:34:11 +01:00
Misc: Use regexp_wrapper for Misc.last
Signed-off-by: James McCoy <jamessan@users.sourceforge.net>
This commit is contained in:
parent
c774be3ea6
commit
57e429011d
@ -313,25 +313,13 @@ class Misc(callbacks.Plugin):
|
|||||||
predicates.setdefault('without', []).append(f)
|
predicates.setdefault('without', []).append(f)
|
||||||
elif option == 'regexp':
|
elif option == 'regexp':
|
||||||
def f(m, arg=arg):
|
def f(m, arg=arg):
|
||||||
def f1(s, arg):
|
|
||||||
"""Since we can't enqueue match objects into the multiprocessing queue,
|
|
||||||
we'll just wrap the function to return bools."""
|
|
||||||
if arg.search(s) is not None:
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
if ircmsgs.isAction(m):
|
if ircmsgs.isAction(m):
|
||||||
m1 = ircmsgs.unAction(m)
|
m1 = ircmsgs.unAction(m)
|
||||||
else:
|
else:
|
||||||
m1 = m.args[1]
|
m1 = m.args[1]
|
||||||
try:
|
return regexp_wrapper(m1, reobj=arg, timeout=0.1,
|
||||||
# use a subprocess here, since specially crafted regexps can
|
plugin_name=self.name(),
|
||||||
# take exponential time and hang up the bot.
|
fcn_name='last')
|
||||||
# timeout of 0.1 should be more than enough for any normal regexp.
|
|
||||||
v = commands.process(f1, m1, arg, timeout=0.1, pn=self.name(), cn='last')
|
|
||||||
return v
|
|
||||||
except commands.ProcessTimeoutError:
|
|
||||||
return False
|
|
||||||
predicates.setdefault('regexp', []).append(f)
|
predicates.setdefault('regexp', []).append(f)
|
||||||
elif option == 'nolimit':
|
elif option == 'nolimit':
|
||||||
nolimit = True
|
nolimit = True
|
||||||
|
Loading…
Reference in New Issue
Block a user