Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

slack-node

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

slack-node - npm Package Compare versions

Comparing version 0.0.9 to 0.0.92

2

lib/index.js

@@ -1,2 +0,2 @@

// Generated by CoffeeScript 1.6.3
// Generated by CoffeeScript 1.7.1
module.exports = require("./lib/slack.seed");

@@ -1,2 +0,2 @@

// Generated by CoffeeScript 1.6.3
// Generated by CoffeeScript 1.7.1
var Slack, request,

@@ -13,2 +13,3 @@ __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };

this.webhook = __bind(this.webhook, this);
this.detectEmoji = __bind(this.detectEmoji, this);
this.composeUrl = __bind(this.composeUrl, this);

@@ -27,18 +28,43 @@ this.apiMode = !this.domain ? true : false;

Slack.prototype.detectEmoji = function(emoji) {
var obj;
obj = [];
if (!emoji) {
obj["key"] = "icon_emoji";
obj["val"] = "";
return obj;
}
if (emoji.match(/^http/)) {
obj["key"] = "icon_url";
obj["val"] = emoji;
} else {
obj["key"] = "icon_emoji";
obj["val"] = emoji;
}
return obj;
};
Slack.prototype.webhook = function(options, callback) {
var bufferJson, emoji;
emoji = this.detectEmoji(options.icon_emoji);
bufferJson = {
channel: options.channel,
text: options.text,
username: options.username,
attachments: options.attachments
};
bufferJson[emoji["key"]] = emoji["val"];
return request.post({
url: this.url,
body: JSON.stringify({
channel: options.channel,
text: options.text,
username: options.username,
icon_url: options.icon_url || "",
attachments: options.attachments
})
body: JSON.stringify(bufferJson)
}, function(err, body, response) {
if (err || response !== "ok") {
return callback(err, null);
return callback(err, {
status: "fail",
response: response
});
}
return callback(err, {
ok: true
status: "ok",
response: response
});

@@ -62,3 +88,6 @@ });

if (err) {
return callback(err, null);
return callback(err, {
status: "fail",
response: response
});
}

@@ -65,0 +94,0 @@ callback(err, JSON.parse(response));

@@ -1,2 +0,2 @@

// Generated by CoffeeScript 1.6.3
// Generated by CoffeeScript 1.7.1
var Slack, apiToken, domain, should, webhookToken;

@@ -21,3 +21,3 @@

});
return it(',should send a correct response', function(done) {
it(',should send a correct response', function(done) {
return slack.webhook({

@@ -32,2 +32,13 @@ channel: "#general",

});
return it(',should send a correct response', function(done) {
return slack.webhook({
channel: "#general",
username: "webhookbot",
text: "This is posted to #general and comes from a bot named webhookbot.",
"icon_emoji": ":ghost:"
}, function(err, response) {
response.should.be.ok.and.an.Object;
return done();
});
});
});

@@ -49,1 +60,30 @@

});
describe(", emoji test", function() {
var slack;
slack = new Slack(webhookToken, domain);
it(', emoji give empty value', function(done) {
var obj;
obj = slack.detectEmoji();
obj.should.be.an.Array;
obj["key"].should.equal("icon_emoji");
obj["val"].should.equal("");
return done();
});
it(', emoji using :ghost: style', function(done) {
var obj;
obj = slack.detectEmoji(":ghost:");
obj.should.be.an.Array;
obj["key"].should.equal("icon_emoji");
obj["val"].should.equal(":ghost:");
return done();
});
return it(', emoji using http image url', function(done) {
var obj;
obj = slack.detectEmoji("http://icons.iconarchive.com/icons/rokey/popo-emotions/128/after-boom-icon.png");
obj.should.be.an.Array;
obj["key"].should.equal("icon_url");
obj["val"].should.equal("http://icons.iconarchive.com/icons/rokey/popo-emotions/128/after-boom-icon.png");
return done();
});
});
{
"name": "slack-node",
"version": "0.0.9",
"version": "0.0.92",
"description": "slack for node verision, full support",

@@ -20,3 +20,3 @@ "main": "lib/index.js",

},
"devDependency": {
"devDependencies": {
"coffee-script": "~1.7.1",

@@ -23,0 +23,0 @@ "mocha": "~1.18.2",

@@ -33,2 +33,30 @@ slack-node-sdk

Use icon emoji, you can give a Slack defined emoji, or use image from URL.
var Slack = require('slack-node');
domain = "--your-slack-subdomain--";
webhookToken = "--your-slack-webhook--";
slack = new Slack(webhookToken, domain);
// slack emoji
slack.webhook({
channel: "#general",
username: "webhookbot",
icon_emoji: ":ghost:"
}, function(err, response) {
console.log(response);
});
// URL image
slack.webhook({
channel: "#general",
username: "webhookbot",
icon_emoji: "http://icons.iconarchive.com/icons/rokey/popo-emotions/128/after-boom-icon.png"
}, function(err, response) {
console.log(response);
});
##Slack API

@@ -53,2 +81,9 @@

## Changelog
* 0.0.92
* merge slack emoji for webhook
* pass request full request object
* 0.0.9
* pass parameters bug fixed

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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