Skip to content

Commit

Permalink
Allow supplying raw attachments/blocks for messages (#83)
Browse files Browse the repository at this point in the history
* Allow supplying raw attachments
* Allow supplying blocks
* Format code with black
  • Loading branch information
TheJokersThief authored Sep 26, 2022
1 parent d7fd803 commit 240b176
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions slackv3.py
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,16 @@ def send_message(self, msg) -> Message:
"as_user": "true",
}

if index == len(parts) - 1:
# Only add attachments/blocks if it's the last message, to avoid duplication
if "attachments" in msg.extras:
# If attachments are provided, and it's the last part of the mssage
data["attachments"] = json.dumps(msg.extras["attachments"])

if "blocks" in msg.extras:
# If blocksare provided, and it's the last part of the mssage
data["blocks"] = json.dumps(msg.extras["blocks"])

# Keep the thread_ts to answer to the same thread.
if "thread_ts" in msg.extras:
data["thread_ts"] = msg.extras["thread_ts"]
Expand Down

0 comments on commit 240b176

Please sign in to comment.