From 0aa19085fbe1fb0d14bff443b174011c0da1e506 Mon Sep 17 00:00:00 2001 From: CMDR furrycat Date: Thu, 29 Sep 2016 10:47:28 +0100 Subject: [PATCH] Make waking up optional. --- bot.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bot.py b/bot.py index 7af9c0f..22c08d6 100755 --- a/bot.py +++ b/bot.py @@ -127,19 +127,23 @@ def zzz(): break @asyncio.coroutine -def maybe_say(channel, text, probability = 0.2): +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) - yield from wake_up() + if wake: + yield from wake_up() return True else: log.debug("Didn't bother to say {}".format(text)) return False @asyncio.coroutine -def say(channel, text): - yield from maybe_say(channel, text, 1.0) +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 @asyncio.coroutine -- 2.7.4