本文整理匯總了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
}
示例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
}