def activate(self, is_bad_request=False): if is_bad_request: self.is_bad_request = True session.reply(self.bad_request_text) else: session.attachment_reply( templates.make_button_choices(self.question, self.postback_choices)) self.wait_for_answer = True
def set_answer(self, answer): answer = re.sub(r'^to\s+', '', answer, 1, re.IGNORECASE) bbox = geolocator.geocode_location_to_bbox(answer) if bbox: self.param_value = bbox self.answer = answer self.wait_for_answer = False session.reply('Ok, we are going to "%s"' % bbox.formatted_address) else: session.reply( self.messages['location_not_found'].format(answer=answer))
def set_answer(self, answer): if self.answer or self.is_bad_request: log.info('Accept phone number: %r' % answer) try: PhoneNumber.objects.create(sender=session.user_id, sender_data=json.dumps( session.data.get( 'user_profile', [])), phone=answer) finally: self.wait_for_answer = False if self.is_bad_request: session.reply('Thank you, we will be in touch.') else: session.reply('Thank you. Have a good day.') models.Chat.objects.filter(id=session.chat_id).update( muted_at=timezone.now()) search_request.reset() else: answer = answer.strip().lower() if not self.answer_matcher.match(answer): self.bad_answer(answer) return self.answer = answer if self.answer == 'yes': session.reply( 'Perfect, we will process your request and our operation manager ' 'will get back to you with your apartment recommendations shortly. ' 'What is your phone number and email address we can contact you on?' ) elif self.answer == 'no': session.reply( 'No problem, we will process your request and our operation manager ' 'will get back to you with apartment recommendations that better fit your criteria. ' 'What is your phone number and email address we can contact you on?' )
def secret500(message): session.reply('%s' % (1/0))
def hey(message): # eggplant session.reply('\U0001F346')
def activate(self): session.reply(self.question) self.wait_for_answer = True
def bad_answer(self, answer): q = search_request.go_to_question(AskPhoneNumberQuestion) if not q: session.reply(self.answer_bad_message.format(answer=answer)) else: q.activate(is_bad_request=True)
def activate(self): session.reply(self.greeting) self.wait_for_answer = True