mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 13:19:24 +01:00
Fixed bug in testGreet.
This commit is contained in:
parent
218e53b409
commit
0f45fe2c36
@ -35,16 +35,26 @@ Just a regexp module to make the bot a wee bit friendlier.
|
|||||||
|
|
||||||
import plugins
|
import plugins
|
||||||
|
|
||||||
|
import debug
|
||||||
|
import ircutils
|
||||||
import callbacks
|
import callbacks
|
||||||
|
|
||||||
class Friendly(callbacks.PrivmsgRegexp):
|
class Friendly(callbacks.PrivmsgRegexp):
|
||||||
onlyFirstMatch = True
|
onlyFirstMatch = True
|
||||||
def greet(self, irc, msg, match):
|
def greet(self, irc, msg, match):
|
||||||
r"(?:heya?|(?:w(?:hat'?s\b|as)s?up)|howdy|hi|hello)$"
|
r"^(?:heya?|(?:w(?:hat'?s\b|as)s?up)|howdy|hi|hello)$"
|
||||||
if irc.nick in msg.args[1]:
|
if irc.nick in msg.args[1]:
|
||||||
s = 'howdy, %s :)' % msg.nick
|
s = 'howdy, %s :)' % msg.nick
|
||||||
irc.reply(msg, s, prefixName=False)
|
irc.reply(msg, s, prefixName=False)
|
||||||
|
|
||||||
|
def greet2(self, irc, msg, match):
|
||||||
|
r"^(?:heya?|(?:w(?:hat'?s\b|as)s*up)|howdy|hi|hello)" \
|
||||||
|
r"(?:,\s*|\s+)" \
|
||||||
|
r"([0-9A-Za-z_\[\]\`^{}\|-]+)[^A-Za-z_\[\]\`^{}\|-]*$"
|
||||||
|
if ircutils.nickEqual(match.group(1), irc.nick):
|
||||||
|
s = 'howdy, %s :)' % msg.nick
|
||||||
|
irc.reply(msg, s, prefixName=False)
|
||||||
|
|
||||||
def goodbye(self, irc, msg, match):
|
def goodbye(self, irc, msg, match):
|
||||||
r"(?:good)?bye|adios|vale|ciao|au revoir|seeya|night$"
|
r"(?:good)?bye|adios|vale|ciao|au revoir|seeya|night$"
|
||||||
if irc.nick in msg.args[1]:
|
if irc.nick in msg.args[1]:
|
||||||
|
@ -40,6 +40,7 @@ class FriendlyTestCase(PluginTestCase):
|
|||||||
def testGreet(self):
|
def testGreet(self):
|
||||||
self.assertNotError('heya, %s' % self.irc.nick)
|
self.assertNotError('heya, %s' % self.irc.nick)
|
||||||
self.assertNotError('howdy %s' % self.irc.nick)
|
self.assertNotError('howdy %s' % self.irc.nick)
|
||||||
|
self.assertNotError('howdy %s!' % self.irc.nick)
|
||||||
self.assertNotError('hi, %s!' % self.irc.nick)
|
self.assertNotError('hi, %s!' % self.irc.nick)
|
||||||
self.assertNotRegexp('hi, %s' % self.irc.nick,
|
self.assertNotRegexp('hi, %s' % self.irc.nick,
|
||||||
'^%s: ' % self.irc.nick)
|
'^%s: ' % self.irc.nick)
|
||||||
@ -58,6 +59,14 @@ class FriendlyTestCase(PluginTestCase):
|
|||||||
self.assertNotRegexp('thanks, %s' % self.irc.nick,
|
self.assertNotRegexp('thanks, %s' % self.irc.nick,
|
||||||
'^%s: ' % self.irc.nick)
|
'^%s: ' % self.irc.nick)
|
||||||
|
|
||||||
|
def testGreet2Regexp(self):
|
||||||
|
me = self.irc.getCallback('Friendly')
|
||||||
|
r = re.compile(me.greet2.__doc__, re.I)
|
||||||
|
m = r.search('heya, %s' % self.irc.nick)
|
||||||
|
self.failUnless(m, 'no match')
|
||||||
|
self.failUnless(m.groups(), 'no match.groups()')
|
||||||
|
self.assertEqual(m.group(1), self.irc.nick)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||||
|
Loading…
Reference in New Issue
Block a user