improve help
parent
91bbc64f2c
commit
b50a12dd55
|
@ -7,41 +7,49 @@ Licensed under the Eiffel Forum License 2.
|
||||||
http://inamidst.com/phenny/
|
http://inamidst.com/phenny/
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def doc(phenny, input):
|
|
||||||
"""Shows a command's documentation, and possibly an example."""
|
|
||||||
name = input.group(1)
|
|
||||||
name = name.lower()
|
|
||||||
|
|
||||||
if name in phenny.doc:
|
def help(phenny, input):
|
||||||
phenny.reply(phenny.doc[name][0])
|
command = input.group(2)
|
||||||
if phenny.doc[name][1]:
|
|
||||||
phenny.say('e.g. ' + phenny.doc[name][1])
|
|
||||||
doc.rule = ('$nick', '(?i)(?:help|doc) +([A-Za-z]+)(?:\?+)?$')
|
|
||||||
doc.example = '$nickname: doc tell?'
|
|
||||||
doc.priority = 'low'
|
|
||||||
|
|
||||||
def commands(phenny, input):
|
# work out a help URL to display
|
||||||
# This function only works in private message
|
if hasattr(phenny.config, 'helpurl'):
|
||||||
if input.sender.startswith('#'): return
|
helpurl = phenny.config.helpurl
|
||||||
names = ', '.join(sorted(phenny.doc.keys()))
|
else:
|
||||||
phenny.say('Commands I recognise: ' + names + '.')
|
helpurl = "https://vtluug.org/wiki/Wadsworth"
|
||||||
phenny.say(("For help, do '%s: help example?' where example is the " +
|
|
||||||
"name of the command you want help for.") % phenny.nick)
|
|
||||||
commands.commands = ['commands']
|
|
||||||
commands.priority = 'low'
|
|
||||||
|
|
||||||
def help(phenny, input):
|
if input.sender.startswith('#'):
|
||||||
response = (
|
# channels get a brief message instead
|
||||||
"Hey there, I'm a friendly bot for this channel. Say \".commands\" " +
|
phenny.say(
|
||||||
"to me in private for a list of my commands or check out my wiki " +
|
"Hey there, I'm a friendly bot for this channel. Say \".help\" "
|
||||||
"page at %s. My owner is %s."
|
"to me in private for a list of my commands or check out my help "
|
||||||
) % (phenny.config.helpurl, phenny.config.owner)
|
"page at {helpurl}.".format(
|
||||||
#phenny.reply(response)
|
helpurl=helpurl,
|
||||||
phenny.say(response)
|
owner=phenny.config.owner))
|
||||||
#help.rule = ('$nick', r'(?i)help(?:[?!]+)?$')
|
elif command is not None:
|
||||||
help.commands = ['help']
|
command = command.lower()
|
||||||
|
if command in phenny.doc:
|
||||||
|
phenny.say(phenny.doc[command][0])
|
||||||
|
if phenny.doc[command][1]:
|
||||||
|
phenny.say('e.g. ' + phenny.doc[command][1])
|
||||||
|
else:
|
||||||
|
phenny.say("Sorry, I'm not that kind of bot.")
|
||||||
|
else:
|
||||||
|
commands = ', '.join(sorted(phenny.doc.keys()))
|
||||||
|
phenny.say(
|
||||||
|
"Hey there, I'm a friendly bot! Here are the commands I "
|
||||||
|
"recognize: {commands}".format(commands=commands))
|
||||||
|
phenny.say(
|
||||||
|
"For help with a command, just use .help followed by the name of"
|
||||||
|
" the command, like \".help botsnack\".")
|
||||||
|
phenny.say(
|
||||||
|
"If you need additional help can check out {helpurl} or you can "
|
||||||
|
"talk to my owner, {owner}.".format(
|
||||||
|
helpurl=helpurl,
|
||||||
|
owner=phenny.config.owner))
|
||||||
|
help.rule = (['help', 'command'], r'(.*)')
|
||||||
help.priority = 'low'
|
help.priority = 'low'
|
||||||
|
|
||||||
|
|
||||||
def stats(phenny, input):
|
def stats(phenny, input):
|
||||||
"""Show information on command usage patterns."""
|
"""Show information on command usage patterns."""
|
||||||
commands = {}
|
commands = {}
|
||||||
|
@ -88,5 +96,6 @@ def stats(phenny, input):
|
||||||
stats.commands = ['stats']
|
stats.commands = ['stats']
|
||||||
stats.priority = 'low'
|
stats.priority = 'low'
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
|
if __name__ == '__main__':
|
||||||
print(__doc__.strip())
|
print(__doc__.strip())
|
||||||
|
|
Loading…
Reference in New Issue