當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Slack.ArchiveChannel方法代碼示例

本文整理匯總了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()
}
開發者ID:timblair,項目名稱:slack-archivebot,代碼行數:30,代碼來源:bot.go

示例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()
}
開發者ID:Rich86man,項目名稱:slack-archivebot,代碼行數:17,代碼來源:bot.go


注:本文中的github.com/nlopes/slack.Slack.ArchiveChannel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。