32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
|
|
from plugins.plugin import Plugin
|
|
|
|
|
|
class Help(Plugin):
|
|
def activate(self):
|
|
super(Help, self).activate()
|
|
|
|
def deactivate(self):
|
|
super(Help, self).deactivate()
|
|
|
|
@Plugin.command()
|
|
def help(self, room, event, args):
|
|
"""Show list of commands (or only CMD) doc => !help [CMD]"""
|
|
command_names = []
|
|
if len(args) >= 1:
|
|
help_command = ' '.join(args)
|
|
if help_command[0] != '!':
|
|
help_command = '!' + help_command
|
|
if help_command in self.plugin_manager.commands.keys():
|
|
command_names = [help_command]
|
|
if not command_names:
|
|
command_names = self.plugin_manager.commands.keys()
|
|
reply = ['Usage:']
|
|
for command_name in command_names:
|
|
command = self.plugin_manager.commands[command_name]
|
|
if not self.plugin_manager.is_admin_command(command_name) or self.plugin_manager.is_sender_admin(msg):
|
|
reply.append('{0}: {1}'.format(command_name, command['function'].__doc__ or 'N/A'))
|
|
room.send_text("\n".join(reply))
|
|
return True
|