Giter VIP home page Giter VIP logo

hubot-pubsub's Introduction

hubot-pubsub

PubSub notification system for Hubot

Using Lita? Try lita-pubsub!

Build Status

hubot-pubsub demo

Book: Automation and Monitoring with Hubot

Automation and Monitoring with Hubot will show you how to build advanced monitoring systems with Hubot PubSub.

Possibilities

hubot-pubsub allows you to build a simple, yet powerful monitoring / notification system using your corporate chat (Campfire, HipChat, IRC, Jabber / XMPP or even Skype). Simply subscribe events in appropriate chat rooms and publish info about these events via HTTP calls or from other Hubot scripts when they happen.

             Hubot PubSub Event Flow

+--------------+ +--------------+ +---------------+
| hubot script | | HTTP Request | | chat message  |<--+
+-------+------+ +-------+------+ +-------+-------+   |
        |                |                |           |
        |                v                |           |
        |        +--------------+         |           |
        +------->| hubot-pubsub |<--------+           |
                 +-------+------+                     |
                         |                            |
                         v                            |
                 +--------------+                     |
             +---+     hubot    +---+                 |
             |   +--------------+   |                 |
             |                      |                 |
             v                      v                 |
       +---------------+  +---------------+           |
       |  chatroom #1  |  |  chatroom #2  +-----------+
       +---------------+  +---------------+

Installing

Add dependency to package.json:

$ npm install --save hubot-pubsub

Include package in Hubot's external-scripts.json:

["hubot-pubsub"]

Configuration

HUBOT_SUBSCRIPTIONS_PASSWORD   # Optional password for protecting HTTP API calls
HUBOT_PUBSUB_SEND_EVENT_NAME   # Optional boolean determines whether the event name is prefixed on delivered messages (defaults to true)
HUBOT_PUBSUB_DATA_AS_JSON      # Optional boolean determines whether the event data is parsed as a JSON object 
                               # and sent as such (defaults to false)
                               # Useful to post to a Slack channel with rich formatting and attachments

Commands

hubot subscribe <event>        # subscribes current room to event
hubot unsubscribe <event>      # unsubscribes current room from event
hubot unsubscribe all events   # unsubscribes current room from all events
hubot subscriptions            # show subscriptions of current room
hubot all subscriptions        # show all existing subscriptions
hubot publish <event> <data>   # triggers event

HTTP API

GET /publish

GET /publish?event=<event>&data=<text>[&password=<password>]

POST /publish

POST /publish
  • Content-Type: application/json
  • Body: { "password": "optional", "event": "event", "data": "text" }

Event Namespaces

Hubot PubSub uses . as event namespace separator. I.e.: subscribing to x.y also subscribes to x.y.* events.

Publishing events from other scripts

Emit pubsub:publish event from any other Hubot script to publish something via hubot-pubsub:

robot.emit 'pubsub:publish', 'news', 'Publishing some news from another script'

Handling unsubscribed events

Do hubot subscribe unsubscribed.event in a room where you want all unrouted events to get announced.

Issues

  • HTTP password based security is weak - don't use it in public network to publish events with sensitive data

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.