Encyclopedia: Rework message parsing.
This commit is contained in:
parent
902534d10b
commit
db29965a33
|
@ -24,7 +24,7 @@ import supybot
|
||||||
import supybot.world as world
|
import supybot.world as world
|
||||||
from importlib import reload
|
from importlib import reload
|
||||||
|
|
||||||
__version__ = "3.6.0"
|
__version__ = "3.7.0"
|
||||||
__author__ = supybot.Author("Krytarik Raido", "krytarik", "krytarik@gmail.com")
|
__author__ = supybot.Author("Krytarik Raido", "krytarik", "krytarik@gmail.com")
|
||||||
__contributors__ = {
|
__contributors__ = {
|
||||||
supybot.Author("Dennis Kaarsemaker", "Seveas", "dennis@kaarsemaker.net"): ['Original Author'],
|
supybot.Author("Dennis Kaarsemaker", "Seveas", "dennis@kaarsemaker.net"): ['Original Author'],
|
||||||
|
|
|
@ -449,7 +449,6 @@ class Encyclopedia(callbacks.Plugin):
|
||||||
if text.split()[0].lower() in self.registryValue('ignores', channel):
|
if text.split()[0].lower() in self.registryValue('ignores', channel):
|
||||||
return
|
return
|
||||||
|
|
||||||
doChanMsg = True # Send message to channel
|
|
||||||
display = None # Set display type
|
display = None # Set display type
|
||||||
edit = None
|
edit = None
|
||||||
if not channel:
|
if not channel:
|
||||||
|
@ -466,15 +465,15 @@ class Encyclopedia(callbacks.Plugin):
|
||||||
return
|
return
|
||||||
|
|
||||||
irc = callbacks.ReplyIrcProxy(irc, msg)
|
irc = callbacks.ReplyIrcProxy(irc, msg)
|
||||||
|
ret, retmsg = '', ''
|
||||||
|
|
||||||
# Now switch between actions
|
# Now switch between actions
|
||||||
ret, retmsg = '', ''
|
if display:
|
||||||
|
ret = self.factoid_lookup(text, channel, msg.nick, display)
|
||||||
|
else:
|
||||||
term = self.get_target(irc, msg.nick, text, target)
|
term = self.get_target(irc, msg.nick, text, target)
|
||||||
lower_term = term[0].lower()
|
lower_term = term[0].lower()
|
||||||
|
|
||||||
if re.match(r"please\s+see\s+((%s|(the\s+)?bot)(\s*'?s)?\s+\S+|\S+.*\s+\S+\s+(%s|(the\s+)?bot)\b)" % (re.escape(irc.nick), re.escape(irc.nick)), text, re.I):
|
|
||||||
doChanMsg = False
|
|
||||||
|
|
||||||
if lower_term == "search": # Usage info for the !search command
|
if lower_term == "search": # Usage info for the !search command
|
||||||
ret = "Search factoids for term: !search <term>"
|
ret = "Search factoids for term: !search <term>"
|
||||||
target = term[1]
|
target = term[1]
|
||||||
|
@ -501,7 +500,6 @@ class Encyclopedia(callbacks.Plugin):
|
||||||
elif re.match(r'^[^|\s]+[^|]*?\s+is(\s+|\b)\S+', text, re.I):
|
elif re.match(r'^[^|\s]+[^|]*?\s+is(\s+|\b)\S+', text, re.I):
|
||||||
edit = 'add'
|
edit = 'add'
|
||||||
else:
|
else:
|
||||||
if not display:
|
|
||||||
text, target, retmsg = term
|
text, target, retmsg = term
|
||||||
ret = self.factoid_lookup(text, channel, msg.nick, display)
|
ret = self.factoid_lookup(text, channel, msg.nick, display)
|
||||||
|
|
||||||
|
@ -559,7 +557,7 @@ class Encyclopedia(callbacks.Plugin):
|
||||||
if retmsg and checkUrl(retmsg):
|
if retmsg and checkUrl(retmsg):
|
||||||
# !ops factoid called with a URL, most likely spam
|
# !ops factoid called with a URL, most likely spam
|
||||||
return
|
return
|
||||||
if doChanMsg and channel and not irc.isChannel(target) \
|
if channel and not irc.isChannel(target) \
|
||||||
and target in irc.state.channels[channel].users:
|
and target in irc.state.channels[channel].users:
|
||||||
myqueue(irc, channel, "%s: Please see my private message" % target)
|
myqueue(irc, channel, "%s: Please see my private message" % target)
|
||||||
myqueue(irc, target, retmsg + ret[0])
|
myqueue(irc, target, retmsg + ret[0])
|
||||||
|
|
Loading…
Reference in New Issue