这是indexloc提供的服务,不要输入任何密码
Skip to content

folpindo/goslack

Repository files navigation

goslack

A Slack client library for Golang, updated with new features as I need them

Installation

go get github.com/doozr/goslack

What's included so far?

  • Connecting to Slack and the Real Time API
  • Getting a list of all users
  • Getting a list of all non-Archived public channels
  • Reading and Posting messages via the RTM

Example

connection, err := goslack.New(token)
if err != nil {
    log.Fatal(err)
}

for {
    event := <-connection.RealTime

    if event.Type == "message" {
        message, err := event.RtmMessage()
        // do something with message
        connection.PostRealTimeMessage(
            message.Channel,
            fmt.Sprintf("<@%s> Hello!", message.User))
    }

    if event.Type == "user_change" {
        userChange, err := event.RtmUserChange()
        // do something with userChange
    }
}

About

A Slack client library for Golang, updated with new features as I need them

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages