A few tweaks to plugins: weather.py now uses web.query for YQL, spellcheck.py has some renamed variables and uses new string formatting, choose.py has a nicer fail message.
This commit is contained in:
parent
de67aad764
commit
5f0d5f62a2
3 changed files with 13 additions and 17 deletions
|
@ -1,11 +1,10 @@
|
|||
import re
|
||||
import enchant
|
||||
from util import hook
|
||||
|
||||
locale = "en_US"
|
||||
|
||||
|
||||
@hook.command("spellcheck")
|
||||
@hook.command
|
||||
def spell(inp):
|
||||
"spell <word> -- Check spelling of <word>."
|
||||
|
||||
|
@ -13,16 +12,16 @@ def spell(inp):
|
|||
return "This command only supports one word at a time."
|
||||
|
||||
if not enchant.dict_exists(locale):
|
||||
return "Could not find dictionary: %s" % locale
|
||||
return "Could not find dictionary: {}".format(locale)
|
||||
|
||||
dict = enchant.Dict(locale)
|
||||
is_correct = dict.check(inp)
|
||||
suggestions = dict.suggest(inp)
|
||||
dictionary = enchant.Dict(locale)
|
||||
is_correct = dictionary.check(inp)
|
||||
suggestions = dictionary.suggest(inp)
|
||||
s_string = ', '.join(suggestions[:10])
|
||||
|
||||
if is_correct:
|
||||
return '"%s" appears to be \x02valid\x02! ' \
|
||||
'(suggestions: %s)' % (inp, s_string)
|
||||
return '"{}" appears to be \x02valid\x02! ' \
|
||||
'(suggestions: {})'.format(inp, s_string)
|
||||
else:
|
||||
return '"%s" appears to be \x02invalid\x02! ' \
|
||||
'(suggestions: %s)' % (inp, s_string)
|
||||
return '"{}" appears to be \x02invalid\x02! ' \
|
||||
'(suggestions: {})'.format(inp, s_string)
|
||||
|
|
Reference in a new issue