mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-17 06:00:42 +01:00
Fixed greedniess of a few regexes and did some associated fixes.
This commit is contained in:
parent
bf12760108
commit
cc94948d10
@ -284,7 +284,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
|
||||
irc.reply(msg, conf.replySuccess)
|
||||
|
||||
def augmentFactoid(self, irc, msg, match):
|
||||
r"(.+) is also (.+)"
|
||||
r"(.+?) is also (.+)"
|
||||
# Must be registered!
|
||||
try:
|
||||
id = ircdb.users.getUserId(msg.prefix)
|
||||
@ -314,7 +314,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
|
||||
irc.reply(msg, conf.replySuccess)
|
||||
|
||||
def replaceFactoid(self, irc, msg, match):
|
||||
r"^no,?\s+(.+)\s+is\s+(.+)"
|
||||
r"^no,?\s+(.+?)\s+is\s+(.+)"
|
||||
# Must be registered!
|
||||
try:
|
||||
id = ircdb.users.getUserId(msg.prefix)
|
||||
@ -322,6 +322,11 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
|
||||
irc.error(msg, conf.replyNotRegistered)
|
||||
return
|
||||
key, new_fact = match.groups()
|
||||
# These are okay, unless there's an _is_ in there, in which case
|
||||
# we split on the leftmost one.
|
||||
if '_is_' in match.group():
|
||||
key, new_fact = map(str.strip, match.group().split('_is_', 1))
|
||||
key = key.split(' ', 1)[1] # Take out everything to first space
|
||||
cursor = self.db.cursor()
|
||||
# Check and make sure it's in the DB
|
||||
cursor.execute("""SELECT locked_at, fact FROM factoids
|
||||
|
@ -193,6 +193,9 @@ if sqlite is not None:
|
||||
self.assertNotError('moo is foo')
|
||||
self.assertNotError('moo is also bar')
|
||||
self.assertResponse('moo', 'moo is foo, or bar')
|
||||
self.assertNotError('moo is bar _is_ foo')
|
||||
self.assertNotError('moo is bar is also foo')
|
||||
self.assertResponse('moo is bar', 'moo is bar is foo, or foo')
|
||||
|
||||
def testReplaceFactoid(self):
|
||||
self.assertNotError('moo is foo')
|
||||
@ -202,6 +205,9 @@ if sqlite is not None:
|
||||
self.assertResponse('moo', 'moo is baz')
|
||||
self.assertNotError('lock moo')
|
||||
self.assertError('no moo is qux')
|
||||
self.assertNotError('foo is bar _is_ foo')
|
||||
self.assertNotError('no foo is bar _is_ baz')
|
||||
self.assertResponse('foo is bar', 'foo is bar is baz')
|
||||
|
||||
def testRegexpNotCalledIfAlreadyHandled(self):
|
||||
self.assertResponse('echo foo is bar', 'foo is bar')
|
||||
|
Loading…
x
Reference in New Issue
Block a user