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

slack-integration

v1.0.1

Published

Slack integration

Downloads

7

Readme

Slack integration for NodeJS

Package for sending slack messages and retrieving Git repository's user info.

This package is not compiled to ES5 and therefore requires Promise, and async/await support.

Installation

npm i slack-integration

Setup

Do not share Slack token in public code repositories.

Generate legacy API token here for your Slack team: https://api.slack.com/custom-integrations/legacy-tokens

Then initialize this package's exported class with generated token as first argument:

import Slack from 'slack-integration';

const token = 'XXXXXX';
const slackIntegration = new Slack(token);

Once initialized, you can access following methods:

send(message: Object): Promise

This methods allows you send a message in your Slack workspace.

See https://api.slack.com/methods/chat.postMessage for arguments and result response.

Example:

slackIntegration.send({
    channel: 'channel id here',
    as_user: false,
    username: 'Your Slack',
    text: 'Hello, its me!',
})
    .then((result) => console.log(result))
    .catch((err) => console.error(err));

getCurrentGitUser(): Promise

This methods returns Promise, when resolved, an object with keys: "name", and "email" are returned.

On error, it will be rejected.

It runs following commands in the working directory:

git config user.name
git config user.email

Example:

slackIntegration.getCurrentGitUser()
    .then((result) => console.log(result)) // { name: 'Git user name', email: 'Git user email' }
    .catch((err) => console.error(err));

getUsers(): Promise

This methods returns a list of found users in your Slack workspace.

See https://api.slack.com/methods/users.list for more information on response.

Example:

slackIntegration.getUsers()
    .then((result) => console.log(result))
    .catch((err) => console.error(err));

findUser(properties: Object): Promise

You can search your Slack workspack users by following properties object:

{
    "email": "[email protected]",
    "name": "or find this user with such name"
}

It tries to search by both, whatever it finds first, will be user that will be resolved.

Example:

slackIntegration.findUser({
    email: '[email protected]',
})
    .then((result) => console.log(result))
    .catch((err) => console.error(err));

Contributions & Issues

Contributions are welcome. Please clearly explain the purpose of the PR and follow the current style.

Issues can be resolved quickest if they are descriptive and include both a reduced test case and a set of steps to reproduce.

Licence

The slack-integration library is copyright © Genert Org and licensed for use under the MIT License (MIT).

Please see MIT License for more information.