From 2fe84a3474833743ae88d19ef4899c7cac560a06 Mon Sep 17 00:00:00 2001 From: ddan39 Date: Sat, 17 Jan 2015 07:13:30 +0100 Subject: [PATCH] add usesendMsg=False to irc.reply() to use sendMsg() instead of queueMsg() --- src/callbacks.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/callbacks.py b/src/callbacks.py index 5cdad5d04..36e55bc00 100644 --- a/src/callbacks.py +++ b/src/callbacks.py @@ -836,8 +836,8 @@ class NestedCommandsIrcProxy(ReplyIrcProxy): else: cb._callCommand(command, self, self.msg, args) - def reply(self, s, noLengthCheck=False, prefixNick=None, - action=None, private=None, notice=None, to=None, msg=None): + def reply(self, s, noLengthCheck=False, prefixNick=None, action=None, + private=None, notice=None, to=None, msg=None, usesendMsg=False): """ Keyword arguments: @@ -851,6 +851,8 @@ class NestedCommandsIrcProxy(ReplyIrcProxy): bot is configured to do so. * `to=`: The nick or channel the reply should go to. Defaults to msg.args[0] (or msg.nick if private) + * `usesendMsg=False`: True if the reply should be sent + using sendMsg instead of queueMsg """ # These use and or or based on whether or not they default to True or # False. Those that default to True use and; those that default to @@ -858,6 +860,10 @@ class NestedCommandsIrcProxy(ReplyIrcProxy): assert not isinstance(s, ircmsgs.IrcMsg), \ 'Old code alert: there is no longer a "msg" argument to reply.' self.repliedTo = True + if usesendMsg: + sendMsg = self.irc.sendMsg + else: + sendMsg = self.irc.queueMsg if msg is None: msg = self.msg if prefixNick is not None: @@ -895,7 +901,7 @@ class NestedCommandsIrcProxy(ReplyIrcProxy): action=self.action, private=self.private, prefixNick=self.prefixNick) - self.irc.queueMsg(m) + sendMsg(m) return m else: s = ircutils.safeArgument(s) @@ -928,7 +934,7 @@ class NestedCommandsIrcProxy(ReplyIrcProxy): notice=self.notice, private=self.private, prefixNick=self.prefixNick) - self.irc.queueMsg(m) + sendMsg(m) return m msgs = ircutils.wrap(s, allowedLength, break_long_words=True) @@ -941,7 +947,7 @@ class NestedCommandsIrcProxy(ReplyIrcProxy): notice=self.notice, private=self.private, prefixNick=self.prefixNick) - self.irc.queueMsg(m) + sendMsg(m) # XXX We should somehow allow these to be returned, but # until someone complains, we'll be fine :) We # can't return from here, though, for obvious @@ -974,7 +980,7 @@ class NestedCommandsIrcProxy(ReplyIrcProxy): notice=self.notice, private=self.private, prefixNick=self.prefixNick) - self.irc.queueMsg(m) + sendMsg(m) return m finally: self._resetReplyAttributes()