diff --git a/plugins/spellcheck.py b/plugins/spellcheck.py index 7af8ab2..33265d6 100644 --- a/plugins/spellcheck.py +++ b/plugins/spellcheck.py @@ -14,11 +14,11 @@ def spell(inp): return "Could not find dictionary: {}".format(locale) if len(inp.split(" ")) > 1: + # input is a sentence chkr = SpellChecker(locale) chkr.set_text(inp) offset = 0 - for err in chkr: # find the location of the incorrect word start = err.wordpos + offset @@ -31,9 +31,9 @@ def spell(inp): offset = (offset + len(s_string)) - len(err.word) # replace the word with the suggestions inp = inp[:start] + s_string + inp[finish:] - return inp else: + # input is a word dictionary = enchant.Dict(locale) is_correct = dictionary.check(inp) suggestions = dictionary.suggest(inp) diff --git a/plugins/stock.py b/plugins/stock.py index d80fe05..73c36bc 100644 --- a/plugins/stock.py +++ b/plugins/stock.py @@ -1,6 +1,4 @@ -import random - -from util import hook, http, web +from util import hook, web @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 quote['Change'] is None: - return "unknown ticker symbol %s" % inp + return "Unknown ticker symbol: {}".format(sym) change = float(quote['Change']) price = float(quote['LastTradePriceOnly']) @@ -24,10 +22,9 @@ def stock(inp): quote['color'] = "3" quote['PercentChange'] = 100 * change / (price - change) + print quote - ret = "\x02%(Name)s\x02 (\x02%(symbol)s\x02) - %(LastTradePriceOnly)s " \ - "\x03%(color)s%(Change)s (%(PercentChange).2f%%)\x03 " \ - "Day Range: %(DaysRange)s " \ - "MCAP: %(MarketCapitalization)s" % quote - - return ret + return u"\x02{Name}\x02 (\x02{symbol}\x02) - {LastTradePriceOnly} " \ + "\x03{color}{Change} ({PercentChange:.2f}%)\x03 " \ + "Day Range: {DaysRange} " \ + "MCAP: {MarketCapitalization}".format(**quote)