--- /dev/null
+# Mattermost Bot module.
+# Copyright (c) 2016-2021 by Someone <someone@somenet.org> (aka. Jan Vales <jan@jvales.net>)
+# published under MIT-License
+
+
+
+from AbstractCommand import *
+class TACommandAnnounceAll(AbstractCommand):
+ TRIGGER = "ta-announce-all"
+ CONFIG = {"display_name": "somebot-command", "auto_complete": True,
+ "auto_complete_hint": "<text>",
+ }
+ CONFIG["auto_complete_desc"] = CONFIG["description"] = "Posts <text> into every teams' announcement channel where the poster is a TA. [TEAM_ADMIN]"
+
+
+ def on_POST(self, request, data):
+ posted_to = ""
+
+ for t in self.bot.api.get_teams():
+ user = self.bot.api.get_team_member(t["id"], data["user_id"], exc=False)
+
+ if "roles" in user and "team_admin" in user["roles"]:
+ channel = self.bot.api.get_channel_by_name(t["id"], "town-square")
+ self.bot.api.create_post(channel["id"], data["text"])
+ posted_to += "\n+ "+t["name"]
+
+ if posted_to != "":
+ request.cmd_respond_text_temp("### ``Done.`` :)\n\nPosted to:"+posted_to)
+ else:
+ request.cmd_respond_text_temp("### ``Done.`` :(\n\nDid not post anything. Are you a Team-Admin anywhere?")