Code Monkey home page Code Monkey logo

go-slackgw's Introduction

go-slackgw

Yet Another Slack Gateway

Features

  • HTTP interface to allow easy integration within trusted environments
  • RTM interface that allows you to queue/process incoming messages

HTTP interface

Send a message

First, start the server (127.0.0.1:4979):

slackgw \
    -token=/path/to/tokenfile

Then send a POST message:

curl -XPOST http://slackgw:4979/post -d "channel=#updates&message=test" 

This is great for your organization/company wide monitoring tools and such, especially when you have lots of tools that may want to post messages to slack, and you are too lazy creating tokens for each bot you have.

Do NOT open this up for the wider internet.

RTM interface

Queue incoming message events to Google PubSub

slackgw \
    -rtm=gpubsub-forward \
    -event=MessageEvent \
    -topic=projects/:project_id:/topics/:topic: \
    -token=/path/to/tokenfile

Or, embed in some other slack integration of yours:

  hctx := context.Background()
  httpcl, err := google.DefaultClient(hctx, pubsub.PubsubScope)
  if err != nil {
    return fmt.Errorf("Failed to create default oauth client: %s", err)
  }
  pubsubsvc, err := pubsub.New(httpcl)
  if err != nil {
    return fmt.Errorf("Failed to create pubsub client: %s", err)
  }
  s := slackgw.New()
  s.StartSlack(token)
  s.StartRTM(gcp.NewPubsubForwarder(pubsubsvc, topic, slackgw.MessageEvent))

  // other initializations follow...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.