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

slackbotify

v0.4.3

Published

Simple slackbot framework

Downloads

12

Readme

slackbotify

XO code style npm

Simple slackbot framework

Installation

npm install slackbotify

Usage

Creating a slackbot is as easy require the dependency, load the config and register a handler. Run it. Done. Slackbot is ready!

const Bot = require('slackbotify');

let bot = new Bot({
	"bot": {
		"token": "xoxb-XXXXX-XXXXX",
		"name": "butler"
	}
});

bot.registerHandler({
	groups: ['direct'],
	match: /hi/ig,
	handler: function (message, callback) {
		callback('Hi there! :smiley:');
	}
});

bot.registerHandler({
	groups: ['channel', 'direct'],
	match: /:smile:/ig,
	handler: function (message, callback) {
		callback(':slightly_smiling_face:');
	}
});

bot.run();

Configuration

The only thing you have to pass to the constructor is a config object, and this config object should have at least a bot object with 2 properties: token & name. (example above)

Handlers

To register a handler to the bot simple pass an object to the registerHandler function. This object needs to contain the following properties: group, match, handler.

Group

The group defines where the command is available. There are 3 groups. channel, direct, admin. Handlers which are registered to the 'channel' group will fire when a message is send in a channel where the bot is invited to. 'Direct' handlers are private messages to the bot, and the 'admin' group handlers can only be called by an admin user in a private message.

A handler can be registered to multiple groups. In the example above the first handler is listening to direct messages only. The second handler will be called when a :smile: is send in a private message or in a channel where the bot is in.

Match

The 'match' property is what the message should match in order to get called. This can be a regex or a string.

Handler

The handler is a function which receives as the first argument the slack message object. The result of the matched message is located at message.matchResult this is the parsed result by the .match() function. The second argument is the callback. The response you give to that callback is send to the user, so basically what the bot will answer.

Bots

The current bots are using slackbotify

License

MIT