// SendReportToSlack send Report to Slack
func SendReportToSlack(api *slack.Slack, r horenso.Report, id string, msg string, items []string) {
	opt := GetSlackChatPostMessageOpt(r, items)

	err := api.ChatPostMessage(id, msg, &opt)
	if err != nil {
		panic(err)
	}
}
// GetGroupID get Slack group ID by group name
func GetGroupID(api *slack.Slack, r horenso.Report, groupName string) string {
	group, err := api.FindGroupByName(groupName)
	if err != nil {
		panic(err)
	}

	return group.Id
}
// GetChannelID get Slack channel ID by channel name
func GetChannelID(api *slack.Slack, r horenso.Report, channelName string) string {
	channel, err := api.FindChannelByName(channelName)
	if err != nil {
		panic(err)
	}

	return channel.Id
}
Beispiel #4
0
//Lookup Slack id for channel, group, or im
func lookupSlackId(api *slack.Slack, name string) (string, error) {
	channel, err := api.FindChannelByName(name)
	if err == nil {
		return channel.Id, nil
	}
	group, err := api.FindGroupByName(name)
	if err == nil {
		return group.Id, nil
	}
	im, err := api.FindImByName(name)
	if err == nil {
		return im.Id, nil
	}
	return "", fmt.Errorf("No such channel, group, or im")
}