mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-27 21:22:39 +01:00
parent
00f26b0a73
commit
c1e2e2b8a6
@ -35,6 +35,7 @@ import supybot.ircmsgs as ircmsgs
|
||||
import supybot.callbacks as callbacks
|
||||
import supybot.ircutils as ircutils
|
||||
import supybot.ircdb as ircdb
|
||||
import supybot.utils as utils
|
||||
|
||||
import re
|
||||
|
||||
@ -50,6 +51,9 @@ except ImportError:
|
||||
SED_REGEX = re.compile(r"^(?:(?P<nick>.+?)[:,] )?s(?P<delim>[^\w\s])(?P<pattern>.*?)(?P=delim)"
|
||||
r"(?P<replacement>.*?)(?:(?P=delim)(?P<flags>[gi]{0,2}))?$")
|
||||
|
||||
# Replace newlines and friends with things like literal "\n" (backslash and "n")
|
||||
axe_spaces = utils.str.MultipleReplacer({'\n': '\\n', '\t': '\\t', '\r': '\\r'})
|
||||
|
||||
class SedRegex(callbacks.PluginRegexp):
|
||||
"""History replacer using sed-style regex syntax."""
|
||||
threaded = True
|
||||
@ -148,6 +152,9 @@ class SedRegex(callbacks.PluginRegexp):
|
||||
text, count, timeout=0.05)
|
||||
if action: # If the message was an ACTION, prepend the nick back.
|
||||
subst = '* %s %s' % (m.nick, subst)
|
||||
|
||||
subst = axe_spaces(subst)
|
||||
|
||||
irc.reply(_("%s meant to say: %s") %
|
||||
(messageprefix, subst), prefixNick=False)
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user