DALL·E 2022-08-04 20 18 34 - very cute happy blue cartoon gopher send a message with computer(1)

Thanks to AI’S

This package get helps from AI’s Github Copilot, OpenAI and DALL·E

Installation

As a library

go get github.com/utfd/slack-alerts

or if you want to use it as a bin command

go >= 1.17

go install github.com/utfd/[email protected]

go < 1.17

go get github.com/utfd/slack-alerts

Setting webhooks

At your .env file set SLACK_WEBHOOK_URL like bellow.

SLACK_WEBHOOK_URL=https://hooks.slack.com/services/XXXXX

Usage

To send a message to Slack, simply call SlackAlert::message() and pass it any message you want.

slackAlerts.Message("You have a new subscriber to the Foo newsletter!")

Formatting

Markdown

You can format your messages with Slack’s markup. Learn how in the Slack API docs.

slackAlerts.Message("A message *with some bold statements* and _some italicized text_.")

Links are formatted differently in Slack than the classic markdown structure.

slackAlerts.Message("<https://google.com|This is a link to our homepage>")

Emoji’s

You can use the same emoji codes as in Slack. This means custom emoji’s are also supported.

slackAlerts.Message(":smile: :custom-code:")

Mentioning

You can use mentions to notify users and groups. Learn how in the Slack API docs.

slackAlerts.Message("A message that notifies <@username> and everyone else who is <!here>")

Testing

go test

License

The MIT License (MIT). Please see License File for more information.

GitHub

View Github