[somebot] /join-all
authorSomeone <someone@somenet.org>
Wed, 8 Dec 2021 18:38:38 +0000 (19:38 +0100)
committerSomeone <someone@somenet.org>
Wed, 8 Dec 2021 18:38:38 +0000 (19:38 +0100)
modules/CommandJoinAll.py [new file with mode: 0644]

diff --git a/modules/CommandJoinAll.py b/modules/CommandJoinAll.py
new file mode 100644 (file)
index 0000000..2c03839
--- /dev/null
@@ -0,0 +1,28 @@
+# Mattermost Bot module.
+#  Copyright (c) 2016-2021 by Someone <someone@somenet.org> (aka. Jan Vales <jan@jvales.net>)
+#  Copyright (c) 2020 by lavish <marco.squarcina@tuwien.ac.at> ("Typos" fixed)
+#  published under MIT-License
+
+
+
+from AbstractCommand import AbstractCommand
+class CommandJoinAll(AbstractCommand):
+    TRIGGER = "join-all"
+    CONFIG = {"display_name": "somebot-command", "auto_complete": True}
+    USEINFO = CONFIG["auto_complete_desc"] = CONFIG["description"] = "Join all public channels in this team. There is no undo."
+
+
+    def __init__(self, team_id, skip_chann_ids):
+        super().__init__(team_id)
+
+        self.skip_chann_ids = skip_chann_ids
+
+
+    def on_POST(self, request, data):
+        msg = ""
+        for c in self.bot.api.get_team_channels(self.TEAM_ID):
+            if not c["id"] in self.skip_chann_ids:
+                self.bot.api.add_user_to_channel(c["id"], data["user_id"])
+                msg += "\n + ~"+c["name"]
+
+        request.cmd_respond_text_temp("### ``Done`` :)\nYou joined all the public channels in the team:\n{}\nA reload might be needed to display the updated list of channels".format(msg))