Return message after successful post.
authorCMDR furrycat <elite@furrycat.net>
Mon, 3 Oct 2016 21:11:40 +0000 (22:11 +0100)
committerCMDR furrycat <elite@furrycat.net>
Mon, 3 Oct 2016 21:11:40 +0000 (22:11 +0100)
bot.py

diff --git a/bot.py b/bot.py
index d43c0af..c043443 100755 (executable)
--- 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):