diff --git a/bot/actions/actions.py b/bot/actions/actions.py index bf2dbf41..73041153 100644 --- a/bot/actions/actions.py +++ b/bot/actions/actions.py @@ -39,7 +39,7 @@ def run( domain: Dict[Text, Any], ) -> List[Dict[Text, Any]]: - telefone = tracker.get_slot('telefone') + telefone = tracker.get_slot("telefone") try: dispatcher.utter_message("O seu telefone é {}?".format(telefone)) diff --git a/bot/actions/forms.py b/bot/actions/forms.py index c64c1c38..470b8bb0 100644 --- a/bot/actions/forms.py +++ b/bot/actions/forms.py @@ -29,10 +29,10 @@ def required_slots(tracker: Tracker) -> List[Text]: def slot_mappings(self) -> Dict[Text, Union[Dict, List[Dict]]]: """A dictionary to map required slots to - - an extracted entity - - intent: value pairs - - a whole message - or a list of them, where a first match will be picked""" + - an extracted entity + - intent: value pairs + - a whole message + or a list of them, where a first match will be picked""" return { "cpf": self.from_text(not_intent="cancelar"), "data_nascimento": self.from_text(not_intent="cancelar"), @@ -45,7 +45,7 @@ def submit( domain: Dict[Text, Any], ) -> List[Dict]: """Define what the login form will do after - all required slots are filled""" + all required slots are filled""" cpf = tracker.get_slot("cpf") data_nascimento = tracker.get_slot("data_nascimento") @@ -94,4 +94,3 @@ def validate_data_nascimento( # validation failed, set this slot to None, meaning the # user will be asked for the slot again return {"data_nascimento": None} - diff --git a/modules/analytics/setup_elastic.py b/modules/analytics/setup_elastic.py index c1ec2869..aa61f296 100644 --- a/modules/analytics/setup_elastic.py +++ b/modules/analytics/setup_elastic.py @@ -45,7 +45,10 @@ if not es.indices.exists(index_name): logger.debug( es.indices.create( - index=index_name, ignore=400, params=param, body=settings, + index=index_name, + ignore=400, + params=param, + body=settings, ) ) logger.info("Created Index") diff --git a/modules/rabbitmq/consumer/consume_bot_messages.py b/modules/rabbitmq/consumer/consume_bot_messages.py index 2c776b38..0d91e868 100644 --- a/modules/rabbitmq/consumer/consume_bot_messages.py +++ b/modules/rabbitmq/consumer/consume_bot_messages.py @@ -29,7 +29,10 @@ connection = pika.BlockingConnection( pika.ConnectionParameters( - host="rabbitmq", credentials=credentials, connection_attempts=20, retry_delay=5, + host="rabbitmq", + credentials=credentials, + connection_attempts=20, + retry_delay=5, ) ) diff --git a/modules/rocketchat/bot_config.py b/modules/rocketchat/bot_config.py index 17760152..c2dd4868 100755 --- a/modules/rocketchat/bot_config.py +++ b/modules/rocketchat/bot_config.py @@ -117,7 +117,8 @@ def create_bot_user(): print("User already created.") api_post( - "users.setAvatar", {"avatarUrl": bot["avatar"], "username": bot["username"]}, + "users.setAvatar", + {"avatarUrl": bot["avatar"], "username": bot["username"]}, ) @@ -169,6 +170,7 @@ def configure_rocketchat(): rocket_available = True except Exception: import time + logger.info("\n\n --------- Rocket Chat Unavailable! --------\n\n") logger.info(">> Waiting for 3 seconds...") time.sleep(3) @@ -176,15 +178,17 @@ def configure_rocketchat(): logger.info(">> Connected to Rocket Instance") if user_header: - logger.info(">> Create user") - create_bot_user() - - logger.info(">> Configure Rocketchat") - configure_rocketchat() + try: + logger.info(">> Create user") + create_bot_user() - logger.info(">> Configure Webhooks") - configure_webhooks() + logger.info(">> Configure Rocketchat") + configure_rocketchat() + logger.info(">> Configure Webhooks") + configure_webhooks() + except Exception as e: + logger.error(f"Problem while trying to configure bot in Rocketchat: {e}") else: logger.error(">> Login Failed")