plugins/help_plugin.py
author Mikael Berthe <mikael@lilotux.net>
Sat, 19 May 2007 15:22:09 +0200
changeset 38 a81dc352e96e
parent 17 069f7fd5545d
permissions -rw-r--r--
rss_plugin: remove trailing whitespace

#$ neutron_plugin 01

def handler_help_help(type, source, parameters):
	parameters = parameters.rstrip()
	if parameters and COMMANDS.has_key(parameters):
		reply = COMMANDS[parameters]['description'] + ' Usage: ' + COMMANDS[parameters]['syntax'] + '\nExamples:'
		for example in COMMANDS[parameters]['examples']:
			reply += '\n  *  ' + example
		reply += '\nRequired Access Level: ' + str(COMMANDS[parameters]['access'])
	else:
		reply = 'Type !commands for a list of commands.'
	smsg(type, source, reply)

def handler_help_commands(type, source, parameters):
    commandlist = []
    for command in COMMANDS.keys():
        if has_access(source, COMMANDS[command]['access']):
            commandlist.append(command)
    commandlist.sort()
    commandlist = string.join(commandlist)
    smsg('private', source, commandlist)

register_command_handler(handler_help_help, 'help', 0, 'Send basic help message or gives information on specified command.', 'help [command]', ['help', 'help help'])
register_command_handler(handler_help_commands, '!commands', 0, 'Send list of commands.', '!commands', ['!commands'])