From 432fa3962ce1078740abaa3d97fed768cf13f48b Mon Sep 17 00:00:00 2001 From: Someone Date: Fri, 19 Jun 2020 01:32:13 +0200 Subject: [PATCH] [somebot] /ta-announce --- somebot/modules/TACommandAnnounce.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 somebot/modules/TACommandAnnounce.py diff --git a/somebot/modules/TACommandAnnounce.py b/somebot/modules/TACommandAnnounce.py new file mode 100644 index 0000000..8c35d53 --- /dev/null +++ b/somebot/modules/TACommandAnnounce.py @@ -0,0 +1,26 @@ +# Mattermost Bot. +# Copyright (c) 2016-2020 by Someone (aka. Jan Vales ) +# published under MIT-License + + + +from AbstractCommand import * +class TACommandAnnounce(AbstractCommand): + TRIGGER = "ta-announce" + CONFIG = {"display_name": "somebot-command", "auto_complete": True, + "auto_complete_hint": "", + } + CONFIG["auto_complete_desc"] = CONFIG["description"] = "Posts into the current team\"s announcement channel. [TEAM_ADMIN]" + + + def on_POST(self, request, data): + user = self.bot.api.get_team_member(data["team_id"], data["user_id"]) + if "team_admin" not in user["roles"]: + request.cmd_respond_text_temp("### You are not a Team Admin. :(") + return + + channel = self.bot.api.get_channel_by_name(data["team_id"], "town-square") + self.bot.api.create_post(channel["id"], data["text"]) + + request.cmd_respond_text_temp("### ``Done.`` :)") + -- 2.43.0