Make waking up optional.
authorCMDR furrycat <elite@furrycat.net>
Thu, 29 Sep 2016 09:47:28 +0000 (10:47 +0100)
committerCMDR furrycat <elite@furrycat.net>
Thu, 29 Sep 2016 09:51:17 +0000 (10:51 +0100)
bot.py

diff --git a/bot.py b/bot.py
index 7af9c0f..22c08d6 100755 (executable)
--- 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