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

norrisbot

v2.0.5

Published

A Slack bot that kicks asses (roundhouse-kicks to be accurate...)

Downloads

36

Readme

norrisbot

CircleCI npm version codecov Known Vulnerabilities

Make your team hyper-productive with cutting Chuck Norris jokes

The NorrisBot is a Slack bot that kicks asses, roundhouse-kicks to be precise... It's super-powered with Chuck Norris jokes and it aims to make your Slack channel even more "slacker" and enjoyable.

Chuck Norris face

NorrisBot is loaded with guns and jokes about Chuck Norris and it will tell a random joke every time that someone says “Chuck Norris” or "norrisbot" in a slack channel.

Norrisbot in action

Installation

As simple as installing any other global node package. Be sure to have npm and node (>= 4.3.2 version) installed and launch:

$ npm install -g norrisbot

Alternative Installation (binaries)

From release 2.0.3, every release comes also with dependency-free binaries for linux, mac and windows that can be downloaded in the Releases page on GitHub.

Running the NorrisBot

To run the NorrisBot you must have a valid Slack BOT token to authenticate the bot on your slack organization. Once you get it (instructions on the next paragraph) you just have to run:

NORRISBOT_TOKEN=somesecretkey norrisbot

Once the bot is up and running, you need to invite him into the channels you want it to be available in.

Getting the BOT token for your Slack channel

To allow the NorrisBot to connect your Slack channel you must provide him a BOT token. To retrieve it you need to add a new Bot in your Slack organization by visiting the following url: https://yourorganization.slack.com/services/new/bot, where yourorganization must be substituted with the name of your organization (e.g. https://loige.slack.com/services/new/bot). Ensure you are logged to your Slack organization in your browser and you have the admin rights to add a new bot.

You will find your BOT token under the field API Token, copy it in a safe place and get ready to use it.

As an alternative you can create a bot by creating a custom application in the Slack developer portal. Inside the application settings you will be able to add a bot user and retrieve a OAUTH BOT token for it.

Configuration

The NorrisBot is configurable through environment variables. There are several variable available:

| Environment variable | Description | |----------------------|-------------| | NORRISBOT_TOKEN | The Slack Bot User OAuth Access Token for your organisation/team (mandatory) | | NORRISBOT_TRIGGERS | A coma separated list of words that triggers the bot to reply with a joke (default: "Chuck Norris,norrisbot") | | NORRISBOT_CATEGORIES | A coma separated list to enable special joke categories like "explicit" and "nerdy" (default: "nerdy") | | NORRISBOT_NO_PICTURES | If set to TRUE will disable pictures in jokes (default: FALSE) | | NORRISBOT_MESSAGE_COLOR | The hex color used by the bot to mark it's messages (default: "#590088") |

Installing on Heroku

A great place where to deploy our lovely NorrisBot is Heroku. We can go reasonably well with their free worker tier and the deploy process is reasonably easy and convenient. Let’s see how we can do that.

I am assuming you already have and account on Heroku and that you have installed and configured the Heroku toolbelt on your machine.

1. Create a new Heroku app

Create a local folder and install norrisbot on it:

mkdir norrisbot-myorg
cd norrisbot-myorg
npm init -y
npm i --save norrisbot

Then create a new app on heroku:

heroku create norrisbot-myorg

2. Configure your Heroku app:

heroku config:set --app norrisbot-myorg NORRISBOT_TOKEN=xoxb-YOUR-AWESOME-BOT-TOKEN

(of course you need to replace xoxb-YOUR-AWESOME-BOT-TOKEN with your actual token).

You can add extra configuration by defining values for the other supported environment variables if you want to customize the behavior of the bot.

3. Initialize your Heroku app

Create an Heroku Procfile (service definition)

echo "worker: node_modules/.bin/norrisbot" >> Procfile

Then prepare the project to be published through git:

git init
echo "node_modules/" >> .gitignore
git add --all
git commit -am "first version"
heroku git:remote --app norrisbot-myorg

4. Publish and launch the Heroku app

Through heroku git

git push heroku master

Stop the web app (not present but started by default by Heroku) and run the worker:

heroku ps:scale web=0 worker=1

That's it, now go on your Slack organization and start enjoying Chuck Norris jokes! 😂

Building the bot from source

If you downloaded the source code of the bot you can build the bot with

npm run build

Then you can run it with:

$ npm start

Don't forget to set your NORRISBOT_TOKEN environment variable bedore doing so and to install all the dependencies (including dev ones with NPM or Yarn).

Bugs and improvements

If you find a bug or have an idea about how to improve the NorrisBot you can open an issue or submit a pull request, it will definitely make you a better person! :P

The Making of

Version 1 of NorrisBot has been developed in collaboration with Scotch.io. A very detailed article has been published to explain every single line of code. It also explains you how to deploy the bot on a free Heroku instance, so you should give it a shot!

Building a Slack Bot with Node.js and Chuck Norris Super Powers

Enjoy your reading!

License

Licensed under MIT License. © Luciano Mammino.