Skip to content

Instantly share code, notes, and snippets.

@rickt
Created March 5, 2016 00:32
Show Gist options
  • Select an option

  • Save rickt/856ba20300badfcfe36f to your computer and use it in GitHub Desktop.

Select an option

Save rickt/856ba20300badfcfe36f to your computer and use it in GitHub Desktop.
slack mini "sniffer", connects to slack and outputs the messages received over the slack websocket
package main
import (
"fmt"
"github.com/nlopes/slack"
)
func main() {
// create new slack object & connect
api := slack.New("TOKEN_REDACTED")
api.SetDebug(true)
rtm := api.NewRTM()
// lets do it
go rtm.ManageConnection()
// loop() and listen for inbound messages
for {
select {
case msg := <-rtm.IncomingEvents:
fmt.Print("Event Received: ")
fmt.Printf(" %s\n", msg.Data)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment