1 # Mattermost Bot module.
2 # Copyright (c) 2016-2022 by Someone <someone@somenet.org> (aka. Jan Vales <jan@jvales.net>)
3 # published under MIT-License
8 from AbstractCommand import AbstractCommand
9 class CommandRandomFoodSource(AbstractCommand):
10 TRIGGER = "randomFood"
11 CONFIG = {"display_name": "somebot-command", "auto_complete": True,
12 "auto_complete_hint": "",
14 USEINFO = CONFIG["auto_complete_desc"] = CONFIG["description"] = "Suggest a random food source."
17 def __init__(self, team_id, channel_id):
18 super().__init__(team_id)
19 self.channel_id = channel_id
22 def on_POST(self, request, data):
23 pinned_posts = self.bot.api.get_channel_posts_pinned(self.channel_id)["posts"]
24 rnd_post_url = ":arrow_right: https://mattermost.fsinf.at/fsinf/pl/"+random.choice(list(pinned_posts.keys()))
25 request.cmd_respond_text_temp("# You eat here\n"+rnd_post_url)