2 # Copyright (c) 2016-2022 by Someone <someone@somenet.org> (aka. Jan Vales <jan@jvales.net>)
4 # published under MIT-License
7 from inspect import cleandoc
9 # pylint: disable=wrong-import-position
10 from AbstractCommand import AbstractCommand
11 class CoreCommandUse(AbstractCommand):
13 CONFIG = {"display_name": "somebot-command", "auto_complete": True,
14 "auto_complete_hint": "[<feature>]",
16 CONFIG["auto_complete_desc"] = CONFIG["description"] = AbstractCommand.ICON_PUBLIC+"Display a hint (how) to use a feature."
17 USEINFO = cleandoc("""
18 ``/use [<topic>]`` can be used to retrieve information about features this :mattermost: and/or :robot: instance offers.
19 It can also be used to hint somebody that they are not using a commonly used feature (correctly). :)
24 Mattermost supports TeX math:
27 g_2(n) = n^2 \\cdot \\sqrt[3]{n^6 - 1}
32 g_2(n) = n^2 \\cdot \\sqrt[3]{n^6 - 1}
35 "threads": cleandoc("""
36 Mattermost supports threads. They make communication way more overseeable and structured.
37 We all <3 to use threads. You too, even if you dont know it yet. :)
38 You can open the thread-view with shift+up or by clicking the small arrow to the right on a post.
39 If you see a repeated offender, consider using ``/use threads`` or ``/threads`` with its many parameters.
44 def on_register(self):
45 self.bot.USETOPICS.update(self.TOPICS)
46 self._create_slash_command()
49 def on_POST(self, request, data):
50 topic = data["text"].strip()
54 pprint.pprint(self.bot.USETOPICS)
55 request.respond_cmd_chan("Debug info dumped to stdout.")
58 msg = "``\n+ ``/use ".join([t for t in sorted(self.bot.USETOPICS.keys())])
59 request.respond_cmd_chan("#### ``Did you know...``\nYou can use ``/use <topic>`` to display a helpful message about a feature of this instance. Known topics are:\n+ ``/use "+msg+"``")
61 elif topic not in self.bot.USETOPICS:
62 request.respond_cmd_chan("#### Did you know that this bot doesnt know anything about: ``"+topic+"``?\nIf this is important, contact @someone")
65 request.respond_cmd_chan("#### ``Did you know...``\n"+self.bot.USETOPICS[topic]+"\n``/use "+topic+"``")