diff --git a/get_all_groups.go b/get_all_groups.go new file mode 100644 index 0000000..f00739c --- /dev/null +++ b/get_all_groups.go @@ -0,0 +1,22 @@ +package main + +import ( + "fmt" + + "github.com/slack-go/slack" +) + +func getAllUserGroups() { + api := slack.New(slack_token()) + // If you set debugging, it will log all requests to the console + // Useful when encountering issues + // slack.New(slack_token(), slack.OptionDebug(true)) + groups, err := api.GetUserGroups(slack.GetUserGroupsOptionIncludeUsers(false)) + if err != nil { + fmt.Printf("%s\n", err) + return + } + for _, group := range groups { + fmt.Printf("ID: %s, Name: %s\n", group.ID, group.Name) + } +} diff --git a/get_user.go b/get_user.go new file mode 100644 index 0000000..3e7185e --- /dev/null +++ b/get_user.go @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + + "github.com/slack-go/slack" +) + +func getUserById(userId string) *slack.User { + api := slack.New(slack_token()) + user, err := api.GetUserInfo(userId) + if err != nil { + fmt.Printf("%s\n", err) + panic(err) + } + return user +} + +func getUserByEmail(email string) *slack.User { + api := slack.New(slack_token()) + user, err := api.GetUserByEmail(email) + if err != nil { + fmt.Printf("%s\n", err) + panic(err) + } + return user +} \ No newline at end of file diff --git a/main.go b/main.go new file mode 100644 index 0000000..38dd16d --- /dev/null +++ b/main.go @@ -0,0 +1,3 @@ +package main + +func main() {} diff --git a/slack_token.go b/slack_token.go new file mode 100644 index 0000000..e3369fd --- /dev/null +++ b/slack_token.go @@ -0,0 +1,10 @@ +package main + +import "os" + +func slack_token() string { + if token, ok := os.LookupEnv("SLACK_TOKEN"); ok { + return token + } + panic("SLACK_TOKEN environment variable not set") +}