mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-26 12:49:24 +01:00
MoobotFactoids: Fix support of commands sent in private.
Regression from c1ae3f5c81
.
This commit is contained in:
parent
bc663b164c
commit
bace9cb6c0
@ -325,7 +325,7 @@ class MoobotFactoids(callbacks.Plugin):
|
||||
else:
|
||||
key = ' '.join(tokens)
|
||||
key = self._sanitizeKey(key)
|
||||
channel = plugins.getChannel(msg.channel)
|
||||
channel = plugins.getChannel(msg.channel or msg.args[0])
|
||||
fact = self.db.getFactoid(channel, key)
|
||||
if fact:
|
||||
self.db.updateRequest(channel, key, msg.prefix)
|
||||
@ -385,7 +385,7 @@ class MoobotFactoids(callbacks.Plugin):
|
||||
|
||||
def addFactoid(self, irc, msg, tokens):
|
||||
# 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)
|
||||
try:
|
||||
(key, fact) = self._getKeyAndFactoid(tokens)
|
||||
@ -401,7 +401,7 @@ class MoobotFactoids(callbacks.Plugin):
|
||||
id = self._getUserId(irc, msg.prefix)
|
||||
(key, regexp) = list(map(' '.join,
|
||||
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
|
||||
fact = self._getFactoid(irc, channel, key)
|
||||
self._checkNotLocked(irc, channel, key)
|
||||
@ -422,7 +422,7 @@ class MoobotFactoids(callbacks.Plugin):
|
||||
isAlso = pairs.index(['is', 'also'])
|
||||
key = ' '.join(tokens[:isAlso])
|
||||
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)
|
||||
self._checkNotLocked(irc, channel, key)
|
||||
# It's fair game if we get to here
|
||||
@ -433,7 +433,7 @@ class MoobotFactoids(callbacks.Plugin):
|
||||
|
||||
def replaceFactoid(self, irc, msg, tokens):
|
||||
# Must be registered!
|
||||
channel = plugins.getChannel(msg.channel)
|
||||
channel = plugins.getChannel(msg.channel or msg.args[0])
|
||||
id = self._getUserId(irc, msg.prefix)
|
||||
del tokens[0] # remove the "no,"
|
||||
try:
|
||||
|
@ -71,6 +71,34 @@ class OptionListTestCase(SupyTestCase):
|
||||
self._testOptions('^\\%(\\%(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):
|
||||
plugins = ('MoobotFactoids', 'User', 'String', 'Utilities', 'Web')
|
||||
config = {'reply.whenNotCommand': False}
|
||||
|
Loading…
Reference in New Issue
Block a user