예제 #1
0
파일: game.py 프로젝트: yi-jiayu/telewords
 def _hint_message(self):
     uncommon_words = self.words - self.common_words
     hint = random.choice([word for word in uncommon_words])
     hint_text = " ".join(redact_letters(hint, HINT_REDACTION_AMOUNT))
     hint_definition = random.choice(
         [d for d in get_definition(hint).split("\n") if hint not in d])
     return f"<em>Hint: {hint_text}</em>\n{hint_definition}"
예제 #2
0
    def definition(self):
        if self._definition:
            return self._definition

        self.json = make_dict_request(self.name, DICT_API_KEY, REQ_URL)
        self._definition = get_definition(self.json)
        return self._definition
예제 #3
0
파일: game.py 프로젝트: yi-jiayu/telewords
 def _missed_words_message(self):
     remaining_words = self._longest_remaining_words()
     if not remaining_words:
         return
     message = "Here are some words you missed:"
     for word in remaining_words:
         definition = get_definition(word)
         if definition:
             word += "\n" + definition
         message += "\n\n" + word
     return message
예제 #4
0
def reply_message(msg):
    if (msg == 'news updates'):
        return news.news()

    if (msg.split()[0] == 'weather'):
        return weather.get_weather(msg.split()[1])

    if (msg.split()[0] == 'definition'):
        return dictionary.get_definition(msg.split()[1])

    if (msg.split()[0:2] == ['covid', 'update']):
        return tracker.get_corona_updates(msg.split()[2])

    else:
        return "I dont understand"
예제 #5
0
def reply_message(msg):
    if(msg=='news updates'):
         return news.news()

    if(msg.split()[0]=='weather'):
        return weather.get_weather(msg.split()[1])

    if(msg.split()[0]=='Weather'):
        return weather.get_weather(msg.split()[1])

    if(msg.split()[0]=='definition'):
        return  dictionary.get_definition(msg.split()[1])

    if(msg.split()[0:2]==['covid','update']):
        return tracker.get_corona_updates(msg.split()[2])

    else:
        return '''Hello, I am a WhatsApp Chatbot made by Vineet Kekatpure,Shreyash Joshi, Sandeep Suhag and Rithik Kalla.\n
예제 #6
0
def test_get_definition():
    word = "apple"
    definition = get_definition(word)
    assert definition is not None
    assert isinstance(definition, str)
예제 #7
0
def test_get_definition_not_found():
    word = "no such word"
    definition = get_definition(word)
    assert definition is None
예제 #8
0
 def define_this(message):
     word = message.text[5:]
     definition = get_definition(word)
     bot.reply_to(message, definition)