]> git.somenet.org - pub/jan/mattermost.git/blob - somebot/modules/CommandJoinAll.py
[somebot] requirements.txt for all modules.
[pub/jan/mattermost.git] / somebot / modules / CommandJoinAll.py
1 # Mattermost Bot.
2 #  Copyright (c) 2016-2020 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
5
6
7
8 from AbstractCommand import *
9 class CommandJoinAll(AbstractCommand):
10     TRIGGER = "join-all"
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."
13
14
15     def on_POST(self, request, data):
16         msg = ""
17         for c in self.bot.api.get_team_channels(self.TEAM_ID):
18             self.bot.api.add_user_to_channel(c["id"], data["user_id"])
19             msg += "\n + ~"+c["name"]
20
21         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))
22