Socket
Book a DemoInstallSign in
Socket

beerbot

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

beerbot

BeerBot is an extensible and real time bot for Slack.com

0.4.0
latest
Source
npmnpm
Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

beerbot NPM version Build Status Dependency Status

Slack Beer Bot for Build Failures

A Slack bot which will listen to channels and will automatically reply with a custom message and a gif generated from giphy when message matches the given pattern.

Why?

Because the one which breaks the build have to bring beers for ALL the team!

Build Broken Message

So this is just to remind him with a message and a random beer gif:

Lets get beers

The Beerbot was originally created for fun, to pollute Slack channels with funky gifs. But now, it can also be used to create integrations with Slack without having to consume official Slack integration limits.

Default Features

  • Listen to CI build failures on a channel and send a random beer gif to a channel
  • Create Hublin video conference: '@bot !hublin' will create a conference on Hubl.in with the current channel name.

Install

$ npm install --save beerbot

Usage

From configuration

var BeerBot = require('beerbot');
var token = 'xoxs-YOUR-TOKEN'; // check the slack API doc

// let's have beers when the build is broken, and let's celebrate when it is back!
var options = {
  token: token,
  silent: false,
  logger: {
    level: 'info'
  },
  plugins: [
    {
      name: 'beerbot-giphy',
      listen_on: ['#jenkins'],
      reply_on: '#general',
      response: 'Build failure, let\'s have beer!',
      match: /Failure after/,
      term: 'beer'
    }, {
      name: 'beerbot-giphy',
      listen_on: ['#jenkins'],
      reply_on: '#general',
      response: 'Yeah, build is back!',
      match: /Back to normal after/,
      term: 'celebrate'
    }
  ]
};

var bot = new BeerBot(options);
bot.on('connected', function() {
  console.log('Bot is started');
});

bot.on('error', function(err) {
  console.error('Error while starting bot', err);
});

bot.start();

You can directly adapt and use ./bin/beerbot.js:

$ SLACK_TOKEN=xoxs-YOUR-TOKEN node bin/beerbot.js

From the BeerBot API

'use strict';

var BeerBot = require('beerbot');
var options = {
  token: 'xoxp-YOUR-TOKEN', // check https://api.slack.com/web
  silent: false,
  logger: {
    level: 'debug'
  }
};

var yoloOptions = {
  listen_on: ['#general'],
  reply_on: '#general',
  response: 'You said: '
};

var bot = new BeerBot(options);

bot.listen(/YOLO/, yoloOptions, function() {
  return bot.q.resolve('YOLO');
});

bot.on('connected', function() {
  console.log('Yolo Bot is started');
});

bot.on('error', function(err) {
  console.error('Error while starting bot', err);
});

bot.start();

API

Beerbot

  • Beerbot provides q and request so they can be use in plugins without requiring them.
var bot = new BeerBot(options);
bot.request('http://www.google.com', function (error, response, body) {
  if (!error && response.statusCode == 200) {
    console.log(body) // Show the HTML for the Google homepage.
  }
});

Default Listener

Options

  • listen_on: Array of channels to listen on. Note that this will not subscribe to channels if the beerbot is not already in the defined channels. It is just a filter to process message on defined channels when received.
  • reply_on: The channel to send back response to. If not defined, the response is sent to the channel on which the message is received.
  • response: The prefix to add to the response generated by your message handler.
  • match: The regular expression applied on the message or a function like function(message, bot) which must return a boolean. If the message matches the regex or if the function returns true, the message handler is called.

License

MIT © Christophe Hamerling

Keywords

slack

FAQs

Package last updated on 30 Nov 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.