Socket
Socket
Sign inDemoInstall

@slack/client

Package Overview
Dependencies
Maintainers
3
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@slack/client - npm Package Compare versions

Comparing version 3.10.0 to 3.11.0

docs/_posts/2017-05-25-v3.11.0.md

23

docs/_pages/bots.md

@@ -62,3 +62,3 @@ ---

var RtmClient = require('@slack/client').RtmClient;
var RTM_CLIENT_EVENTS = require('@slack/client').CLIENT_EVENTS.RTM;
var CLIENT_EVENTS = require('@slack/client').CLIENT_EVENTS;

@@ -68,10 +68,19 @@ var bot_token = process.env.SLACK_BOT_TOKEN || '';

var rtm = new RtmClient(bot_token);
rtm.start();
var channel = "#general"; //could also be a channel, group, DM, or user ID (C1234), or a username (@don)
let channel;
// The client will emit an RTM.AUTHENTICATED event on successful connection, with the `rtm.start` payload
rtm.on(CLIENT_EVENTS.RTM.AUTHENTICATED, (rtmStartData) => {
for (const c of rtmStartData.channels) {
if (c.is_member && c.name ==='general') { channel = c.id }
}
console.log(`Logged in as ${rtmStartData.self.name} of team ${rtmStartData.team.name}, but not yet connected to a channel`);
});
// you need to wait for the client to fully connect before you can send messages
rtm.on(RTM_CLIENT_EVENTS.RTM_CONNECTION_OPENED, function () {
rtm.on(CLIENT_EVENTS.RTM.RTM_CONNECTION_OPENED, function () {
rtm.sendMessage("Hello!", channel);
});
rtm.start();
```

@@ -132,3 +141,3 @@

var RtmClient = require('@slack/client').RtmClient;
var RTM_EVENTS = require('@slack/client').RTM_EVENTS;
var bot_token = process.env.SLACK_BOT_TOKEN || '';

@@ -162,3 +171,3 @@

var rtm = new RtmClient(token, {
var rtm = new RtmClient(bot_token, {
// Sets the level of logging we require

@@ -193,3 +202,3 @@ logLevel: 'error',

var RtmClient = require('@slack/client').RtmClient;
var RTM_EVENTS = require('@slack/client').RTM_EVENTS;
var bot_token = process.env.SLACK_BOT_TOKEN || '';

@@ -196,0 +205,0 @@

@@ -24,2 +24,3 @@ ---

| defaults.text | <code>string</code> | The default text to use when sending a webhook. |
| defaults.linkNames | <code>string</code> | The default setting for the link_names format option to use when sending a webhook. If no value is specified, the one chosen when creating the webhook will be used. |

@@ -26,0 +27,0 @@ <a name="IncomingWebhook+send"></a>

@@ -25,2 +25,3 @@ /**

channel: 'custom-channel',
linkNames: '1',
attachments: [

@@ -27,0 +28,0 @@ // attachment data

@@ -17,2 +17,4 @@ var requestsTransport = require('../transports/request').requestTransport;

* @param {string} defaults.text The default text to use when sending a webhook.
* @param {string} defaults.linkNames The default setting for the link_names format option to use when sending a webhook.
* If no value is specified, the one chosen when creating the webhook will be used.
* @constructor

@@ -33,2 +35,3 @@ */

channel: _defaults.channel,
linkNames: _defaults.linkNames,
text: _defaults.text

@@ -68,2 +71,3 @@ };

channel: this.defaults.channel,
link_names: this.defaults.linkNames,
text: this.defaults.text

@@ -80,2 +84,3 @@ };

if (message.channel) data.channel = message.channel;
if (message.linkNames) data.link_names = message.linkNames;
if (message.attachments) data.attachments = message.attachments;

@@ -82,0 +87,0 @@ }

@@ -343,3 +343,2 @@ /**

// Stop listening to the websocket's close event, so that the auto-reconnect logic doesn't fire
// twice.
this.ws.removeAllListeners('close');

@@ -346,0 +345,0 @@ this.ws.close();

@@ -7,2 +7,3 @@ /**

* - meMessage: {@link https://api.slack.com/methods/chat.meMessage|chat.meMessage}
* - postEphemeral: {@link https://api.slack.com/methods/chat.postEphemeral|chat.postEphemeral}
* - postMessage: {@link https://api.slack.com/methods/chat.postMessage|chat.postMessage}

@@ -61,2 +62,32 @@ * - update: {@link https://api.slack.com/methods/chat.update|chat.update}

/**
* Sends an ephemeral message to a user in a channel.
* @see {@link https://api.slack.com/methods/chat.postEphemeral|chat.postEphemeral}
*
* @param {?} channel - Channel, private group, or IM channel to send message to. Can be an
* encoded ID, or a name. See [below](#channels) for more details.
* @param {?} text - Text of the message to send. See below for an explanation of
* [formatting](#formatting). This field is usually required, unless you're providing only
* `attachments` instead.
* @param {?} user - `id` of the user who will receive the ephemeral message.
* The user should be in the channel specified by the `channel` argument.
* @param {Object=} opts
* @param {?} opts.parse - Change how messages are treated. Defaults to `none`. See
* [below](#formatting).
* @param {?} opts.link_names - Find and link channel names and usernames.
* @param {?} opts.attachments - Structured message attachments.
* @param {?} opts.as_user - Pass true to post the message as the authed user, instead of as a
* bot. Defaults to false. See [authorship](#authorship) below.
* @param {function=} optCb Optional callback, if not using promises.
*/
ChatFacet.prototype.postEphemeral = function postEphemeral(channel, text, user, opts, optCb) {
var requiredArgs = {
channel: channel,
text: text,
user: user
};
return this.makeAPICall('chat.postEphemeral', requiredArgs, opts, optCb);
};
/**
* Sends a message to a channel.

@@ -63,0 +94,0 @@ * @see {@link https://api.slack.com/methods/chat.postMessage|chat.postMessage}

@@ -40,3 +40,3 @@ /**

*/
UsersProfileFacet.prototype.set = function get(opts, optCb) {
UsersProfileFacet.prototype.set = function set(opts, optCb) {
return this.makeAPICall('users.profile.set', null, opts, optCb);

@@ -43,0 +43,0 @@ };

{
"name": "@slack/client",
"version": "3.10.0",
"version": "3.11.0",
"description": "A library for creating a Slack client",

@@ -5,0 +5,0 @@ "main": "./index",

@@ -10,9 +10,5 @@ # Node Library for the Slack APIs

So you want to build a Slack app with Node.js? We've got you covered. `node-slack-sdk` is aimed at making
building Slack apps ridiculously easy. This module will help you build on all aspects of the Slack platform,
from dropping notifications in channels to fully interactive bots.
This module is a wrapper around the Slack [RTM](https://api.slack.com/rtm) and [Web](https://api.slack.com/web) APIs.
This is a wrapper around the Slack [RTM](https://api.slack.com/rtm) and [Web](https://api.slack.com/web) APIs.
This library provides the low level functionality you need to build reliable apps and projects on top of Slack's APIs.
It will help you build on the Slack platform, from dropping notifications in channels to developing fully interactive bots. It provides the low level functionality you need to build reliable apps and projects on top of Slack's APIs.
It:

@@ -24,3 +20,3 @@

This library does not attempt to provide application level support, _e.g._ regex matching and filtering of the
This module does not attempt to provide application level support, _e.g._ regex matching and filtering of the
conversation stream.

@@ -32,2 +28,9 @@

# Installation
Once you have a working Node.js project, you can install the Slack Developer Kit as a dependency via npm:
```sh
$ npm install @slack/client --save
```
# Some Examples

@@ -52,7 +55,7 @@

webhook.send('Hello there', function(err, res) {
webhook.send('Hello there', function(err, header, statusCode, body) {
if (err) {
console.log('Error:', err);
} else {
console.log('Message sent: ', res);
console.log('Received', statusCode, 'from Slack');
}

@@ -59,0 +62,0 @@ });

@@ -22,2 +22,3 @@ var expect = require('chai').expect;

channel: 'channel-name',
linkNames: '1',
text: 'some text'

@@ -30,2 +31,3 @@ };

expect(wh.defaults.channel).to.equal(opts.channel);
expect(wh.defaults.linkNames).to.equal(opts.linkNames);
expect(wh.defaults.text).to.equal(opts.text);

@@ -171,3 +173,4 @@ });

channel: 'a-channel',
iconEmoji: ':robot_face:'
iconEmoji: ':robot_face:',
linkNames: '1'
}, function () {

@@ -180,3 +183,4 @@ expect(transport.calledOnce).to.equal(true);

channel: 'a-channel',
icon_emoji: ':robot_face:'
icon_emoji: ':robot_face:',
link_names: '1'
}

@@ -183,0 +187,0 @@ })).to.equal(true);

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc