Encyclopedia: Refactor handling of being addressed.

This commit is contained in:
Krytarik Raido 2020-11-06 05:34:04 +01:00
parent 83434d4373
commit 1284f0c157
2 changed files with 7 additions and 5 deletions

View File

@ -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']

View File

@ -427,9 +427,11 @@ class Encyclopedia(callbacks.Plugin):
if c.isCommandMethod(cmd):
return
match = re.match(r'^(?:%s|%s[\W\s]+)\s*(?P<text>.*?)$' % (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: