def even_or_odd(self, message=None, match=None, to=None):
is_odd = len(match.group("evenOrOdd")) % 2
num = random.randint(1, 10)
if (is_odd and num % 2) or (not is_odd and not num % 2):
return TextMessageProtocolEntity("[%d]\nYou win." % num, to=message.getFrom())
else:
return TextMessageProtocolEntity("[%d]\nYou lose!" % num, to=message.getFrom())
# def beban_spell_checker(self, message=None, match=None, to=None):
# print(message.getBody())
# correctionList = ""
# text = message.getBody()
# d = enchant.DictWithPWL("es_MX","wordList.txt")
# d_en = enchant.Dict("en_US")
# wordList = text.split()
# for word in wordList:
# if(word.isalnum() == True):
# print(word)
# if(d.check(word) == False):
# # if(d_en.check(word) == False):
# solutions = d.suggest(word)
# print(solutions)
# sol = str(solutions[0])
# if(sol.isalnum() == False):
# correctionList += sol + "* "
# if (correctionList != ""):
# print(correctionList)
# return TextMessageProtocolEntity(correctionList, to=message.getFrom())
评论列表
文章目录