a bunch of things
This commit is contained in:
parent
8317ba0920
commit
3e073c8278
2 changed files with 9 additions and 12 deletions
|
@ -14,11 +14,11 @@ def spell(inp):
|
||||||
return "Could not find dictionary: {}".format(locale)
|
return "Could not find dictionary: {}".format(locale)
|
||||||
|
|
||||||
if len(inp.split(" ")) > 1:
|
if len(inp.split(" ")) > 1:
|
||||||
|
# input is a sentence
|
||||||
chkr = SpellChecker(locale)
|
chkr = SpellChecker(locale)
|
||||||
chkr.set_text(inp)
|
chkr.set_text(inp)
|
||||||
|
|
||||||
offset = 0
|
offset = 0
|
||||||
|
|
||||||
for err in chkr:
|
for err in chkr:
|
||||||
# find the location of the incorrect word
|
# find the location of the incorrect word
|
||||||
start = err.wordpos + offset
|
start = err.wordpos + offset
|
||||||
|
@ -31,9 +31,9 @@ def spell(inp):
|
||||||
offset = (offset + len(s_string)) - len(err.word)
|
offset = (offset + len(s_string)) - len(err.word)
|
||||||
# replace the word with the suggestions
|
# replace the word with the suggestions
|
||||||
inp = inp[:start] + s_string + inp[finish:]
|
inp = inp[:start] + s_string + inp[finish:]
|
||||||
|
|
||||||
return inp
|
return inp
|
||||||
else:
|
else:
|
||||||
|
# input is a word
|
||||||
dictionary = enchant.Dict(locale)
|
dictionary = enchant.Dict(locale)
|
||||||
is_correct = dictionary.check(inp)
|
is_correct = dictionary.check(inp)
|
||||||
suggestions = dictionary.suggest(inp)
|
suggestions = dictionary.suggest(inp)
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
import random
|
from util import hook, web
|
||||||
|
|
||||||
from util import hook, http, web
|
|
||||||
|
|
||||||
|
|
||||||
@hook.command
|
@hook.command
|
||||||
|
@ -13,7 +11,7 @@ def stock(inp):
|
||||||
|
|
||||||
# if we dont get a company name back, the symbol doesn't match a company
|
# if we dont get a company name back, the symbol doesn't match a company
|
||||||
if quote['Change'] is None:
|
if quote['Change'] is None:
|
||||||
return "unknown ticker symbol %s" % inp
|
return "Unknown ticker symbol: {}".format(sym)
|
||||||
|
|
||||||
change = float(quote['Change'])
|
change = float(quote['Change'])
|
||||||
price = float(quote['LastTradePriceOnly'])
|
price = float(quote['LastTradePriceOnly'])
|
||||||
|
@ -24,10 +22,9 @@ def stock(inp):
|
||||||
quote['color'] = "3"
|
quote['color'] = "3"
|
||||||
|
|
||||||
quote['PercentChange'] = 100 * change / (price - change)
|
quote['PercentChange'] = 100 * change / (price - change)
|
||||||
|
print quote
|
||||||
|
|
||||||
ret = "\x02%(Name)s\x02 (\x02%(symbol)s\x02) - %(LastTradePriceOnly)s " \
|
return u"\x02{Name}\x02 (\x02{symbol}\x02) - {LastTradePriceOnly} " \
|
||||||
"\x03%(color)s%(Change)s (%(PercentChange).2f%%)\x03 " \
|
"\x03{color}{Change} ({PercentChange:.2f}%)\x03 " \
|
||||||
"Day Range: %(DaysRange)s " \
|
"Day Range: {DaysRange} " \
|
||||||
"MCAP: %(MarketCapitalization)s" % quote
|
"MCAP: {MarketCapitalization}".format(**quote)
|
||||||
|
|
||||||
return ret
|
|
||||||
|
|
Reference in a new issue