Exemple #1
0
 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
Exemple #2
0
 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))
Exemple #3
0
    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?'
                )
Exemple #4
0
def secret500(message):
    session.reply('%s' % (1/0))
Exemple #5
0
def hey(message):
    # eggplant
    session.reply('\U0001F346')
Exemple #6
0
 def activate(self):
     session.reply(self.question)
     self.wait_for_answer = True
Exemple #7
0
 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)
Exemple #8
0
 def activate(self):
     session.reply(self.greeting)
     self.wait_for_answer = True