Debian Codegraph @

examples/messages/messages.go

raw symbols SCIP
1 package mainscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack/examples/messages`/
2
3 import (
4 "fmtscip-go gomod github.com/golang/go/src go1.16 fmt/"
5
6 "github.com/slack-go/slackscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/"
7 )
8
9 func mainscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack/examples/messages`/main().() {
10 api := slackscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/.Newscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/New().("YOUR_TOKEN_HERE")
11 attachment := slackscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/.Attachmentscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/Attachment#{
12 Pretextscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/Attachment#Pretext.: "some pretext",
13 Textscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/Attachment#Text.: "some text",
14 // Uncomment the following part to send a field too
15 /*
16 Fields: []slack.AttachmentField{
17 slack.AttachmentField{
18 Title: "a",
19 Value: "no",
20 },
21 },
22 */
23 }
24
25 channelID, timestamp, err := api.PostMessagescip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/Client#PostMessage().(
26 "CHANNEL_ID",
27 slackscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/.MsgOptionTextscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/MsgOptionText().("Some text", false),
28 slackscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/.MsgOptionAttachmentsscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/MsgOptionAttachments().(attachment),
29 slackscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/.MsgOptionAsUserscip-go gomod github.com/slack-go/slack . `github.com/slack-go/slack`/MsgOptionAsUser().(true), // Add this if you want that the bot would post message as a user, otherwise it will send response using the default slackbot
30 )
31 if err != nil {
32 fmtscip-go gomod github.com/golang/go/src go1.16 fmt/.Printfscip-go gomod github.com/golang/go/src go1.16 fmt/Printf().("%s\n", err)
33 return
34 }
35 fmtscip-go gomod github.com/golang/go/src go1.16 fmt/.Printfscip-go gomod github.com/golang/go/src go1.16 fmt/Printf().("Message successfully sent to channel %s at %s", channelID, timestamp)
36 }