예제 #1
0
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,
		})
	}
}
예제 #2
0
func dmPerson(user *slack.User, message string, api *slack.Slack) {
	if user.Name == "typebot" {
		return
	}

	_, _, chanId, err := api.OpenIMChannel(user.Id)
	if err != nil {
		fmt.Println("IM err ", err)
	}
	api.PostMessage(chanId, message, slack.PostMessageParameters{
		AsUser: true,
	})
}
예제 #3
0
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,
		})
	}
}