Skip to content

Commit

Permalink
sendSlackMessage: no more than 50 blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
thypon committed May 13, 2024
1 parent abda2d9 commit 290575c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/sendSlackMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,21 @@ export default async function sendSlackMessage ({
const { markdownToBlocks } = await import('@tryfabric/mack')

const web = new WebClient(token)
const blocks = await markdownToBlocks(message)
let blocks = await markdownToBlocks(message)

if (debug) { console.log(blocks) }

if (blocks.length > 50) {
blocks = blocks.slice(0, 49)
blocks.push({
type: 'section',
text: {
type: 'mrkdwn',
text: '...and more'
}
})
}

const result = await web.chat.postMessage({
username,
text: `${username} alert`,
Expand Down

0 comments on commit 290575c

Please sign in to comment.