npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

beerbot

v0.4.0

Published

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

Downloads

14

Readme

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