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:
|
|
||||||
phenny.reply(phenny.doc[name][0])
|
|
||||||
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):
|
|
||||||
# This function only works in private message
|
|
||||||
if input.sender.startswith('#'): return
|
|
||||||
names = ', '.join(sorted(phenny.doc.keys()))
|
|
||||||
phenny.say('Commands I recognise: ' + names + '.')
|
|
||||||
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):
|
def help(phenny, input):
|
||||||
response = (
|
command = input.group(2)
|
||||||
"Hey there, I'm a friendly bot for this channel. Say \".commands\" " +
|
|
||||||
"to me in private for a list of my commands or check out my wiki " +
|
# work out a help URL to display
|
||||||
"page at %s. My owner is %s."
|
if hasattr(phenny.config, 'helpurl'):
|
||||||
) % (phenny.config.helpurl, phenny.config.owner)
|
helpurl = phenny.config.helpurl
|
||||||
#phenny.reply(response)
|
else:
|
||||||
phenny.say(response)
|
helpurl = "https://vtluug.org/wiki/Wadsworth"
|
||||||
#help.rule = ('$nick', r'(?i)help(?:[?!]+)?$')
|
|
||||||
help.commands = ['help']
|
if input.sender.startswith('#'):
|
||||||
|
# channels get a brief message instead
|
||||||
|
phenny.say(
|
||||||
|
"Hey there, I'm a friendly bot for this channel. Say \".help\" "
|
||||||
|
"to me in private for a list of my commands or check out my help "
|
||||||
|
"page at {helpurl}.".format(
|
||||||
|
helpurl=helpurl,
|
||||||
|
owner=phenny.config.owner))
|
||||||
|
elif command is not None:
|
||||||
|
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