Skip to content

Commit

Permalink
Merge pull request #184 from lappis-unb/improvements
Browse files Browse the repository at this point in the history
Improvements
  • Loading branch information
arthurTemporim authored Oct 28, 2020
2 parents 1a531da + 9c36977 commit 8351c10
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 17 deletions.
2 changes: 1 addition & 1 deletion bot/actions/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
11 changes: 5 additions & 6 deletions bot/actions/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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")
Expand Down Expand Up @@ -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}

5 changes: 4 additions & 1 deletion modules/analytics/setup_elastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
5 changes: 4 additions & 1 deletion modules/rabbitmq/consumer/consume_bot_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
)

Expand Down
20 changes: 12 additions & 8 deletions modules/rocketchat/bot_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]},
)


Expand Down Expand Up @@ -169,22 +170,25 @@ 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)

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")

0 comments on commit 8351c10

Please sign in to comment.