From: CMDR furrycat Date: Mon, 3 Oct 2016 21:11:40 +0000 (+0100) Subject: Return message after successful post. X-Git-Url: http://git.furryclan.net/?a=commitdiff_plain;h=f6e8ae9187d97cb5df85dd26937eb632c4e44f02;p=furrycat%2Fcatbot.git Return message after successful post. --- diff --git a/bot.py b/bot.py index d43c0af..c043443 100755 --- a/bot.py +++ b/bot.py @@ -172,29 +172,30 @@ def zzz(): def maybe_say(channel, text, *, probability = 0.2, wake = True): if random.random() <= probability: yield from client.send_typing(channel) - yield from client.send_message(channel, text) + message = yield from client.send_message(channel, text) if wake: yield from wake_up() - return True + return message else: log.debug("Didn't bother to say {}".format(text)) - return False + return None @asyncio.coroutine def say(channel, text, *, wake = None): args = { 'probability': 1.0 } if wake is not None: args['wake'] = wake - yield from maybe_say(channel, text, **args) - return True + message = yield from maybe_say(channel, text, **args) + return message @asyncio.coroutine def say_expect(message, stdout): if stdout: log.debug(stdout) - yield from say(message.channel, '{}```{}```'.format('{} '.format(message.author.mention) if not message.channel.is_private else '', stdout)) + result = yield from say(message.channel, '{}```{}```'.format('{} '.format(message.author.mention) if not message.channel.is_private else '', stdout)) else: - yield from say(message.channel, 'Sorry!') + result = yield from say(message.channel, 'Sorry!') + return result @asyncio.coroutine def not_admin(message):