소스 검색

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"


불러오는 중...
취소
저장