Skip to content

Commit 8351c10

Browse files
Merge pull request #184 from lappis-unb/improvements
Improvements
2 parents 1a531da + 9c36977 commit 8351c10

File tree

5 files changed

+26
-17
lines changed

5 files changed

+26
-17
lines changed

bot/actions/actions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def run(
3939
domain: Dict[Text, Any],
4040
) -> List[Dict[Text, Any]]:
4141

42-
telefone = tracker.get_slot('telefone')
42+
telefone = tracker.get_slot("telefone")
4343

4444
try:
4545
dispatcher.utter_message("O seu telefone é {}?".format(telefone))

bot/actions/forms.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ def required_slots(tracker: Tracker) -> List[Text]:
2929

3030
def slot_mappings(self) -> Dict[Text, Union[Dict, List[Dict]]]:
3131
"""A dictionary to map required slots to
32-
- an extracted entity
33-
- intent: value pairs
34-
- a whole message
35-
or a list of them, where a first match will be picked"""
32+
- an extracted entity
33+
- intent: value pairs
34+
- a whole message
35+
or a list of them, where a first match will be picked"""
3636
return {
3737
"cpf": self.from_text(not_intent="cancelar"),
3838
"data_nascimento": self.from_text(not_intent="cancelar"),
@@ -45,7 +45,7 @@ def submit(
4545
domain: Dict[Text, Any],
4646
) -> List[Dict]:
4747
"""Define what the login form will do after
48-
all required slots are filled"""
48+
all required slots are filled"""
4949

5050
cpf = tracker.get_slot("cpf")
5151
data_nascimento = tracker.get_slot("data_nascimento")
@@ -94,4 +94,3 @@ def validate_data_nascimento(
9494
# validation failed, set this slot to None, meaning the
9595
# user will be asked for the slot again
9696
return {"data_nascimento": None}
97-

modules/analytics/setup_elastic.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@
4545
if not es.indices.exists(index_name):
4646
logger.debug(
4747
es.indices.create(
48-
index=index_name, ignore=400, params=param, body=settings,
48+
index=index_name,
49+
ignore=400,
50+
params=param,
51+
body=settings,
4952
)
5053
)
5154
logger.info("Created Index")

modules/rabbitmq/consumer/consume_bot_messages.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@
2929

3030
connection = pika.BlockingConnection(
3131
pika.ConnectionParameters(
32-
host="rabbitmq", credentials=credentials, connection_attempts=20, retry_delay=5,
32+
host="rabbitmq",
33+
credentials=credentials,
34+
connection_attempts=20,
35+
retry_delay=5,
3336
)
3437
)
3538

modules/rocketchat/bot_config.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ def create_bot_user():
117117
print("User already created.")
118118

119119
api_post(
120-
"users.setAvatar", {"avatarUrl": bot["avatar"], "username": bot["username"]},
120+
"users.setAvatar",
121+
{"avatarUrl": bot["avatar"], "username": bot["username"]},
121122
)
122123

123124

@@ -169,22 +170,25 @@ def configure_rocketchat():
169170
rocket_available = True
170171
except Exception:
171172
import time
173+
172174
logger.info("\n\n --------- Rocket Chat Unavailable! --------\n\n")
173175
logger.info(">> Waiting for 3 seconds...")
174176
time.sleep(3)
175177

176178
logger.info(">> Connected to Rocket Instance")
177179

178180
if user_header:
179-
logger.info(">> Create user")
180-
create_bot_user()
181-
182-
logger.info(">> Configure Rocketchat")
183-
configure_rocketchat()
181+
try:
182+
logger.info(">> Create user")
183+
create_bot_user()
184184

185-
logger.info(">> Configure Webhooks")
186-
configure_webhooks()
185+
logger.info(">> Configure Rocketchat")
186+
configure_rocketchat()
187187

188+
logger.info(">> Configure Webhooks")
189+
configure_webhooks()
190+
except Exception as e:
191+
logger.error(f"Problem while trying to configure bot in Rocketchat: {e}")
188192

189193
else:
190194
logger.error(">> Login Failed")

0 commit comments

Comments
 (0)