Skip to content

skybet/slack

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

About

Simple go package for bootstraping Slack bots

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 99.6%
  • Makefile 0.4%