示例#1
0
// 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
}
示例#2
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")
}