Example #1
0
File: main.go Project: ewok/tools
func updateDutyGroup(api *slack.Client, groupName string) {

	allChanenels, err := api.GetChannels(true)
	if err != nil {
		panic("Cannot get all channels")
	}

	allGroups, err := api.GetGroups(true)
	if err != nil {
		panic("Cannot get all groups")
	}

	var dutyChannel *slack.Channel
	for _, v := range allChanenels {

		if v.Name == groupName {

			dutyChannel, err = api.GetChannelInfo(v.ID)
			if err != nil {
				panic(err)
			}
			dutyMembers = dutyChannel.Members
		}
	}

	var dutyGroup *slack.Group
	for _, v := range allGroups {

		if v.Name == groupName {

			dutyGroup, err = api.GetGroupInfo(v.ID)
			if err != nil {
				panic(err)
			}

			dutyMembers = dutyGroup.Members

		}
	}
	if dutyChannel == nil && dutyGroup == nil {
		panic("Duty group not found")
	}

	fmt.Printf("Alld duties %s\n", dutyMembers)

}