Added conf.replyWhenNotAddressed for RFE #859183.

This commit is contained in:
Jeremy Fincher 2003-12-17 13:22:21 +00:00
parent eca71949b4
commit bbafb4294e
3 changed files with 22 additions and 0 deletions

View File

@ -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 ''

View File

@ -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

View File

@ -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)