diff --git a/src/callbacks.py b/src/callbacks.py index b7195d6c0..8c967dfbb 100644 --- a/src/callbacks.py +++ b/src/callbacks.py @@ -92,6 +92,8 @@ def addressed(nick, msg): return '' elif msg.args[1] and msg.args[1][0] in conf.prefixChars: return msg.args[1][1:].strip() + elif conf.replyWhenNotAddressed: + return msg.args[1] else: return '' diff --git a/src/conf.py b/src/conf.py index 79cea501a..476314d34 100644 --- a/src/conf.py +++ b/src/conf.py @@ -140,6 +140,14 @@ replyWithNickPrefix = True ### replyWhenAddressedByNick = True +### +# replyWhenNotAddressed: True if the bot should reply to messages even if they +# don't address it at all. If you have this on, you'll +# almost certainly want to make sure replyWhenNotCommand +# is turned off. +### +replyWhenNotAddressed = False + ### # requireRegistration: Oftentimes a plugin will want to record who added or # changed or messed with it last. Supybot's user database diff --git a/test/test_callbacks.py b/test/test_callbacks.py index 203e36252..2fd853de8 100644 --- a/test/test_callbacks.py +++ b/test/test_callbacks.py @@ -151,6 +151,18 @@ class FunctionsTestCase(unittest.TestCase): badmsg = ircmsgs.privmsg('#foo', '%s`: foo' % nick) self.failIf(callbacks.addressed(nick, badmsg)) + def testAddressedReplyWhenNotAddressed(self): + msg1 = ircmsgs.privmsg('#foo', '@bar') + msg2 = ircmsgs.privmsg('#foo', 'bar') + self.assertEqual(callbacks.addressed('blah', msg1), 'bar') + try: + original = conf.replyWhenNotAddressed + conf.replyWhenNotAddressed = True + self.assertEqual(callbacks.addressed('blah', msg1), 'bar') + self.assertEqual(callbacks.addressed('blah', msg2), 'bar') + finally: + conf.replyWhenNotAddressed = original + def testReply(self): prefix = 'foo!bar@baz' channelMsg = ircmsgs.privmsg('#foo', 'bar baz', prefix=prefix)