diff --git a/plugins/slack/README.md b/plugins/slack/README.md index 9074d85cf..e66b57feb 100644 --- a/plugins/slack/README.md +++ b/plugins/slack/README.md @@ -218,7 +218,7 @@ There are a lot of steps to creating a Slack app and installing it. Let's go over what you'll need to do to get set up with app auth. 1. [Create the app](https://api.slack.com/apps) -2. From your app's `Basic Information` page go to `Permissions => Bot Token Scopes` and add `chat:write` and `file:write` +2. From your app's `Basic Information` page go to `Permissions => Bot Token Scopes` and add `chat:write` and `file:write` (Optionally add `chat:write.customize` to use the `username` and `icon` options) 3. Copy the `Bot User OAuth Access Token` into your `.env` file and store it as `SLACK_TOKEN` 4. Install the app in the channels you want it to post to via the Slack UI diff --git a/plugins/slack/__tests__/__snapshots__/slack.test.ts.snap b/plugins/slack/__tests__/__snapshots__/slack.test.ts.snap index 9c9e115b0..e751d8ba5 100644 --- a/plugins/slack/__tests__/__snapshots__/slack.test.ts.snap +++ b/plugins/slack/__tests__/__snapshots__/slack.test.ts.snap @@ -31,6 +31,13 @@ Array [ }, "type": "section", }, + Object { + "text": Object { + "text": " ", + "type": "mrkdwn", + }, + "type": "section", + }, Object { "type": "divider", }, @@ -49,6 +56,13 @@ Array [ }, "type": "section", }, + Object { + "text": Object { + "text": " ", + "type": "mrkdwn", + }, + "type": "section", + }, Object { "text": Object { "text": "*📝 Documentation*", @@ -63,6 +77,13 @@ Array [ }, "type": "section", }, + Object { + "text": Object { + "text": " ", + "type": "mrkdwn", + }, + "type": "section", + }, Object { "type": "divider", }, @@ -123,6 +144,13 @@ Array [ }, "type": "section", }, + Object { + "text": Object { + "text": " ", + "type": "mrkdwn", + }, + "type": "section", + }, Object { "type": "divider", }, @@ -141,6 +169,13 @@ Array [ }, "type": "section", }, + Object { + "text": Object { + "text": " ", + "type": "mrkdwn", + }, + "type": "section", + }, Object { "text": Object { "text": "*📝 Documentation*", @@ -155,6 +190,13 @@ Array [ }, "type": "section", }, + Object { + "text": Object { + "text": " ", + "type": "mrkdwn", + }, + "type": "section", + }, Object { "type": "divider", }, @@ -198,6 +240,13 @@ Array [ }, "type": "section", }, + Object { + "text": Object { + "text": " ", + "type": "mrkdwn", + }, + "type": "section", + }, Object { "type": "divider", }, @@ -258,6 +307,13 @@ Object { }, "type": "section", }, + Object { + "text": Object { + "text": " ", + "type": "mrkdwn", + }, + "type": "section", + }, ], "link_names": true, } @@ -298,6 +354,13 @@ Object { }, "type": "section", }, + Object { + "text": Object { + "text": " ", + "type": "mrkdwn", + }, + "type": "section", + }, ], "link_names": true, } @@ -344,6 +407,13 @@ Object { }, "type": "section", }, + Object { + "text": Object { + "text": " ", + "type": "mrkdwn", + }, + "type": "section", + }, ], "link_names": true, } @@ -383,6 +453,13 @@ Object { }, "type": "section", }, + Object { + "text": Object { + "text": " ", + "type": "mrkdwn", + }, + "type": "section", + }, ], "link_names": true, } @@ -422,6 +499,13 @@ Object { }, "type": "section", }, + Object { + "text": Object { + "text": " ", + "type": "mrkdwn", + }, + "type": "section", + }, ], "link_names": true, } @@ -461,6 +545,13 @@ Object { }, "type": "section", }, + Object { + "text": Object { + "text": " ", + "type": "mrkdwn", + }, + "type": "section", + }, ], "link_names": true, } @@ -500,6 +591,13 @@ Object { }, "type": "section", }, + Object { + "text": Object { + "text": " ", + "type": "mrkdwn", + }, + "type": "section", + }, ], "link_names": true, } @@ -539,6 +637,13 @@ Object { }, "type": "section", }, + Object { + "text": Object { + "text": " ", + "type": "mrkdwn", + }, + "type": "section", + }, ], "link_names": true, } @@ -578,6 +683,13 @@ Object { }, "type": "section", }, + Object { + "text": Object { + "text": " ", + "type": "mrkdwn", + }, + "type": "section", + }, ], "link_names": true, } diff --git a/plugins/slack/src/index.ts b/plugins/slack/src/index.ts index 07b4dbed5..7c91d9c2e 100644 --- a/plugins/slack/src/index.ts +++ b/plugins/slack/src/index.ts @@ -48,6 +48,15 @@ const createSectionBlock = (text: string) => ({ }, }); +/** Create some space in the message */ +const createSpacerBlock = () => ({ + type: "section" as const, + text: { + type: "mrkdwn", + text: " ", + }, +}); + /** Create slack header block */ const createHeaderBlock = (text: string) => ({ type: "header" as const, @@ -96,6 +105,7 @@ export function convertToBlocks( if (line.startsWith("#")) { currentMessage.push(createSectionBlock(`*${line.replace(/^[#]+/, "")}*`)); } else if (line === "---") { + currentMessage.push(createSpacerBlock()); currentMessage.push(createDividerBlock()); } else if (line.startsWith("```")) { const [, language] = line.match(/```(\S+)/) || ["", "detect"]; @@ -147,6 +157,7 @@ export function convertToBlocks( } currentMessage.push(createSectionBlock(lines.join("\n"))); + currentMessage.push(createSpacerBlock()); } else if (line) { currentMessage.push(createSectionBlock(line)); }