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):