本文整理匯總了Golang中github.com/nlopes/slack.Slack.ArchiveChannel方法的典型用法代碼示例。如果您正苦於以下問題:Golang Slack.ArchiveChannel方法的具體用法?Golang Slack.ArchiveChannel怎麽用?Golang Slack.ArchiveChannel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/nlopes/slack.Slack
的用法示例。
在下文中一共展示了Slack.ArchiveChannel方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: archiveChannels
func archiveChannels(api *slack.Slack, c []slack.Channel, reason string) {
var wg sync.WaitGroup
for _, channel := range c {
fmt.Printf("Archiving #%s (%s) due to %s\n", channel.Name, channel.Id, reason)
wg.Add(1)
go func(c slack.Channel) {
defer wg.Done()
if err := api.ArchiveChannel(c.Id); err != nil {
message := fmt.Sprintf(
"Error archiving channel #%s (%s): %s\n", c.Name, c.Id, err)
log.Printf(message)
// send error message in a DM to onErrorNotify user/channel
onErrorNotify := os.Getenv("ARCHIVEBOT_NOTIFY")
if onErrorNotify != "" {
params := slack.PostMessageParameters{}
if _, _, postMessageError := api.PostMessage(
onErrorNotify, message, params); postMessageError != nil {
postMessageErrorMessage := fmt.Sprintf(
"Error posting error message to Slack: %s\n", postMessageError)
log.Printf(postMessageErrorMessage)
}
}
}
}(channel)
}
wg.Wait()
}
示例2: archiveChannels
func archiveChannels(api *slack.Slack, c []slack.Channel, reason string) {
var wg sync.WaitGroup
for _, channel := range c {
fmt.Printf("Archiving #%s (%s) due to %s\n", channel.Name, channel.Id, reason)
wg.Add(1)
go func(c slack.Channel) {
defer wg.Done()
if err := api.ArchiveChannel(c.Id); err != nil {
log.Printf("Error archiving #%s (%s): %s\n", c.Name, c.Id, err)
}
}(channel)
}
wg.Wait()
}