Command to toggle dryrun.
authorCMDR furrycat <elite@furrycat.net>
Thu, 29 Sep 2016 09:18:29 +0000 (10:18 +0100)
committerCMDR furrycat <elite@furrycat.net>
Thu, 29 Sep 2016 09:19:35 +0000 (10:19 +0100)
bot.py

diff --git a/bot.py b/bot.py
index 05b1c13..7af9c0f 100755 (executable)
--- a/bot.py
+++ b/bot.py
@@ -317,6 +317,21 @@ def do_commands(message, command, raw, non_admin):
     yield from client.purge_from(message.channel, *args, limit = limit)
     return
 
+  elif command == 'dryrun':
+    # dryrun
+    m = re.match(r'\bdryrun\s+(o(?:ff|n))\b', raw.lower())
+    if m is None:
+      yield from say(message.channel, 'Sorry!')
+      return
+
+    arg = m.group(1)
+    if arg == 'on':
+      print('DRYRUN mode')
+      dryrun = True
+    elif arg == 'off':
+      print('Live mode')
+      dryrun = False
+
   elif command == 'rss':
     # rss
     m = re.match(r'\brss\s+(\d+)\b', raw.lower())
@@ -496,7 +511,7 @@ modules = {
   'admin': {
     'fn': do_commands,
     'args': [False],
-    'commands': ['avatar', 'debug', 'delete', 'rss']
+    'commands': ['avatar', 'debug', 'delete', 'dryrun', 'rss']
   },
   'any': {
     'fn': do_commands,