Exemplo n.º 1
0
 def run_error_state(self, update, context):
     error_states = self.state_data.get('error_states', [])
     if len(error_states) == 0:  # default error
         self.run_default_error_state(update, context)
     else:  # specified error
         error_state = self.States.states_map[error_states[0]['state']]
         error_texts = error_state.get_texts(update, context)
         for text in error_texts:
             bot_send_message(update, context, text, remove_keyboard=False)
Exemplo n.º 2
0
    def run_state(self, update, context):
        """
        perform the current state, send message to user
        """
        logger.info(f'{self.state_type}, {self.get_texts(update, context)}')
        if self.state_type in ['question', 'message', 'error']:
            texts = self.get_texts(update, context)
            keyboards = self.get_keyboards(update, context)
            reply_markup = None

            for t, text in enumerate(texts):
                if t == len(texts) - 1:
                    reply_markup = keyboards

                bot_send_message(update,
                                 context,
                                 text,
                                 reply_markup=reply_markup)
Exemplo n.º 3
0
 def run_default_error_state(self, update, context):
     error_state = self.states_map['DEFAULT_ERROR']
     error_texts = error_state.get_texts(update, context)
     for text in error_texts:
         bot_send_message(update, context, text, remove_keyboard=False)
Exemplo n.º 4
0
 def run_server_error_state(self, update, context):
     error_state = self.states_map['SERVER_ERROR']
     error_texts = error_state.get_texts(update, context)
     for text in error_texts:
         bot_send_message(update, context, text, remove_keyboard=False)
Exemplo n.º 5
0
 def run_do_not_spam_state(self, update, context):
     error_state = self.states_map['DEFAULT_DO_NOT_SPAM']
     error_texts = error_state.get_texts(update, context)
     for text in error_texts:
         bot_send_message(update, context, text, remove_keyboard=False)