1 # Mattermost Bot module.
2 # Copyright (c) 2016-2021 by Someone <someone@somenet.org> (aka. Jan Vales <jan@jvales.net>)
3 # Copyright (c) 2020 by lavish <marco.squarcina@tuwien.ac.at> ("Typos" fixed)
4 # published under MIT-License
8 from AbstractCommand import AbstractCommand
9 class CommandJoinAll(AbstractCommand):
11 CONFIG = {"display_name": "somebot-command", "auto_complete": True}
12 USEINFO = CONFIG["auto_complete_desc"] = CONFIG["description"] = "Join all public channels in this team. There is no undo."
15 def __init__(self, team_id, skip_chann_ids):
16 super().__init__(team_id)
18 self.skip_chann_ids = skip_chann_ids
21 def on_POST(self, request, data):
23 for c in self.bot.api.get_team_channels(self.TEAM_ID):
24 if not c["id"] in self.skip_chann_ids:
25 self.bot.api.add_user_to_channel(c["id"], data["user_id"])
26 msg += "\n + ~"+c["name"]
28 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))