def new_game(self, message: Message):
        user = User.objects.get(telegram_id=message.chat.id)

        if user.is_playing():
            self.send_message(message.chat.id, M.ALREADY_PLAYING)
            self._send_current_word(user)
            return

        random_word = Word.get_random_word()

        user.new_game(random_word)

        self.send_message(message.chat.id,
                          M.THINK_OF_LETTERS(len(random_word)))
        self._send_current_word(user)
Example #2
0
def random_word():
    """ This method serves a meaning of random word from Wikipedia in JSON format. """

    word = Word.get_random_word()
    return word.to_json()