]> git.somenet.org - pub/jan/mattermost-bot.git/blob - modules/CommandRandomFoodSource.py
modules/TACommandJoinAdmins.py
[pub/jan/mattermost-bot.git] / modules / CommandRandomFoodSource.py
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
4
5 import random
6
7
8 # pylint: disable=wrong-import-position
9 from AbstractCommand import AbstractCommand
10 class CommandRandomFoodSource(AbstractCommand):
11     TRIGGER = "randomFood"
12     CONFIG = {"display_name": "somebot-command", "auto_complete": True,
13               "auto_complete_hint":  "",
14              }
15     USEINFO = CONFIG["auto_complete_desc"] = CONFIG["description"] = AbstractCommand.ICON_PRIVATE+"Suggest a random food source."
16
17
18     def __init__(self, team_id, channel_id):
19         super().__init__(team_id)
20         self.channel_id = channel_id
21
22
23     def on_POST(self, request, data):
24         pinned_posts = self.bot.api.get_channel_posts_pinned(self.channel_id)["posts"]
25         rnd_post_url = ":arrow_right: https://mattermost.fsinf.at/fsinf/pl/"+random.choice(list(pinned_posts.keys()))
26         request.respond_cmd_temp("# You eat here\n"+rnd_post_url)