Fixed crashing on facebook connector

This commit is contained in:
Jakub Filo 2023-04-20 00:14:24 +02:00
parent 47d1356d4b
commit d5e3db11ff

View File

@ -63,12 +63,17 @@ async def api_conversation(opsdroid, config, message):
connector_matrix - the object obtained from opsdroid.get_connector
"""
# Get connector_matrix object and start the typing notification
try:
if message.connector.name == "matrix":
connector_matrix = opsdroid.get_connector("matrix")
await connector_matrix.connection.room_typing(message.target,
typing_state=True)
except (NameError,KeyError):
pass
api_to_use = None
try:
if message.connector.name == "matrix" and 'm.relates_to' in message.raw_event['content']:
# Load conversation_context for current thread_id if it exists
question_text = message.text
@ -95,6 +100,9 @@ async def api_conversation(opsdroid, config, message):
return
# Generate empty conversation_context
conversation_context = {"api_to_use": api_to_use}
except (NameError,KeyError):
pass
api_params = config.get("apis")[api_to_use]
@ -108,6 +116,7 @@ async def api_conversation(opsdroid, config, message):
except KeyError:
response_value = "No such response key was found. Check configuration"
try:
if message.connector.name == "matrix":
# Construct and send a response and save conversation context for matrix
message_dict = {
@ -131,3 +140,6 @@ async def api_conversation(opsdroid, config, message):
else:
# For non-matrix connectors send a response
await message.respond(response_value)
except (NameError,KeyError):
pass