Procházet zdrojové kódy

Implement do_help().

tags/v0.1^2
Ben Kurtovic před 12 roky
rodič
revize
776bbb6dc7
1 změnil soubory, kde provedl 25 přidání a 0 odebrání
  1. +25
    -0
      earwigbot/commands/notes.py

+ 25
- 0
earwigbot/commands/notes.py Zobrazit soubor

@@ -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"


Načítá se…
Zrušit
Uložit