mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 19:19:32 +01:00
Fix replacement of my/me not obeying word boundaries. Also created tests to
ensure it stays fixed.
This commit is contained in:
parent
8cc9620a4b
commit
afc74b96f0
@ -154,9 +154,8 @@ class FunDB(callbacks.Privmsg):
|
|||||||
else:
|
else:
|
||||||
(id, insult) = cursor.fetchone()
|
(id, insult) = cursor.fetchone()
|
||||||
nick = nick.strip()
|
nick = nick.strip()
|
||||||
if nick in (irc.nick, 'yourself', 'me'):
|
nick = re.sub(r'\b(?:me|%s)\b' % irc.nick, msg.nick, nick)
|
||||||
insultee = msg.nick
|
nick = re.sub(r'\bmy\b', '%s\'s' % msg.nick, nick)
|
||||||
else:
|
|
||||||
insultee = nick
|
insultee = nick
|
||||||
insult = insult.replace("$who", insultee)
|
insult = insult.replace("$who", insultee)
|
||||||
s = '%s: %s (#%s)' % (insultee, insult, id)
|
s = '%s: %s (#%s)' % (insultee, insult, id)
|
||||||
@ -427,11 +426,10 @@ class FunDB(callbacks.Privmsg):
|
|||||||
irc.error(msg, 'There are currently no available larts.')
|
irc.error(msg, 'There are currently no available larts.')
|
||||||
else:
|
else:
|
||||||
(id, lart) = cursor.fetchone()
|
(id, lart) = cursor.fetchone()
|
||||||
if nick in (irc.nick, 'me'):
|
nick = re.sub(r'\b(?:me|%s)\b' % irc.nick, msg.nick, nick)
|
||||||
lartee = msg.nick
|
reason = re.sub(r'\b(?:me|%s)\b' % irc.nick, msg.nick, reason)
|
||||||
elif 'my' in nick:
|
nick = re.sub(r'\bmy\b', '%s\'s' % msg.nick, nick)
|
||||||
lartee = nick.replace('my', '%s\'s' % msg.nick)
|
reason = re.sub(r'\bmy\b', '%s\'s' % msg.nick, reason)
|
||||||
else:
|
|
||||||
lartee = nick
|
lartee = nick
|
||||||
lart = lart.replace("$who", lartee)
|
lart = lart.replace("$who", lartee)
|
||||||
if len(reason) > 0:
|
if len(reason) > 0:
|
||||||
@ -480,11 +478,10 @@ class FunDB(callbacks.Privmsg):
|
|||||||
irc.error(msg, 'There are currently no available praises.')
|
irc.error(msg, 'There are currently no available praises.')
|
||||||
else:
|
else:
|
||||||
(id, praise) = cursor.fetchone()
|
(id, praise) = cursor.fetchone()
|
||||||
if nick in (msg.nick, 'me'):
|
nick = re.sub(r'\b(?:me|%s)\b' % irc.nick, msg.nick, nick)
|
||||||
praisee = msg.nick
|
reason = re.sub(r'\b(?:me|%s)\b' % irc.nick, msg.nick, reason)
|
||||||
elif 'my' in nick:
|
nick = re.sub(r'\bmy\b', '%s\'s' % msg.nick, nick)
|
||||||
praisee = nick.replace('my', '%s\'s' % msg.nick)
|
reason = re.sub(r'\bmy\b', '%s\'s' % msg.nick, reason)
|
||||||
else:
|
|
||||||
praisee = nick
|
praisee = nick
|
||||||
praise = praise.replace("$who", praisee)
|
praise = praise.replace("$who", praisee)
|
||||||
if len(reason) > 0:
|
if len(reason) > 0:
|
||||||
|
@ -70,6 +70,32 @@ if sqlite is not None:
|
|||||||
self.assertRegexp('num lart', 'currently 0')
|
self.assertRegexp('num lart', 'currently 0')
|
||||||
self.assertError('lart jemfinch')
|
self.assertError('lart jemfinch')
|
||||||
|
|
||||||
|
def testMyMeReplacement(self):
|
||||||
|
self.assertNotError('add lart jabs $who')
|
||||||
|
self.assertNotError('add praise pets $who')
|
||||||
|
self.assertNotError('add insult foo')
|
||||||
|
self.assertRegexp('lart me', 'jabs test \(#1\)')
|
||||||
|
self.assertRegexp('praise me', 'pets test \(#1\)')
|
||||||
|
self.assertRegexp('insult me', 'test: foo \(#1\)')
|
||||||
|
self.assertRegexp('lart whamme', 'jabs whamme \(#1\)')
|
||||||
|
self.assertRegexp('praise whamme', 'pets whamme \(#1\)')
|
||||||
|
self.assertRegexp('insult whamme', 'whamme: foo \(#1\)')
|
||||||
|
self.assertRegexp('lart my knee', 'jabs test\'s knee \(#1\)')
|
||||||
|
self.assertRegexp('praise my knee', 'pets test\'s knee \(#1\)')
|
||||||
|
self.assertRegexp('insult my knee', 'test\'s knee: foo \(#1\)')
|
||||||
|
self.assertRegexp('lart sammy the snake', 'jabs sammy the snake'\
|
||||||
|
' \(#1\)')
|
||||||
|
self.assertRegexp('praise sammy the snake', 'pets sammy the snake'\
|
||||||
|
' \(#1\)')
|
||||||
|
self.assertRegexp('insult sammy the snake', 'sammy the snake: foo'\
|
||||||
|
' \(#1\)')
|
||||||
|
self.assertRegexp('lart me for my', 'jabs test for test\'s \(#1\)')
|
||||||
|
self.assertRegexp('praise me for my','pets test for test\'s '\
|
||||||
|
'\(#1\)')
|
||||||
|
self.assertNotError('remove lart 1')
|
||||||
|
self.assertNotError('remove praise 1')
|
||||||
|
self.assertNotError('remove insult 1')
|
||||||
|
|
||||||
def testExcuse(self):
|
def testExcuse(self):
|
||||||
self.assertNotError('add excuse Power failure')
|
self.assertNotError('add excuse Power failure')
|
||||||
self.assertResponse('excuse', 'Power failure (#1)')
|
self.assertResponse('excuse', 'Power failure (#1)')
|
||||||
|
Loading…
Reference in New Issue
Block a user