mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-28 03:20:48 +01:00
MoobotFactoids: Fix support of commands sent in private.
Regression from c1ae3f5c81cc8cf4effc7670e99c9270e31a1c9c.
This commit is contained in:
parent
bc663b164c
commit
bace9cb6c0
@ -325,7 +325,7 @@ class MoobotFactoids(callbacks.Plugin):
|
|||||||
else:
|
else:
|
||||||
key = ' '.join(tokens)
|
key = ' '.join(tokens)
|
||||||
key = self._sanitizeKey(key)
|
key = self._sanitizeKey(key)
|
||||||
channel = plugins.getChannel(msg.channel)
|
channel = plugins.getChannel(msg.channel or msg.args[0])
|
||||||
fact = self.db.getFactoid(channel, key)
|
fact = self.db.getFactoid(channel, key)
|
||||||
if fact:
|
if fact:
|
||||||
self.db.updateRequest(channel, key, msg.prefix)
|
self.db.updateRequest(channel, key, msg.prefix)
|
||||||
@ -385,7 +385,7 @@ class MoobotFactoids(callbacks.Plugin):
|
|||||||
|
|
||||||
def addFactoid(self, irc, msg, tokens):
|
def addFactoid(self, irc, msg, tokens):
|
||||||
# First, check and see if the entire message matches a factoid key
|
# First, check and see if the entire message matches a factoid key
|
||||||
channel = plugins.getChannel(msg.channel)
|
channel = plugins.getChannel(msg.channel or msg.args[0])
|
||||||
id = self._getUserId(irc, msg.prefix)
|
id = self._getUserId(irc, msg.prefix)
|
||||||
try:
|
try:
|
||||||
(key, fact) = self._getKeyAndFactoid(tokens)
|
(key, fact) = self._getKeyAndFactoid(tokens)
|
||||||
@ -401,7 +401,7 @@ class MoobotFactoids(callbacks.Plugin):
|
|||||||
id = self._getUserId(irc, msg.prefix)
|
id = self._getUserId(irc, msg.prefix)
|
||||||
(key, regexp) = list(map(' '.join,
|
(key, regexp) = list(map(' '.join,
|
||||||
utils.iter.split('=~'.__eq__, tokens, maxsplit=1)))
|
utils.iter.split('=~'.__eq__, tokens, maxsplit=1)))
|
||||||
channel = plugins.getChannel(msg.channel)
|
channel = plugins.getChannel(msg.channel or msg.args[0])
|
||||||
# Check and make sure it's in the DB
|
# Check and make sure it's in the DB
|
||||||
fact = self._getFactoid(irc, channel, key)
|
fact = self._getFactoid(irc, channel, key)
|
||||||
self._checkNotLocked(irc, channel, key)
|
self._checkNotLocked(irc, channel, key)
|
||||||
@ -422,7 +422,7 @@ class MoobotFactoids(callbacks.Plugin):
|
|||||||
isAlso = pairs.index(['is', 'also'])
|
isAlso = pairs.index(['is', 'also'])
|
||||||
key = ' '.join(tokens[:isAlso])
|
key = ' '.join(tokens[:isAlso])
|
||||||
new_text = ' '.join(tokens[isAlso+2:])
|
new_text = ' '.join(tokens[isAlso+2:])
|
||||||
channel = plugins.getChannel(msg.channel)
|
channel = plugins.getChannel(msg.channel or msg.args[0])
|
||||||
fact = self._getFactoid(irc, channel, key)
|
fact = self._getFactoid(irc, channel, key)
|
||||||
self._checkNotLocked(irc, channel, key)
|
self._checkNotLocked(irc, channel, key)
|
||||||
# It's fair game if we get to here
|
# It's fair game if we get to here
|
||||||
@ -433,7 +433,7 @@ class MoobotFactoids(callbacks.Plugin):
|
|||||||
|
|
||||||
def replaceFactoid(self, irc, msg, tokens):
|
def replaceFactoid(self, irc, msg, tokens):
|
||||||
# Must be registered!
|
# Must be registered!
|
||||||
channel = plugins.getChannel(msg.channel)
|
channel = plugins.getChannel(msg.channel or msg.args[0])
|
||||||
id = self._getUserId(irc, msg.prefix)
|
id = self._getUserId(irc, msg.prefix)
|
||||||
del tokens[0] # remove the "no,"
|
del tokens[0] # remove the "no,"
|
||||||
try:
|
try:
|
||||||
|
@ -71,6 +71,34 @@ class OptionListTestCase(SupyTestCase):
|
|||||||
self._testOptions('^\\%(\\%(foo\\)\\@<!.\\)*$',
|
self._testOptions('^\\%(\\%(foo\\)\\@<!.\\)*$',
|
||||||
['^\\%(\\%(foo\\)\\@<!.\\)*$'])
|
['^\\%(\\%(foo\\)\\@<!.\\)*$'])
|
||||||
|
|
||||||
|
|
||||||
|
class NonChannelFactoidsTestCase(ChannelPluginTestCase):
|
||||||
|
plugins = ('MoobotFactoids', 'User')
|
||||||
|
config = {'reply.whenNotCommand': False}
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
ChannelPluginTestCase.setUp(self)
|
||||||
|
# Create a valid user to use
|
||||||
|
self.prefix = 'mf!bar@baz'
|
||||||
|
self.irc.feedMsg(ircmsgs.privmsg(self.nick, 'register tester moo',
|
||||||
|
prefix=self.prefix))
|
||||||
|
m = self.irc.takeMsg() # Response to register.
|
||||||
|
def testAddFactoid(self):
|
||||||
|
self.assertNotError('moo is foo')
|
||||||
|
# Check stripping punctuation
|
||||||
|
self.assertError('moo!? is foo') # 'moo' already exists
|
||||||
|
self.assertNotError('foo!? is foo')
|
||||||
|
self.assertResponse('foo', 'foo is foo')
|
||||||
|
self.assertNotError('bar is <reply>moo is moo')
|
||||||
|
self.assertResponse('bar', 'moo is moo')
|
||||||
|
# Check substitution
|
||||||
|
self.assertNotError('who is <reply>$who')
|
||||||
|
self.assertResponse('who', ircutils.nickFromHostmask(self.prefix))
|
||||||
|
# Check that actions ("\x01ACTION...") don't match
|
||||||
|
m = ircmsgs.action(self.channel, 'is doing something')
|
||||||
|
self.irc.feedMsg(m)
|
||||||
|
self.assertNoResponse(' ', 1)
|
||||||
|
|
||||||
class FactoidsTestCase(ChannelPluginTestCase):
|
class FactoidsTestCase(ChannelPluginTestCase):
|
||||||
plugins = ('MoobotFactoids', 'User', 'String', 'Utilities', 'Web')
|
plugins = ('MoobotFactoids', 'User', 'String', 'Utilities', 'Web')
|
||||||
config = {'reply.whenNotCommand': False}
|
config = {'reply.whenNotCommand': False}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user