githubbot

0.1.2 • Public • Published

githubbot NPM version

Starting point for registering event handlers and handling payloads coming from github webhooks. Allows usage of plugins to extend functionality for individual implementations.

The main purpose of this module is to create a starting point for registering github webhook event handlers and triggering the handlers with a payload.

The actual web server pieces of handling github webhooks are not included in this module. See related-projects for usage with web servers and other implementations.

(TOC generated by verb)

Install

Install with npm

$ npm i githubbot --save

Usage

var bot = require('githubbot');

API

GithubBot

Create a new instance of a GithubBot with provided options.

Params

  • options {Object}: Options to configure the github bot.

Example

var bot = new GithubBot();

Events

Array of event types from https://developer.github.com/v3/activity/events/types/

commit-comment

Github webhook commit-comment event. Find more information about the payload for this event here.

Listen for this event registering a handler with the .onCommitComment(fn) method. Handle events by calling the .handleCommitComment(payload) method.

// listen for commit-comment events.
bot.onCommitComment(function(payload, cb) {
  // handle payload
  cb(null, payload);
});
 
// handle a payload for the commit-comment event.
bot.handleCommitComment(payload, function(err, results) {
  if (err) return console.log(err);
  console.log(results);
});

create

Github webhook create event. Find more information about the payload for this event here.

Listen for this event registering a handler with the .onCreate(fn) method. Handle events by calling the .handleCreate(payload) method.

// listen for create events.
bot.onCreate(function(payload, cb) {
  // handle payload
  cb(null, payload);
});
 
// handle a payload for the create event.
bot.handleCreate(payload, function(err, results) {
  if (err) return console.log(err);
  console.log(results);
});

delete

Github webhook delete event. Find more information about the payload for this event here.

Listen for this event registering a handler with the .onDelete(fn) method. Handle events by calling the .handleDelete(payload) method.

// listen for delete events.
bot.onDelete(function(payload, cb) {
  // handle payload
  cb(null, payload);
});
 
// handle a payload for the delete event.
bot.handleDelete(payload, function(err, results) {
  if (err) return console.log(err);
  console.log(results);
});

deployment

Github webhook deployment event. Find more information about the payload for this event here.

Listen for this event registering a handler with the .onDeployment(fn) method. Handle events by calling the .handleDeployment(payload) method.

// listen for deployment events.
bot.onDeployment(function(payload, cb) {
  // handle payload
  cb(null, payload);
});
 
// handle a payload for the deployment event.
bot.handleDeployment(payload, function(err, results) {
  if (err) return console.log(err);
  console.log(results);
});

deployment-status

Github webhook deployment-status event. Find more information about the payload for this event here.

Listen for this event registering a handler with the .onDeploymentStatus(fn) method. Handle events by calling the .handleDeploymentStatus(payload) method.

// listen for deployment-status events.
bot.onDeploymentStatus(function(payload, cb) {
  // handle payload
  cb(null, payload);
});
 
// handle a payload for the deployment-status event.
bot.handleDeploymentStatus(payload, function(err, results) {
  if (err) return console.log(err);
  console.log(results);
});

download

Github webhook download event. Find more information about the payload for this event here.

Listen for this event registering a handler with the .onDownload(fn) method. Handle events by calling the .handleDownload(payload) method.

// listen for download events.
bot.onDownload(function(payload, cb) {
  // handle payload
  cb(null, payload);
});
 
// handle a payload for the download event.
bot.handleDownload(payload, function(err, results) {
  if (err) return console.log(err);
  console.log(results);
});

follow

Github webhook follow event. Find more information about the payload for this event here.

Listen for this event registering a handler with the .onFollow(fn) method. Handle events by calling the .handleFollow(payload) method.

// listen for follow events.
bot.onFollow(function(payload, cb) {
  // handle payload
  cb(null, payload);
});
 
// handle a payload for the follow event.
bot.handleFollow(payload, function(err, results) {
  if (err) return console.log(err);
  console.log(results);
});

fork

Github webhook fork event. Find more information about the payload for this event here.

Listen for this event registering a handler the .onFork(fn) method. Handle events by calling the .handleFork(payload) method.

// listen for fork events.
bot.onFork(function(payload, cb) {
  // handle payload
  cb(null, payload);
});
 
// handle a payload for the fork event.
bot.handleFork(payload, function(err, results) {
  if (err) return console.log(err);
  console.log(results);
});

fork-apply

Github webhook fork-apply event. Find more information about the payload for this event here.

Listen for this event registering a handler with the .onForkApply(fn) method. Handle events by calling the .handleForkApply(payload) method.

// listen for fork-apply events.
bot.onForkApply(function(payload, cb) {
  // handle payload
  cb(null, payload);
});
 
// handle a payload for the fork-apply event.
bot.handleForkApply(payload, function(err, results) {
  if (err) return console.log(err);
  console.log(results);
});

gist

Github webhook gist event. Find more information about the payload for this event here.

Listen for this event registering a handler the .onGist(fn) method. Handle events by calling the .handleGist(payload) method.

// listen for gist events.
bot.onGist(function(payload, cb) {
  // handle payload
  cb(null, payload);
});
 
// handle a payload for the gist event.
bot.handleGist(payload, function(err, results) {
  if (err) return console.log(err);
  console.log(results);
});

gollum

Github webhook gollum event. Find more information about the payload for this event here.

Listen for this event registering a handler with the .onGollum(fn) method. Handle events by calling the .handleGollum(payload) method.

// listen for gollum events.
bot.onGollum(function(payload, cb) {
  // handle payload
  cb(null, payload);
});
 
// handle a payload for the gollum event.
bot.handleGollum(payload, function(err, results) {
  if (err) return console.log(err);
  console.log(results);
});

issue-comment

Github webhook issue-comment event. Find more information about the payload for this event here.

Listen for this event registering a handler with the .onIssueComment(fn) method. Handle events by calling the .handleIssueComment(payload) method.

// listen for issue-comment events.
bot.onIssueComment(function(payload, cb) {
  // handle payload
  cb(null, payload);
});
 
// handle a payload for the issue-comment event.
bot.handleIssueComment(payload, function(err, results) {
  if (err) return console.log(err);
  console.log(results);
});

issues

Github webhook issues event. Find more information about the payload for this event here.

Listen for this event registering a handler with the .onIssues(fn) method. Handle events by calling the .handleIssues(payload) method.

// listen for issues events.
bot.onIssues(function(payload, cb) {
  // handle payload
  cb(null, payload);
});
 
// handle a payload for the issues event.
bot.handleIssues(payload, function(err, results) {
  if (err) return console.log(err);
  console.log(results);
});

member

Github webhook member event. Find more information about the payload for this event here.

Listen for this event registering a handler with the .onMember(fn) method. Handle events by calling the .handleMember(payload) method.

// listen for member events.
bot.onMember(function(payload, cb) {
  // handle payload
  cb(null, payload);
});
 
// handle a payload for the member event.
bot.handleMember(payload, function(err, results) {
  if (err) return console.log(err);
  console.log(results);
});

membership

Github webhook membership event. Find more information about the payload for this event here.

Listen for this event registering a handler with the .onMembership(fn) method. Handle events by calling the .handleMembership(payload) method.

// listen for membership events.
bot.onMembership(function(payload, cb) {
  // handle payload
  cb(null, payload);
});
 
// handle a payload for the membership event.
bot.handleMembership(payload, function(err, results) {
  if (err) return console.log(err);
  console.log(results);
});

page-build

Github webhook page-build event. Find more information about the payload for this event here.

Listen for this event registering a handler with the .onPageBuild(fn) method. Handle events by calling the .handlePageBuild(payload) method.

// listen for page-build events.
bot.onPageBuild(function(payload, cb) {
  // handle payload
  cb(null, payload);
});
 
// handle a payload for the page-build event.
bot.handlePageBuild(payload, function(err, results) {
  if (err) return console.log(err);
  console.log(results);
});

public

Github webhook public event. Find more information about the payload for this event here.

Listen for this event registering a handler with the .onPublic(fn) method. Handle events by calling the .handlePublic(payload) method.

// listen for public events.
bot.onPublic(function(payload, cb) {
  // handle payload
  cb(null, payload);
});
 
// handle a payload for the public event.
bot.handlePublic(payload, function(err, results) {
  if (err) return console.log(err);
  console.log(results);
});

pull-request

Github webhook pull-request event. Find more information about the payload for this event here.

Listen for this event registering a handler with on-puthe.on-pull-request(fn)method. Handle events by calling the.handle-pull-request(payload)` method.

// listen for pull-request events.
bot.onPullRequest(function(payload, cb) {
  // handle payload
  cb(null, payload);
});
 
// handle a payload for the pull-request event.
bot.handlePullRequest(payload, function(err, results) {
  if (err) return console.log(err);
  console.log(results);
});

pull-request-review-comment

Github webhook pull-request-review-comment event. Find more information about the payload for this event here.

Listen for this event registering a handler with the .onPullRequestReviewComment(fn) method. Handle events by calling the .handlePullRequestReviewComment(payload) method.

// listen for pull-request-review-comment events.
bot.onPullRequestReviewComment(function(payload, cb) {
  // handle payload
  cb(null, payload);
});
 
// handle a payload for the pull-request-review-comment event.
bot.handlePullRequestReviewComment(payload, function(err, results) {
  if (err) return console.log(err);
  console.log(results);
});

push

Github webhook push event. Find more information about the payload for this event here.

Listen for this event registering a handler the .onPush(fn) method. Handle events by calling the .handlePush(payload) method.

// listen for push events.
bot.onPush(function(payload, cb) {
  // handle payload
  cb(null, payload);
});
 
// handle a payload for the push event.
bot.handlePush(payload, function(err, results) {
  if (err) return console.log(err);
  console.log(results);
});

release

Github webhook release event. Find more information about the payload for this event here.

Listen for this event registering a handler with the .onRelease(fn) method. Handle events by calling the .handleRelease(payload) method.

// listen for release events.
bot.onRelease(function(payload, cb) {
  // handle payload
  cb(null, payload);
});
 
// handle a payload for the release event.
bot.handleRelease(payload, function(err, results) {
  if (err) return console.log(err);
  console.log(results);
});

repository

Github webhook repository event. Find more information about the payload for this event here.

Listen for this event registering a handler with the .onRepository(fn) method. Handle events by calling the .handleRepository(payload) method.

// listen for repository events.
bot.onRepository(function(payload, cb) {
  // handle payload
  cb(null, payload);
});
 
// handle a payload for the repository event.
bot.handleRepository(payload, function(err, results) {
  if (err) return console.log(err);
  console.log(results);
});

status

Github webhook status event. Find more information about the payload for this event here.

Listen for this event registering a handler with the .onStatus(fn) method. Handle events by calling the .handleStatus(payload) method.

// listen for status events.
bot.onStatus(function(payload, cb) {
  // handle payload
  cb(null, payload);
});
 
// handle a payload for the status event.
bot.handleStatus(payload, function(err, results) {
  if (err) return console.log(err);
  console.log(results);
});

team-add

Github webhook team-add event. Find more information about the payload for this event here.

Listen for this event registering a handler with the .onTeamAdd(fn) method. Handle events by calling the .handleTeamAdd(payload) method.

// listen for team-add events.
bot.onTeamAdd(function(payload, cb) {
  // handle payload
  cb(null, payload);
});
 
// handle a payload for the team-add event.
bot.handleTeamAdd(payload, function(err, results) {
  if (err) return console.log(err);
  console.log(results);
});

watch

Github webhook watch event. Find more information about the payload for this event here.

Listen for this event registering a handler with the .onWatch(fn) method. Handle events by calling the .handleWatch(payload) method.

// listen for watch events.
bot.onWatch(function(payload, cb) {
  // handle payload
  cb(null, payload);
});
 
// handle a payload for the watch event.
bot.handleWatch(payload, function(err, results) {
  if (err) return console.log(err);
  console.log(results);
});

Related projects

  • base-bot: Simple bot that knows how to handle events when told too. Use base bot to… more | homepage
  • base-methods: base-methods is the foundation for creating modular, unit testable and highly pluggable node.js applications, starting… more | homepage

Running tests

Install dev dependencies:

$ npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Author

Brian Woodward

License

Copyright © 2015 Brian Woodward Released under the MIT license.


This file was generated by verb on December 23, 2015.

Readme

Keywords

none

Package Sidebar

Install

npm i githubbot

Weekly Downloads

5

Version

0.1.2

License

MIT

Last publish

Collaborators

  • doowb