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

opsbot

v3.0.4

Published

hermione the npm operations chat bot

Downloads

34

Readme

opsbot

Hermione the npm operations Slack chat battlestation is fully operational and is capable of demonstrating its power on a target, a military target. Name the system!

on npm Tests Coverage Status Dependencies

deploying

You'll want to create your own little node package for your installation. This package needs a package.json, a configuration file, and a shell script to run the bot.

Here's a nice minimal package.json, requiring opsbot & a third-party plugin:

{
  "name": "deathstar",
  "version": "0.0.0",
  "description": "a bot of destruction",
  "scripts": {
    "start": "opsbot config.js",
    "dev": "NODE_ENV=dev opsbot testconfig.js"
  },
  "dependencies": {
    "opsbot": "~3.0.0",
    "opsbot-owl": "^0.0.1"
  }
}

To create your configuration file, start by copying config.example.js. Edit to your taste. You can have it log to console and/or log to a file depending on how you want to keep its logs. npm start runs the bot in prod mode. npm run dev will run it with pretty-printed console output.

List the plugins you want to load as fields in the plugins hash. The value should be an object with any required configuration for the plugin. Note that opsbot can load both built-in plugins and plugins installed via npm.

Example configuration:

{
	botname: "hermione",
	admin_channel: "your-admin-channel-id",
	brain: { dbpath: "./db" },
	plugins:
	{
		bartly:
		{
			apikey: "your-bart-api-key",
			station: "powl",
			tzOffset: 420,
		},
	}
}

Create a Slack bot and copy its API key. You must provide that key in the environment variable SLACK_TOKEN. One way to do that is to create a .env file containing the text SLACK_TOKEN=your-token-here. Opsbot will read that file if it's present.

built-in commands

botname: help: return a help message

botname: status: gives bot uptime, loaded plugins, and location of the bot's brain.

writing plugins

Plugs in are yargs command modules. To write a plugin, write a yargs command and then load it into opsbot via config. The handler for the yargs command has an object with all the usual yargs parsed items in it, plus a reply() function that can be called as many times as you wish to post messages to the Slack channel the original command came from.

reply('string of text') posts the given string of text.

reply(messsageObj) posts a message as formatted according to the Slack message API.

Here's very boring plugin.

function builder(yargs) {}

function handler(argv)
{
	argv.reply('https://cldup.com/5B3kURG8aE.jpg');
}

module.exports = {
	command: 'ORLY <text...>',
	describe: 'If you say ORLY?, you get the obvious response.',
	builder: builder,
	handler: handler
};

Let's suppose we've published this on npm as opsbot-owl. To load this epic chatbot feature, you'd add the module as a dependency of your bot package and then mention it in the config like this:

{
	botname: "wol",
	admin_channel: "your-admin-channel-id",
	plugins:
	{
		"opsbot-owl": true
	}
}

Provided plugins

bartly: Real-time BART departure information by station. Requires an API key and, of all things, a timezone offset. flip: Table flip!
rageflip: Really table flip!
karma: Give points and take them away. Requires a database. npm: Fetch package information from npm.
statuscats: Show an http status cat.
statuscats: Show an http status dog.
morph: Morph one word into another using a nice short path.

Each plugin has more documentation at the top of its source file.

Plugin storage

Opsbot uses levelup to provide a persistent key/value brain to plugins. Each plugin is, on construction, given an options object with a sublevel-namespaced db object in the brain field. This object might not be available if the opsbot configuration hasn't given it a path to store the db in, so your plugin should assert if it requires the brain but is not given one. See an example in the built-in karma plugin.

Contributing

Write more plugins, add features to the existing plugins, it's all good.

Please follow the code style in existing files. npm run lint catches style problems as well as bugs. xo --fix might or might not actually fix them. If you write your own plugins, I don't much care what you do. Please try to be at least as responsible as I have been about writing tests.

If you want to use promises, go ahead! bluebird is already in the package deps.

If you write a plugin for opsbot & publish it on npm, please let me know so I can link it here! It might also help to give it the keyword opsbot so other people can find it when they search.

License

ISC