matrix-bot/matrix_bot/plugins/help.py

28 lines
861 B
Python
Raw Normal View History

2020-08-06 17:16:43 +02:00
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)