瀏覽代碼

Implement do_help().

tags/v0.1^2
Ben Kurtovic 12 年之前
父節點
當前提交
776bbb6dc7
共有 1 個文件被更改,包括 25 次插入0 次删除
  1. +25
    -0
      earwigbot/commands/notes.py

+ 25
- 0
earwigbot/commands/notes.py 查看文件

@@ -39,6 +39,7 @@ class Notes(Command):

def process(self, data):
commands = {
"help": self.do_help,
"list": self.do_list,
"read": self.do_read,
"edit": self.do_edit,
@@ -59,6 +60,30 @@ class Notes(Command):
msg = "Unknown subcommand: \x0303{0}\x0F.".format(command)
self.reply(data, msg)

def do_help(self, data):
"""Get help on a subcommand."""
help = {
"help": "Get help on other subcommands.",
"list": "List existing entries."
"read": "Read an existing entry ('!notes read [name]')."
"edit": "Modify or create a new entry ('!notes edit name [entry content]...')."
"info": "Get information on an existing entry ('!notes info [name]')."
"rename": "Rename an existing entry ('!notes rename [old_name] [new_name]')."
"delete": "Delete an existing entry ('!notes delete [name]')."
}

try:
command = data.args[1]
except IndexError:
self.reply(data, "Please specify a subcommand to get help on.")
return
try:
prefix = "\x0303{0}\x0F: ".format(command)
self.reply(data, prefix + help[command])
except KeyError:
msg = "Unknown subcommand: \x0303{0}\x0F.".format(command)
self.reply(data, msg)

def do_list(self, data):
"""Show a list of entries in the notes database."""
query = "SELECT entry_title FROM entries"


Loading…
取消
儲存