1.1.6 • Published 6 years ago

raslack v1.1.6

Weekly downloads
3
License
ISC
Repository
github
Last release
6 years ago

A module to simplify use of slack as an automated notification tool and for easy sending of slack messages from the command line and used as a module in a node app.

Warning! This is still really a BETA (sorry about the version number! This started as an attempt to learn how to publish an NPM)

The command line use wont break much from here on, but beware, if you use this programmatically, you might consider this an ALPHA/TEST version at this point.

Requirements:

  • A slack webhook. Don't have one? For your chosen channel, register a 'slack app' and a web hook here https://api.slack.com/apps
  • Put the webhook url in the config file here: ~/.raslack/slackconfig.json
  • The config file must be valid json, format below. Two accounts reflected below, you can have just one, or several with several channels each.
{
    "default_channel": "anAccountName.general",
    "accounts": {
        "anAccountName": {
            "default_channel": "general",
            "icon_emoji": ":some_slack_icon!:",
            "username": "[the name you want to appear in the slack chat, you choose!]",
            "channels": {
                "general": "https://yourwebhooktochannel"
            }
        },
        "myOtherAccountName": {
            "default_channel": "myFunnestChannel",
            "icon_emoji": ":some_slack_icon!:",
            "username": "[the name you want to appear in the slack chat, you choose!]",
            "channels": {
                "myFunChannel": "https://yourwebhooktochannel",
                "myFunnestChannel": "https://yourwebhooktochannel"
            }
        }
    }
}

Command line Install

npm install -g raslack

Run from the command line:

raslack --text 'some silly-ass message' [--channel someAccount_general]

or a using json payload (message format docs her https://api.slack.com/incoming-webhooks and here https://api.slack.com/incoming-webhooks)

raslack --json '{"text":"I am Pard *the monkey*, _please bend your knee_","username":"pard", "icon_emoji": ":monkey_face:", "channel": "general", "mrkdwn": true}'

Example of use in a program:

install

npm install raslack

example code

const raslack = require('raslack');
// all but text are optional. the rest can come from the slackconfig.json file
let opts = {
    text: "Hey! I sent a message programmatically!", // your message here
    username: "Herfert",
    channel: "anAccountName.aChannelName", // these must be changed
    icon_emoji: ":rocket:"
}

let body = raslack.createPostBody(opts);
raslack.post(body);
1.1.6

6 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.16

6 years ago

1.0.15

6 years ago

1.0.14

6 years ago

1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago