add usesendMsg=False to irc.reply() to use sendMsg() instead of queueMsg()

This commit is contained in:
ddan39 2015-01-17 07:13:30 +01:00
parent c58399730b
commit 2fe84a3474
1 changed files with 12 additions and 6 deletions

View File

@ -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=<nick|channel>`: 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()