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 with npm
$ npm i githubbot --save
var bot = require('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();
Array of event types from https://developer.github.com/v3/activity/events/types/
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);
});
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);
});
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);
});
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);
});
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);
});
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);
});
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);
});
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);
});
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);
});
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);
});
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);
});
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);
});
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);
});
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);
});
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);
});
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);
});
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);
});
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);
});
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);
});
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);
});
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);
});
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);
});
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);
});
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);
});
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);
});
- 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
Install dev dependencies:
$ npm i -d && npm test
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Brian Woodward
Copyright © 2015 Brian Woodward Released under the MIT license.
This file was generated by verb on December 22, 2015.