Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add basic functions #1

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions get_all_groups.go
Original file line number Diff line number Diff line change
@@ -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)
}
}
27 changes: 27 additions & 0 deletions get_user.go
Original file line number Diff line number Diff line change
@@ -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
}
3 changes: 3 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package main

func main() {}
10 changes: 10 additions & 0 deletions slack_token.go
Original file line number Diff line number Diff line change
@@ -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")
}