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


Golang Slack.GetChannels方法代碼示例

本文整理匯總了Golang中github.com/nlopes/slack.Slack.GetChannels方法的典型用法代碼示例。如果您正苦於以下問題:Golang Slack.GetChannels方法的具體用法?Golang Slack.GetChannels怎麽用?Golang Slack.GetChannels使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/nlopes/slack.Slack的用法示例。


在下文中一共展示了Slack.GetChannels方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: dumpChannels

func dumpChannels(api *slack.Slack, dir string, rooms []string) []slack.Channel {
	channels, err := api.GetChannels(false)
	check(err)

	if len(rooms) > 0 {
		channels = FilterChannels(channels, func(channel slack.Channel) bool {
			for _, room := range rooms {
				if room == channel.Name {
					return true
				}
			}
			return false
		})
	}

	if len(channels) == 0 {
		var channels []slack.Channel
		return channels
	}

	for _, channel := range channels {
		dumpChannel(api, dir, channel.Id, channel.Name, "channel")
	}

	return channels
}
開發者ID:felag,項目名稱:slack-dump,代碼行數:26,代碼來源:main.go

示例2: updateChannels

func updateChannels(s *slack.Slack, db *sql.DB) error {
	channels, err := s.GetChannels(false)
	if err != nil {
		return err
	}

	for _, c := range channels {
		fmt.Printf("%s : %s\n", c.Name, c.ID)
		_, err := db.Exec(
			`INSERT INTO channels(id, name, created_at, updated_at)
			 VALUES(?, ?, NOW(), NOW())
			 ON DUPLICATE KEY UPDATE name = VALUES(name), updated_at = NOW()
			`,
			c.ID, c.Name)
		if err != nil {
			return err
		}
	}

	return nil
}
開發者ID:kan,項目名稱:slack-door,代碼行數:21,代碼來源:crawler.go


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