28 lines
861 B
Python
28 lines
861 B
Python
from nio import MatrixRoom, RoomMessageText
|
|
|
|
from ..config import Config
|
|
from ..message import MarkdownMessage
|
|
from ._plugin import _Plugin
|
|
|
|
|
|
class Plugin(_Plugin):
|
|
help = 'Display this help message'
|
|
|
|
@property
|
|
def help_message(self) -> str:
|
|
prefix = Config.CHAT_PREFIX
|
|
message = ('# Help\n'
|
|
'Use the bot by starting a message with '
|
|
f'`{prefix}`\n\n'
|
|
'## Usage\n')
|
|
|
|
for plugin in self.__bot.command_plugins:
|
|
plugin = self.__bot.command_plugins[plugin]
|
|
message += f'* {prefix} {plugin.__name} - {plugin.help}\n'
|
|
return message
|
|
|
|
async def on_command(self, room: MatrixRoom,
|
|
message: RoomMessageText) -> None:
|
|
message = MarkdownMessage(self.help_message)
|
|
await message.send(self.client, room)
|