diff --git a/src/callbacks.py b/src/callbacks.py index 05d439627..8316f7e13 100644 --- a/src/callbacks.py +++ b/src/callbacks.py @@ -430,7 +430,11 @@ class IrcObjectProxy: if isinstance(self.irc, self.__class__): self.irc.error(msg, s) else: - self.irc.queueMsg(reply(msg, 'Error: ' + s)) + s = 'Error: ' + s + if conf.errorReplyPrivate: + self.irc.queueMsg(ircmsgs.privmsg(msg.nick, s)) + else: + self.irc.queueMsg(reply(msg, s)) def killProxy(self): if not isinstance(self.irc, irclib.Irc): diff --git a/test/test_callbacks.py b/test/test_callbacks.py index 40380ca83..2de07269e 100644 --- a/test/test_callbacks.py +++ b/test/test_callbacks.py @@ -160,5 +160,24 @@ class PrivmsgTestCase(ChannelPluginTestCase): self.assertResponse("eval irc.reply(msg, 'foo', action=True)", '\x01ACTION foo\x01') + def testErrorReplyPrivate(self): + try: + originalConfErrorReplyPrivate = conf.errorReplyPrivate + conf.errorReplyPrivate = False + # If this doesn't raise an error, we've got a problem, so the next + # two assertions shouldn't run. So we first check that what we + # expect to error actually does so we don't go on a wild goose + # chase because our command never errored in the first place :) + s = 're s/foo/bar baz' # will error; should be "re s/foo/bar/ baz" + self.assertError(s) + m = self.getMsg(s) + self.failUnless(ircutils.isChannel(m.args[0])) + conf.errorReplyPrivate = True + m = self.getMsg(s) + self.failIf(ircutils.isChannel(m.args[0])) + finally: + conf.errorReplyPrivate = originalConfErrorReplyPrivate + + # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: