From 0f45fe2c36213305122b3bd53a88c1e75abb5084 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Sat, 25 Oct 2003 18:22:52 +0000 Subject: [PATCH] Fixed bug in testGreet. --- plugins/Friendly.py | 12 +++++++++++- test/test_Friendly.py | 9 +++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/plugins/Friendly.py b/plugins/Friendly.py index 69c6f953c..0093f28be 100755 --- a/plugins/Friendly.py +++ b/plugins/Friendly.py @@ -35,16 +35,26 @@ Just a regexp module to make the bot a wee bit friendlier. import plugins +import debug +import ircutils import callbacks class Friendly(callbacks.PrivmsgRegexp): onlyFirstMatch = True 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]: s = 'howdy, %s :)' % msg.nick 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): r"(?:good)?bye|adios|vale|ciao|au revoir|seeya|night$" if irc.nick in msg.args[1]: diff --git a/test/test_Friendly.py b/test/test_Friendly.py index d78f3c3c8..efa2c86d8 100644 --- a/test/test_Friendly.py +++ b/test/test_Friendly.py @@ -40,6 +40,7 @@ class FriendlyTestCase(PluginTestCase): def testGreet(self): self.assertNotError('heya, %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.assertNotRegexp('hi, %s' % self.irc.nick, '^%s: ' % self.irc.nick) @@ -58,6 +59,14 @@ class FriendlyTestCase(PluginTestCase): self.assertNotRegexp('thanks, %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: