2 # Copyright (c) 2016-2020 by Someone <someone@somenet.org> (aka. Jan Vales <jan@jvales.net>)
4 # published under MIT-License
7 from inspect import cleandoc
9 from AbstractCommand import AbstractCommand
10 class CoreCommandUse(AbstractCommand):
12 CONFIG = {"display_name": "somebot-command", "auto_complete": True,
13 "auto_complete_hint": "[<feature>]",
15 CONFIG["auto_complete_desc"] = CONFIG["description"] = "Display a hint (how) to use a feature."
16 USEINFO = cleandoc("""
17 ``/use [<topic>]`` can be used to retrieve information features this instance offers.
18 It can also be used to hint somebody, that they are not using a commonly used feature (correctly). :)
23 Mattermost supports TeX math:
26 g_2(n) = n^2 \\cdot \\sqrt[3]{n^6 - 1}
31 g_2(n) = n^2 \\cdot \\sqrt[3]{n^6 - 1}
34 "threads": cleandoc("""
35 Mattermost supports threads. They make communication way more overseeable and structured.
36 We all <3 to use threads. You too, even if you dont know it yet. :)
37 You can open the thread-view with shift+up or by clicking the small arrow to the right on a post.
38 If you see a repeated offender, consider using ``/use threads`` or ``/threads`` with its many parameters.
43 def on_register(self):
44 self.bot.USETOPICS.update(self.TOPICS)
45 self._create_slash_command()
48 def on_POST(self, request, data):
49 topic = data["text"].strip()
53 pprint.pprint(self.bot.USETOPICS)
54 request.cmd_respond_text_chan("Debug info dumped to stdout.")
57 msg = "``\n+ ``/use ".join([t for t in sorted(self.bot.USETOPICS.keys())])
58 request.cmd_respond_text_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+"``")
60 elif topic not in self.bot.USETOPICS:
61 request.cmd_respond_text_chan("#### Did you know that this bot doesnt know anything about: ``"+topic+"``?\nIf this is important, contact @someone")
64 request.cmd_respond_text_chan("#### ``Did you know...``\n"+self.bot.USETOPICS[topic]+"\n``/use "+topic+"``")