report options when given ambiguous command, make .dict report which word the definition is for
This commit is contained in:
parent
3e9708cc79
commit
b0259336cd
|
@ -129,6 +129,8 @@ def match_command(command):
|
||||||
prefix = filter(lambda x: x.startswith(command), commands)
|
prefix = filter(lambda x: x.startswith(command), commands)
|
||||||
if len(prefix) == 1:
|
if len(prefix) == 1:
|
||||||
return prefix[0]
|
return prefix[0]
|
||||||
|
elif prefix:
|
||||||
|
return prefix
|
||||||
|
|
||||||
return command
|
return command
|
||||||
|
|
||||||
|
@ -156,7 +158,11 @@ def main(conn, out):
|
||||||
trigger = m.group(1).lower()
|
trigger = m.group(1).lower()
|
||||||
command = match_command(trigger)
|
command = match_command(trigger)
|
||||||
|
|
||||||
if command in bot.commands:
|
if isinstance(command, list): # multiple potential matches
|
||||||
|
input = Input(conn, *out)
|
||||||
|
input.reply("did you mean %s or %s?" %
|
||||||
|
(', '.join(command[:-1]), command[-1]))
|
||||||
|
elif command in bot.commands:
|
||||||
input = Input(conn, *out)
|
input = Input(conn, *out)
|
||||||
input.trigger = trigger
|
input.trigger = trigger
|
||||||
input.inp_unstripped = m.group(2)
|
input.inp_unstripped = m.group(2)
|
||||||
|
|
|
@ -43,11 +43,11 @@ def define(inp):
|
||||||
return 'No results for ' + inp
|
return 'No results for ' + inp
|
||||||
|
|
||||||
def format_output(show_examples):
|
def format_output(show_examples):
|
||||||
result = ''
|
result = '%s: ' % h.xpath('//dt[@class="title-word"]/a/text()')[0]
|
||||||
|
|
||||||
correction = h.xpath('//span[@class="correct-word"]')
|
correction = h.xpath('//span[@class="correct-word"]/text()')
|
||||||
if correction:
|
if correction:
|
||||||
result = 'definition for "%s": ' % correction[0].text
|
result = 'definition for "%s": ' % correction[0]
|
||||||
|
|
||||||
sections = []
|
sections = []
|
||||||
for section in definition:
|
for section in definition:
|
||||||
|
|
Loading…
Reference in New Issue