本文整理汇总了Golang中github.com/bluele/slack.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了New函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
api := slack.New(token)
err := api.CreateGroup(groupName)
if err != nil {
panic(err)
}
}
示例2: main
func main() {
ts := oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: GITHUB_TOKEN},
)
tc := oauth2.NewClient(oauth2.NoContext, ts)
githubClient := github.NewClient(tc)
release, err := githubClient.Repositories.GetLatestRelease("FRC1360", "Stronghold2016")
if err != nil {
panic(err)
}
if downloadFromUrl(release.ZipballURL) {
message := "Code Release Downloaded: " + release.AssetsURL + "\nSaved to Backup Server - Running copy cron job now."
api := slack.New(SLACK_TOKEN)
channel, err := api.FindChannelByName(SLACK_CHANNEL)
if err != nil {
panic(err)
}
err = api.ChatPostMessage(channel.Id, message, nil)
if err != nil {
panic(err)
}
}
}
示例3: newSlackNotify
func newSlackNotify(conf *SlackNotifyConfig) *SlackNotify {
sn := &SlackNotify{
slackApi: slack.New(conf.Token),
Config: conf,
}
return sn
}
示例4: main
func main() {
api := slack.New(token)
err := api.JoinChannel(channelName)
if err != nil {
panic(err)
}
}
示例5: main
func main() {
api := slack.New(token)
user, err := api.UsersInfo(userID)
if err != nil {
panic(err)
}
fmt.Println(user.Name, user.Profile.Email)
}
示例6: main
func main() {
api := slack.New(token)
groups, err := api.GroupsList()
if err != nil {
panic(err)
}
for _, group := range groups {
fmt.Println(group.Id, group.Name)
}
}
示例7: main
func main() {
api := slack.New(token)
users, err := api.UsersList()
if err != nil {
panic(err)
}
for _, user := range users {
fmt.Println(user.Id, user.Name)
}
}
示例8: main
func main() {
api := slack.New(token)
auth, err := api.AuthTest()
if err != nil {
panic(err)
}
fmt.Println(auth.Url)
fmt.Println(auth.Team)
fmt.Println(auth.User)
}
示例9: main
func main() {
api := slack.New(token)
channels, err := api.ChannelsList()
if err != nil {
panic(err)
}
for _, channel := range channels {
fmt.Println(channel.Id, channel.Name)
}
}
示例10: main
func main() {
token, channelName, groupName, mention, items := helper.Getenvs()
r := helper.GetReport(os.Stdin)
api := slack.New(token)
id := helper.GetID(api, r, channelName, groupName)
msg := helper.GetMessage(r, mention)
reporter.SendReportToSlack(api, r, id, msg, items)
}
示例11: main
func main() {
api := slack.New(token)
channel, err := api.FindChannelByName(channelName)
if err != nil {
panic(err)
}
err = api.ChatPostMessage(channel.Id, "Hello, world!", nil)
if err != nil {
panic(err)
}
}
示例12: Notify
func Notify(message string) {
s := slack.New(SLACK_TOKEN)
c, err := s.FindChannelByName(SLACK_CHANNEL)
if err != nil {
panic(err)
}
err = s.ChatPostMessage(c.Id, message, nil)
if err != nil {
panic(err)
}
}
示例13: main
func main() {
api := slack.New(token)
group, err := api.FindGroupByName(groupName)
if err != nil {
panic(err)
}
err = api.ChatPostMessage(group.Id, "Hello, world!", &slack.ChatPostMessageOpt{AsUser: true})
if err != nil {
panic(err)
}
}
示例14: setupSlack
func setupSlack() {
if len(os.Getenv("SLACK_API_TOKEN")) == 0 ||
len(os.Getenv("SLACK_ROOM")) == 0 {
color.Yellow("[>] Skipping Slack setup, missing SLACK_API_TOKEN and SLACK_ROOM")
return
}
slack_api = slack.New(os.Getenv("SLACK_API_TOKEN"))
slack_channel, err = slack_api.FindChannelByName(os.Getenv("SLACK_ROOM"))
if err != nil {
panic(err)
}
}
示例15: PostNotificationEventToSlackChannel
func PostNotificationEventToSlackChannel(config config.SlackConfig, event parser.NotificationEvent) (err error) {
f, err := os.OpenFile("/var/log/redis/sentinel.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
if err != nil {
log.Printf("error opening log file: %v", err)
}
defer f.Close()
log.SetOutput(f)
doTrigger := contains(config.TriggerOn, event.Eventname)
hostname, err := GetMyFQDN()
if !doTrigger {
return nil
}
api := slack.New(config.Token)
channel, err := api.FindChannelByName(config.Channel)
levelColor := "warning"
// switch through event to determine attachment color
switch event.Role {
case "sentinel":
levelColor = "danger"
}
switch event.Eventname {
case "+odown", "-failover-abort-no-good-slave":
levelColor = "danger"
case "-odown", "-sdown":
levelColor = "good"
}
att := slack.Attachment{Color: levelColor, AuthorName: config.AuthorName}
att.Title = fmt.Sprintf("Sentinel event")
eventField := slack.AttachmentField{Title: "Event Name", Value: event.Eventname, Short: true}
podField := slack.AttachmentField{Title: "Pod Name", Value: event.Podname, Short: true}
roleField := slack.AttachmentField{Title: "Role", Value: event.Role, Short: true}
reporterField := slack.AttachmentField{Title: "Reporter", Value: hostname, Short: true}
att.Fields = []*slack.AttachmentField{&eventField, &podField, &roleField, &reporterField}
if err != nil {
return (err)
}
var msg string
switch levelColor {
case "good":
msg = "Phew, it has recovered."
case "danger":
msg = "UHOH! Something is broken."
case "warning":
msg = "Heads up, something isn't looking right."
}
atts := []*slack.Attachment{&att}
msgopt := slack.ChatPostMessageOpt{AsUser: false, Attachments: atts, Username: config.Username}
err = api.ChatPostMessage(channel.Id, msg, &msgopt)
return err
}