Changed to use callbacks.reply again, now that we have the prefixName option.

This commit is contained in:
Jeremy Fincher 2003-09-08 08:50:57 +00:00
parent 9d8aa07f86
commit 43fbbb9b70
2 changed files with 13 additions and 7 deletions

View File

@ -41,30 +41,30 @@ import ircmsgs
import ircutils
import callbacks
def reply(msg, s):
return ircmsgs.privmsg(ircutils.replyTo(msg), s)
class Friendly(callbacks.PrivmsgRegexp):
def greet(self, irc, msg, match):
r"(?:heya?|(?:w(?:hat'?s\b|as)s?up)|howdy|hi|hello)"
if irc.nick in msg.args[1]:
irc.queueMsg(reply(msg, 'howdy, %s :)' % msg.nick))
s = 'howdy, %s :)' % msg.nick
irc.queueMsg(callbacks.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]:
irc.queueMsg(reply(msg, 'seeya, %s!' % msg.nick))
s = 'seeya, %s!' % msg.nick
irc.queueMsg(callbacks.reply(msg, s, prefixName=False))
def exclaim(self, irc, msg, match):
r"^([^\s]+)!"
if match.group(1) == irc.nick:
irc.queueMsg(reply(msg, '%s!' % msg.nick))
s = msg.nick + '!'
irc.queueMsg(callbacks.reply(msg, s, prefixName=False))
def beGracious(self, irc, msg, match):
r"\b(?:thank'?s?|thx|tnks?)\b"
if irc.nick in msg.args[1]:
s = 'you\'re welcome, %s' % msg.nick
irc.queueMsg(reply(msg, s))
irc.queueMsg(callbacks.reply(msg, s, prefixName=False))
Class = Friendly

View File

@ -41,16 +41,22 @@ class FriendlyTestCase(PluginTestCase):
self.assertNotError('heya, %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)
def testGoodbye(self):
self.assertNotError('seeya %s!' % self.irc.nick)
self.assertNotError('bye, %s.' % self.irc.nick)
self.assertNotRegexp('bye, %s' % self.irc.nick,
'^%s: ' % self.irc.nick)
def testBeGracious(self):
self.assertNotError('thanks, %s' % self.irc.nick)
self.assertNotError('thank you, %s' % self.irc.nick)
self.assertNotError('thx %s' % self.irc.nick)
self.assertNotError('%s: thx!' % self.irc.nick)
self.assertNotRegexp('thanks, %s' % self.irc.nick,
'^%s: ' % self.irc.nick)