From 1284f0c1576c6efe1c04f6e71301900015cdf38b Mon Sep 17 00:00:00 2001 From: Krytarik Raido Date: Fri, 6 Nov 2020 05:34:04 +0100 Subject: [PATCH] Encyclopedia: Refactor handling of being addressed. --- Encyclopedia/__init__.py | 4 ++-- Encyclopedia/plugin.py | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Encyclopedia/__init__.py b/Encyclopedia/__init__.py index 30231a7..a37a774 100644 --- a/Encyclopedia/__init__.py +++ b/Encyclopedia/__init__.py @@ -24,8 +24,8 @@ import supybot import supybot.world as world from imp import reload -__version__ = "3.1" -__author__ = supybot.Author("Krytarik Raido", "krytarik", "krytarik@tuxgarage.com") +__version__ = "3.2" +__author__ = supybot.Author("Krytarik Raido", "krytarik", "krytarik@gmail.com") __contributors__ = { supybot.Author("Dennis Kaarsemaker", "Seveas", "dennis@kaarsemaker.net"): ['Original Author'], supybot.Author("Terence Simpson", "tsimpson", "tsimpson@ubuntu.com"): ['Original Author'] diff --git a/Encyclopedia/plugin.py b/Encyclopedia/plugin.py index 5fdcd38..febcda1 100644 --- a/Encyclopedia/plugin.py +++ b/Encyclopedia/plugin.py @@ -427,9 +427,11 @@ class Encyclopedia(callbacks.Plugin): if c.isCommandMethod(cmd): return - match = re.match(r'^(?:%s|%s[\W\s]+)\s*(?P.*?)$' % (re.escape(self.registryValue('prefixchar', channel)), re.escape(irc.nick)), text, re.I) - if match: - text = match.group('text') + prefixchar = self.registryValue('prefixchar', channel) + if text[0] == prefixchar: + text = text[1:].strip() + elif re.match(r'^%s[\W\s]' % re.escape(irc.nick), text, re.I): + text = re.sub(r'^%s[\W\s]\s*%s?\s*' % (re.escape(irc.nick), re.escape(prefixchar)), '', text, flags=re.I) elif channel: return if not text: