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

super-slack-bot

v0.3.1

Published

Slack bot framework for build platform

Downloads

17

Readme

Short description :

The basic idea of the platform, to create a complete tool to work with bots in the environment slack.

Usually we do not want to disassemble authentication, application architecture and implementation for various protocols.

We just want to add configuration and quick to develop, so go ahead!

Requirement

Node js version 9.3.0
The app is under development(WIP)

Installation

npm install super-slack-bot

Environment variables

In the spirit The Twelve-Factor App all changing the configuration are set via environment variables.

You need create file .env in your directory and add variables.

List variables

| Variable name | Description | |--------------------------|----------------------------------------------------------------------------------------| | SLACK_CLIENT_ID | you can find inside of your application under "Basic Information" -> "App Credentials" | | SLACK_CLIENT_SECRET | you can find inside of your application under "Basic Information" -> "App Credentials" | | SLACK_BOT_TOKEN | Token you can get a temporary or passing authentication | | SLACK_BOT_NAME | you can find inside of your application under "Bot User" | | SLACK_VERIFICATION_TOKEN | you can find inside of your application under "Basic Information" -> "App Credentials" | | PORT_SERVER | PORT server for conversation and command |

Message

Message is of the basic concepts. There are 4 main types:

  • message.channels - for messages appearing within channels
  • message.im - for messages appearing within direct messages
  • message.groups - for messages appearing within private channels
  • message.mpim - for messages appearing within multiparty direct messages

more can be read here

Those are 4 basic concepts, they are inherited from all other subtypes.

Conversation or Interactive

In documentation you can read more.

Short, interactive messages differ from ordinary messages.

Interaction to push data in other url, which will choose in your app.

It doesn't work with web-socket, but for you it will not be quite noticeable.

Specify url
  • You must go to your app
  • Next step : Features -> Interactive Components
  • Insert your url

Example https://url/conversation

Note: For testing you can use ngrok.

He is create secure tunnel for your localhost.

// listen event 'conversation'
// in route we need to pass 'callback_id'
bot.on('conversation', async (route, response) => {
    // responseInitiator json which is refundable after the reaction
    route('welcome_button', function (responseInitiator, classConversation) {
        response.end('ok');
    });
});

Slash Commands

Read more

Commands are very similar to conversation.

They have separete url and not working with web-socket.

Specify url
  • You must go to your app
  • Next step : Features -> Slash Commands
  • Create new command and insert your url with prefix /commands

When a request comes in, it checks team_id and token verification, if not checked return response code 401.

// listen event 'command'
bot.on('command', async (route, response) => {
    route('/start', (responseInitiator, classCommand) => {
        response.end();
    });
});

Console

List commands

  • server

    Options

    • start - Start server
  • show

    Options:

    • events - A list of all available events

Tutorial on the use

Start
// include env variables
require('dotenv').config();
// require package
const SlackBot = require('./BaseBot');
// pass name and token bot
const bot = new SlackBot({
    token: process.env.SLACK_BOT_TOKEN,
    name: process.env.SLACK_BOT_NAME,
});
Listen event
// first argument pass type event 
// list event you can watch using the command : show events

// second callback where two arguments:
// - object Route for match regexp or string
// - object Route for match regexp or string if the message mentioned our bot

bot.on('message.channels', (route, routeMention) => {
    // route can take type Regexp and type String
    // if type string then expected full match
    route(/hello|hi/gi, async function (response, classMessage) {
        // reply - it means sending in response
        let res = await classMessage.reply('hello friend!');
    });

     routeMention('hello', async function (response, classMessage) {
         // the message will be visible only to the sender
         classMessage.replyEphemeral('hello', {
             icon_emoji: ':piggy:'
         });
     });
});

Contributions welcome!

Pull requests/forks all welcome, and please share your thoughts, questions and feature requests in Issues section.