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

generator-slack-bot

v0.0.6

Published

Yeoman generator to create a Node Slack Bot

Downloads

26

Readme

About Slack bot Yeoman Generator

Full Yeoman Generator to create Slack Bot with travis, coveralls and test.

Installation

First, install Yeoman and generator-slack-bot using npm (we assume you have pre-installed node.js).

npm install -g yo
npm install -g generator-slack-bot

Then generate your new Bot:

yo slack-bot

Which will generate the following project structure, if for example your bot name is Mazinga:

├── travis.yml
├── gitignore
├── jscsrc
├── LICENSE
├── README.md
├── app.json
├── package.json
├── Gruntfile.js
├── configBot.json
├── grunt/coveralls.js
├── grunt/jscs.js
├── grunt/jshint.js
├── grunt/mocha_istanbul.js
├── grunt/mochaTest.js
├── src/slackMessageAnalyzer.js
├── src/main.js
├── src/botMazinga.js
├── test/botMazinga.spec.js
└── test/mockoBjects/channel.js

And run npm install for you to fetch all dependencies.

Getting Started with the bot

In order to make the bot works you need a TOKEN_SLACK. Your Slack bot integration token is obtainable at https://my.slack.com/services/new/bot. After you have obtained your TOKEN_SLACK copy it in the configBot.json

Main chunk of codes to understand in the generated bot

  1. slackMessageAnalyzer.js

In this class you are going to find all the utility in order to analyzer the slack message

Class | Method | Parameters | Description ------------ | ------------- | ------------- | ------------- slackMessageAnalyzer.js | createSlackMessageLink(titleLink, link) |@param {Boolean} @param {String} titleLink text to show instead of the pure URL @param {String} link to redirect | Create a slack link format message slackMessageAnalyzer.js | createSlackMessageLink(titleLink, link) |@param {String} textMessage message to analyze @param {String} textToSearch text to search in the message | Create a slack link format message isTextContainedInMessage

  1. yourBotName.js

In this class there are the listeners for the messages

Class | Method | Parameters | Description ------------ | ------------- | ------------- | ------------- yourBotName.js | _listenerMessage(condition, callback) |@param {Boolean} condition to meet to call the callback @param {Function} callback to call if the condition is satisfied | Call a callback in the case a message from slack meets the condition

Code Example

This pice of code below will activate a listner on the hello message and will answer in the general chat wit a mssage 'Hello Answer'

   _listenerHelloMessage() {
    this._listenerMessage(this.isHelloMessage, (function(message) {
      var message = 'Hello answer';
      var fallBack = 'Hello answer';
      var color = 'warning';
      var title = 'Hello Answer ' + slackMessageAnalyzer.createSlackMessageLink('made by slack bot generator','https://github.com/eromano/generator-slack-bot');

      this.postSlackMessage(message, fallBack, color, null, title, '', 'general');
    }).bind(this));
  }
  
  isHelloMessage(textMessage) {
    return slackMessageAnalyzer.isTextContainedInMessage(textMessage, 'hello');
  }

History

For detailed changelog, see Releases.

Contributors

Contributor | GitHub profile | Twitter profile | --- | --- | --- Eugenio Romano (contributor)| Eugenio Romano | @RomanoEugenio

All contributors contributors.

License

MIT