From 43e9665ea71ff3f6caf796dc7ab1266a09ebcc5b Mon Sep 17 00:00:00 2001 From: Someone Date: Wed, 8 Dec 2021 19:38:38 +0100 Subject: [PATCH] [somebot] /join-all --- modules/CommandJoinAll.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 modules/CommandJoinAll.py diff --git a/modules/CommandJoinAll.py b/modules/CommandJoinAll.py new file mode 100644 index 0000000..2c03839 --- /dev/null +++ b/modules/CommandJoinAll.py @@ -0,0 +1,28 @@ +# Mattermost Bot module. +# Copyright (c) 2016-2021 by Someone (aka. Jan Vales ) +# Copyright (c) 2020 by lavish ("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)) -- 2.43.0