1.0.5 • Published 6 months ago

send-slack v1.0.5

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

Send Slack

A powerful CLI tool to send formatted Markdown messages to Slack using webhooks.

Features

  • Convert Markdown to Slack blocks
  • Support for complex Markdown elements (headings, lists, code blocks, etc.)
  • Automatic splitting of long messages to comply with Slack's limits
  • Option to send pre-formatted Slack blocks
  • Add title, context, and start text to your messages
  • Read input from files or directly from the command line

Installation

npm install -g send-slack

Usage

You can use this package with npx without installing it globally:

npx send-slack [options]

Or if you've installed it globally:

send-slack [options]

Options

OptionAliasDescriptionTypeRequired
--webhook-wSlack webhook URLstringYes
--markdown-mMarkdown string or file pathstringNo*
--blocks-bJSON string of Slack blocks or file pathstringNo*
--title-tHeading for the messagestringNo
--context-cContext array as a JSON stringstringNo
--start-text-sStart text for the messagestringNo
--help-hShow helpbooleanNo

*Either --markdown or --blocks must be provided

Examples

Send a Markdown message

npx send-slack --webhook "https://hooks.slack.com/services/XXX/YYY/ZZZ" --markdown "# Hello World\n\nThis is a test message."

Send a message from a Markdown file

npx send-slack --webhook "https://hooks.slack.com/services/XXX/YYY/ZZZ" --markdown ./message.md

Send pre-formatted Slack blocks

npx send-slack --webhook "https://hooks.slack.com/services/XXX/YYY/ZZZ" --blocks '[{"type":"section","text":{"type":"mrkdwn","text":"Hello, World!"}}]'

Send a message with a title and context

npx send-slack --webhook "https://hooks.slack.com/services/XXX/YYY/ZZZ" --markdown "This is the main message." --title "Important Announcement" --context '["Posted by: John Doe", "Date: 2023-06-01"]'

Markdown Support

This tool supports a wide range of Markdown elements, including:

  • Headings (H1 to H6)
  • Bold and italic text
  • Strikethrough
  • Unordered and ordered lists
  • Code blocks (with language highlighting)
  • Blockquotes
  • Horizontal rules
  • Links
  • Images

Slack Message Limits

This tool automatically handles Slack's message limits:

  • Maximum of 50 blocks per message
  • Maximum text length of 3000 characters per block
  • Maximum total message length of 40,000 characters

Long messages are automatically split into multiple Slack messages while preserving formatting.

Error Handling

If an error occurs during execution, the tool will output an error message to the console and exit with a non-zero status code.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License.

1.0.5

6 months ago

1.0.4

6 months ago

1.0.3

6 months ago

1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago