1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
package main
import (
"encoding/json"
"fmt"
"strconv"
"time"
"github.com/slack-go/slack"
)
func main() {
attachment := slack.Attachment{
Color: "good",
Fallback: "You successfully posted by Incoming Webhook URL!",
AuthorName: "slack-go/slack",
AuthorSubname: "github.com",
AuthorLink: "https://github.com/slack-go/slack",
AuthorIcon: "https://avatars2.githubusercontent.com/u/652790",
Text: "<!channel> All text in Slack uses the same system of escaping: chat messages, direct messages, file comments, etc. :smile:\nSee <https://api.slack.com/docs/message-formatting#linking_to_channels_and_users>",
Footer: "slack api",
FooterIcon: "https://platform.slack-edge.com/img/default_application_icon.png",
Ts: json.Number(strconv.FormatInt(time.Now().Unix(), 10)),
}
msg := slack.WebhookMessage{
Attachments: []slack.Attachment{attachment},
}
err := slack.PostWebhook("YOUR_WEBHOOK_URL_HERE", &msg)
if err != nil {
fmt.Println(err)
}
}
|