def yahoo_question_callback(sess, resp): response_data = resp.json() print('in Yahoo callback...') try: sess.obj.answer = response_data["all"]["questions"][0]["ChosenAnswer"] print(sess.obj.answer) yoda_say(sess.obj) except: #Gotta catch them all! print('Yahoo, you have failed me for the last time. Cleverbot, I choose you!') cleverbot_ask(sess.obj)
def ask(self): if len(self.message) < 22: cleverbot_ask(self) else: yahoo_ask(self)