From 22bd434549fc96273fcfde99ff94f3d7a0257281 Mon Sep 17 00:00:00 2001
From: Tamas Gal <tgal@km3net.de>
Date: Fri, 4 Oct 2019 18:07:22 +0200
Subject: [PATCH] Allow controlling the monitoring system

---
 scripts/chatbot.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/scripts/chatbot.py b/scripts/chatbot.py
index 6c6470c..a0b95ac 100644
--- a/scripts/chatbot.py
+++ b/scripts/chatbot.py
@@ -83,6 +83,16 @@ def register_handlers(bot):
             ['supervisorctl', 'status']).decode('ascii') + "\n```"
         bot.send_message(status, channel_id)
 
+    def supervisorctl(msg, user, channel_id):
+        if not is_shifter(user) and not is_operator(user):
+            bot.send_message(
+                "Sorry @{}, only operators and shifters are allowed to mess "
+                "with me, sorry...".format(user), channel_id)
+            return
+        output = subprocess.check_output(['supervisorctl'] +
+                                         msg.split()).decode('ascii')
+        bot.send_message(output, channel_id)
+
     def shifters(msg, user, channel_id):
         if channel_id != CHANNEL_ID:
             print("skipping")
-- 
GitLab