This repository has been archived on 2023-04-13. You can view files and clone it, but cannot push or open issues or pull requests.
CloudBot/plugins/spellcheck.py
2012-02-29 00:29:53 -08:00

23 lines
569 B
Python
Executable file

import re
from util import hook
import enchant
@hook.command("spellcheck")
def spell(inp):
".spell <word> -- Check spelling of <word>."
d = enchant.Dict("en_US")
if not (inp.split()[-1] == inp):
return "This command only supports one word at a time."
is_correct = d.check(inp)
suggestions = d.suggest(inp)
s_string = ', '.join(suggestions)
if is_correct:
return "That word appears to be valid! (suggestions: " + s_string + ")"
else:
return "That word appears to be invalid! (suggestions: " + s_string + ")"