mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-26 20:59:27 +01:00
SedRegex: abort when a search times out
This requires commitb54d8f8073
, which separates the timeout and no match cases. Also, raise the default processTimeout as the plugin now aborts on the first message that times out. From:e5af479939
This commit is contained in:
parent
43d4861577
commit
1267d6452e
@ -1,6 +1,6 @@
|
|||||||
###
|
###
|
||||||
# Copyright (c) 2015, Michael Daniel Telatynski <postmaster@webdevguru.co.uk>
|
# Copyright (c) 2015, Michael Daniel Telatynski <postmaster@webdevguru.co.uk>
|
||||||
# Copyright (c) 2015, James Lu <glolol@overdrivenetworks.com>
|
# Copyright (c) 2015-2019, James Lu <james@overdrivenetworks.com>
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
@ -57,7 +57,7 @@ conf.registerChannelValue(SedRegex, 'ignoreRegex',
|
|||||||
registry.Boolean(True, _("""Should Perl/sed regex replacing
|
registry.Boolean(True, _("""Should Perl/sed regex replacing
|
||||||
ignore messages which look like valid regex?""")))
|
ignore messages which look like valid regex?""")))
|
||||||
conf.registerGlobalValue(SedRegex, 'processTimeout',
|
conf.registerGlobalValue(SedRegex, 'processTimeout',
|
||||||
registry.PositiveFloat(0.05, _("""Sets the timeout when processing a single
|
registry.PositiveFloat(0.5, _("""Sets the timeout when processing a single
|
||||||
regexp. The default should be adequate unless
|
regexp. The default should be adequate unless
|
||||||
you have a busy or low-powered system that
|
you have a busy or low-powered system that
|
||||||
cannot process regexps quickly enough. However,
|
cannot process regexps quickly enough. However,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
###
|
###
|
||||||
# Copyright (c) 2015, Michael Daniel Telatynski <postmaster@webdevguru.co.uk>
|
# Copyright (c) 2015, Michael Daniel Telatynski <postmaster@webdevguru.co.uk>
|
||||||
# Copyright (c) 2015-2017, James Lu <james@overdrivenetworks.com>
|
# Copyright (c) 2015-2019, James Lu <james@overdrivenetworks.com>
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
@ -154,8 +154,9 @@ class SedRegex(callbacks.PluginRegexp):
|
|||||||
messageprefix = '%s thinks %s' % (msg.nick, m.nick)
|
messageprefix = '%s thinks %s' % (msg.nick, m.nick)
|
||||||
try:
|
try:
|
||||||
regex_timeout = self.registryValue('processTimeout')
|
regex_timeout = self.registryValue('processTimeout')
|
||||||
if regexp_wrapper(text, pattern, timeout=regex_timeout, plugin_name=self.name(),
|
replace_result = regexp_wrapper(text, pattern, timeout=regex_timeout, plugin_name=self.name(),
|
||||||
fcn_name='replacer'):
|
fcn_name='replacer')
|
||||||
|
if replace_result is True:
|
||||||
if self.registryValue('boldReplacementText', msg.args[0]):
|
if self.registryValue('boldReplacementText', msg.args[0]):
|
||||||
replacement = ircutils.bold(replacement)
|
replacement = ircutils.bold(replacement)
|
||||||
subst = process(pattern.sub, replacement,
|
subst = process(pattern.sub, replacement,
|
||||||
@ -168,6 +169,12 @@ class SedRegex(callbacks.PluginRegexp):
|
|||||||
irc.reply(_("%s meant to say: %s") %
|
irc.reply(_("%s meant to say: %s") %
|
||||||
(messageprefix, subst), prefixNick=False)
|
(messageprefix, subst), prefixNick=False)
|
||||||
return
|
return
|
||||||
|
elif replace_result is None:
|
||||||
|
# Abort on timeout instead of looking against older messages - this prevents
|
||||||
|
# replacing the wrong message when we get a one off timeout, which usually leads
|
||||||
|
# to very confusing results.
|
||||||
|
# This requires commit https://github.com/ProgVal/Limnoria/commit/b54d8f8073b4fca1787012b211337dc707cfea45
|
||||||
|
irc.error(_("Search timed out."), Raise=True)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.log.warning(_("SedRegex error: %s"), e, exc_info=True)
|
self.log.warning(_("SedRegex error: %s"), e, exc_info=True)
|
||||||
if self.registryValue('displayErrors', msg.args[0]):
|
if self.registryValue('displayErrors', msg.args[0]):
|
||||||
|
Loading…
Reference in New Issue
Block a user