Commit 200b7dd3 by Oleksandr Barabash

request wrapped into the function

parent 5a6e6381
...@@ -367,21 +367,27 @@ class TeamsMessagingExtensionsActionPreviewBot(TeamsActivityHandler): ...@@ -367,21 +367,27 @@ class TeamsMessagingExtensionsActionPreviewBot(TeamsActivityHandler):
return return
# try get flow link # try get flow link
# noinspection PyBroadException def request():
try: """ request """
flow = await self.cosmos_client.get_flow(message) try:
Log.e(TAG, f"on_message_activity::flow.url:{unquote(flow.url)}") flow = await self.cosmos_client.get_flow(message)
async with aiohttp.ClientSession() as session: Log.e(TAG, f"on_message_activity::flow.url:{flow.url}")
# TODO(s1z): string bot's @mention if needed. async with aiohttp.ClientSession() as session:
data = dict(reference=reference, message=message) # TODO(s1z): string bot's @mention if needed.
async with session.post(unquote(flow.url), json=data) as resp: data = dict(reference=reference, message=message)
Log.e(TAG, f"on_message_activity::response.status:" async with session.post(flow.url, json=data) as resp:
f"{resp.status}") Log.e(TAG, f"on_message_activity::response.status:"
rest_text = await resp.text() f"{resp.status}")
Log.e(TAG, f"on_message_activity::response.text: {rest_text}") rest_text = await resp.text()
return Log.e(TAG, f"on_message_activity::"
except Exception: f"response.text: {rest_text}")
Log.e(TAG, f"on_message_activity::get_flow:error", sys.exc_info()) return True
except Exception:
Log.e(TAG, f"on_message_activity::get_flow:error", sys.exc_info())
return False
response = await request()
if response:
return
await turn_context.send_activity(i18n.t("response_unknown_cmd", await turn_context.send_activity(i18n.t("response_unknown_cmd",
cmd_help=cmd_help)) cmd_help=cmd_help))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment