Skip to content

Commit

Permalink
done
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderGi committed Sep 26, 2023
1 parent 957b9a9 commit 68955c9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion daras_ai_v2/asr.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def google_translate_languages() -> dict[str, str]:
parent = f"projects/{project}/locations/global"
client = translate.TranslationServiceClient()
supported_languages = client.get_supported_languages(
parent, display_language_code="en"
parent=parent, display_language_code="en"
)
return {
lang.language_code: lang.display_name
Expand Down
6 changes: 6 additions & 0 deletions daras_ai_v2/bots.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ def _unpack_bot_integration(self):
def get_interactive_msg_info(self) -> tuple[str, str]:
raise NotImplementedError("This bot does not support interactive messages.")

def get_recieved_msg_id(self) -> str | None:
return None


PAGE_NOT_CONNECTED_ERROR = (
"💔 Looks like you haven't connected this page to a gooey.ai workflow. "
Expand Down Expand Up @@ -290,6 +293,9 @@ def _process_and_send_msg(
# save the message id for the sent message
if msg_id:
msgs_to_save[-1].platform_msg_id = msg_id
# save the message id for the received message
if bot.get_recieved_msg_id():
msgs_to_save[0].platform_msg_id = bot.get_recieved_msg_id()
# save the messages
for msg in msgs_to_save:
msg.save()
Expand Down
10 changes: 7 additions & 3 deletions daras_ai_v2/slack_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class SlackBot(BotInterface):
platform = Platform.SLACK

_read_rcpt_ts: str | None = None
_bot_res_ts: str | None = None

def __init__(
self,
Expand Down Expand Up @@ -125,6 +126,9 @@ def get_interactive_msg_info(self) -> tuple[str, str]:
button_id = self._actions[0]["value"]
return button_id, self._msg_ts

def get_recieved_msg_id(self) -> str:
return self._msg_ts

def send_msg(
self,
*,
Expand All @@ -149,15 +153,15 @@ def send_msg(

splits = text_splitter(text, chunk_size=SLACK_MAX_SIZE, length_function=len)
for doc in splits[:-1]:
self._msg_ts = chat_post_message(
self._bot_res_ts = chat_post_message(
text=doc.text,
channel=self.bot_id,
channel_is_personal=self.convo.slack_channel_is_personal,
thread_ts=self._msg_ts,
username=self.convo.bot_integration.name,
token=self._access_token,
)
self._msg_ts = chat_post_message(
self._bot_res_ts = chat_post_message(
text=splits[-1].text,
audio=audio,
video=video,
Expand All @@ -168,7 +172,7 @@ def send_msg(
token=self._access_token,
buttons=buttons or [],
)
return self._msg_ts
return self._bot_res_ts

def mark_read(self):
text = self.convo.bot_integration.slack_read_receipt_msg.strip()
Expand Down

0 comments on commit 68955c9

Please sign in to comment.