Skip to content

Latest commit

 

History

History
104 lines (74 loc) · 2.98 KB

README.md

File metadata and controls

104 lines (74 loc) · 2.98 KB

InstallingExamplesBuild StatusLicense

This library supports most if not all of the api.slack.com REST calls, as well as the Real-Time Messaging protocol over websocket, in a fully managed way.

Installing

Before the initial install allows git to use redirects for pkg.re service (reason why you should do this described here):

git config --global http.https://pkg.re.followRedirects true

Make sure you have a working Go 1.7+ workspace (instructions), then:

go get pkg.re/essentialkaos/slack.v2

For update to latest stable release, do:

go get -u pkg.re/essentialkaos/slack.v2

Examples

Getting all groups

import (
  "fmt"

  "pkg.re/essentialkaos/slack.v2"
)

func main() {
  api := slack.New("YOUR_TOKEN_HERE")
  // If you set debugging, it will log all requests to the console
  // Useful when encountering issues
  // api.SetDebug(true)
  groups, err := api.GetGroups(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)
  }
}

Getting user information

import (
  "fmt"

  "pkg.re/essentialkaos/slack.v2"
)

func main() {
  api := slack.New("YOUR_TOKEN_HERE")
  user, err := api.GetUserInfo("U023BECGF")

  if err != nil {
    fmt.Printf("%s\n", err)
    return
  }

  fmt.Printf("ID: %s, Fullname: %s, Email: %s\n", user.ID, user.Profile.RealName, user.Profile.Email)
}

Minimal RTM usage

See example.

Build Status

Branch Status
master (Stable) Build Status
develop (Unstable) Build Status

License

BSD 2-Clause license