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


Golang Slack.GetUsers方法代碼示例

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


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

示例1: createFormForEverybody

func createFormForEverybody(formMessage *slack.MessageEvent, api *slack.Slack) {
	users, err := api.GetUsers()
	if err != nil {
		fmt.Println("Channel err ", err)
	}

	for _, user := range users {
		//create user form DONE
		//send dm to fill out form DONE

		formResp := createFormForUser(formMessage, user.Id)
		if user.Name == "typebot" || user.Id == "U085QG8D7" {
			continue
		}
		_, _, chanId, err := api.OpenIMChannel(user.Id)
		if err != nil {
			fmt.Println("IM err ", err)
		}

		fmt.Println("formResp ", formResp)
		formDM := fmt.Sprintf("A form has been created, go fill it out! %v", formResp.Links[1].Href)

		api.PostMessage(chanId, formDM, slack.PostMessageParameters{
			AsUser: true,
		})
	}
}
開發者ID:zachgoldstein,項目名稱:typeformhackathon2015,代碼行數:27,代碼來源:main.go

示例2: dumpUsers

func dumpUsers(api *slack.Slack, dir string) {
	users, err := api.GetUsers()
	check(err)

	data, err := MarshalIndent(users, "", "    ")
	check(err)
	err = ioutil.WriteFile(path.Join(dir, "users.json"), data, 0644)
	check(err)
}
開發者ID:felag,項目名稱:slack-dump,代碼行數:9,代碼來源:main.go

示例3: dmAll

func dmAll(message string, api *slack.Slack) {

	users, err := api.GetUsers()
	if err != nil {
		fmt.Println("Channel err ", err)
	}

	for _, user := range users {
		if user.Name == "typebot" {
			continue
		}

		_, _, chanId, err := api.OpenIMChannel(user.Id)
		if err != nil {
			fmt.Println("IM err ", err)
		}
		api.PostMessage(chanId, message, slack.PostMessageParameters{
			AsUser: true,
		})
	}
}
開發者ID:zachgoldstein,項目名稱:typeformhackathon2015,代碼行數:21,代碼來源:main.go

示例4: updateUsers

func updateUsers(s *slack.Slack, db *sql.DB) error {
	users, err := s.GetUsers()
	if err != nil {
		return err
	}

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

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


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