slack-node
Advanced tools
Comparing version 0.0.95 to 0.1.0
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.8.0 | ||
// Generated by CoffeeScript 1.9.0 | ||
module.exports = require("./lib/slack.seed"); |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.8.0 | ||
// Generated by CoffeeScript 1.9.0 | ||
var Slack, request, | ||
@@ -8,11 +8,11 @@ __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; | ||
Slack = (function() { | ||
function Slack(token, domain) { | ||
this.token = token; | ||
this.domain = domain; | ||
function Slack(_at_token, _at_domain) { | ||
this.token = _at_token; | ||
this.domain = _at_domain; | ||
this.api = __bind(this.api, this); | ||
this.webhook = __bind(this.webhook, this); | ||
this.detectEmoji = __bind(this.detectEmoji, this); | ||
this.setWebHook = __bind(this.setWebHook, this); | ||
this.setWebhook = __bind(this.setWebhook, this); | ||
this.composeUrl = __bind(this.composeUrl, this); | ||
this.apiMode = !this.domain ? true : false; | ||
this.apiMode = this.domain == null; | ||
this.url = this.composeUrl(); | ||
@@ -25,4 +25,4 @@ } | ||
Slack.prototype.setWebHook = function(url) { | ||
return this.webhookUrl = url; | ||
Slack.prototype.setWebhook = function(url) { | ||
this.webhookUrl = url; | ||
return this; | ||
@@ -33,15 +33,10 @@ }; | ||
var obj; | ||
obj = []; | ||
obj = {}; | ||
if (!emoji) { | ||
obj["key"] = "icon_emoji"; | ||
obj["val"] = ""; | ||
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; | ||
} | ||
obj.key = emoji.match(/^http/) ? "icon_url" : "icon_emoji"; | ||
obj.val = emoji; | ||
return obj; | ||
@@ -59,3 +54,3 @@ }; | ||
}; | ||
payload[emoji["key"]] = emoji["val"]; | ||
payload[emoji.key] = emoji.val; | ||
return request.post({ | ||
@@ -76,2 +71,5 @@ url: this.webhookUrl, | ||
var request_arg, url; | ||
if (options == null) { | ||
options = {}; | ||
} | ||
if (typeof options === "function") { | ||
@@ -81,3 +79,2 @@ callback = options; | ||
} | ||
options = options || {}; | ||
options.token = this.token; | ||
@@ -102,3 +99,3 @@ url = this.url + method; | ||
} | ||
if (callback) { | ||
if (typeof callback === "function") { | ||
callback(err, JSON.parse(response)); | ||
@@ -111,5 +108,3 @@ } | ||
Slack.prototype._is_post_api = function(method) { | ||
if (method === "files.upload") { | ||
return true; | ||
} | ||
return method === "files.upload"; | ||
}; | ||
@@ -116,0 +111,0 @@ |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.8.0 | ||
// Generated by CoffeeScript 1.9.0 | ||
var Slack, apiToken, domain, should, webhookToken, webhookUri; | ||
@@ -14,13 +14,14 @@ | ||
webhookUri = "https://hooks.slack.com/services/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"; | ||
webhookUri = "https://hooks.slack.com/services/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"; | ||
describe.only('slack new webhook test', function() { | ||
describe('slack new webhook test', function() { | ||
var slack; | ||
this.timeout(50000); | ||
slack = new Slack(); | ||
slack.setWebHook(webhookUri); | ||
it(',should send a correct response', function(done) { | ||
slack.setWebhook(webhookUri); | ||
it('should create a slack object', function(done) { | ||
slack.should.be.an.Object; | ||
return done(); | ||
}); | ||
it(',should send a correct response', function(done) { | ||
it('should send a correct response', function(done) { | ||
return slack.webhook({ | ||
@@ -35,3 +36,3 @@ channel: "#general", | ||
}); | ||
it(',should send a correct response', function(done) { | ||
it('should send a correct response with emoji', function(done) { | ||
return slack.webhook({ | ||
@@ -41,3 +42,3 @@ channel: "#general", | ||
text: "This is posted to #general and comes from a bot named webhookbot.", | ||
"icon_emoji": ":ghost:" | ||
icon_emoji: ":ghost:" | ||
}, function(err, response) { | ||
@@ -48,3 +49,3 @@ response.should.be.ok.and.an.Object; | ||
}); | ||
return it(',should have status code and headers', function(done) { | ||
return it('should have status code and headers', function(done) { | ||
return slack.webhook({ | ||
@@ -65,8 +66,9 @@ channel: "#general", | ||
var slack; | ||
this.timeout(50000); | ||
slack = new Slack(apiToken); | ||
it(',shoule be return a slack object', function(done) { | ||
it('should return a slack object', function(done) { | ||
slack.should.be.an.Object; | ||
return done(); | ||
}); | ||
return it(", run with user.list", function(done) { | ||
return it("run with user.list", function(done) { | ||
return slack.api("users.list", function(err, response) { | ||
@@ -79,9 +81,9 @@ response.should.be.ok.and.an.Object; | ||
describe(", emoji test", function() { | ||
describe("emoji test", function() { | ||
var slack; | ||
slack = new Slack(webhookToken, domain); | ||
it(', emoji give empty value', function(done) { | ||
it('emoji give empty value', function(done) { | ||
var obj; | ||
obj = slack.detectEmoji(); | ||
obj.should.be.an.Array; | ||
obj.should.be.an.Object; | ||
obj["key"].should.equal("icon_emoji"); | ||
@@ -91,6 +93,6 @@ obj["val"].should.equal(""); | ||
}); | ||
it(', emoji using :ghost: style', function(done) { | ||
it('emoji using :ghost: style', function(done) { | ||
var obj; | ||
obj = slack.detectEmoji(":ghost:"); | ||
obj.should.be.an.Array; | ||
obj.should.be.an.Object; | ||
obj["key"].should.equal("icon_emoji"); | ||
@@ -100,6 +102,6 @@ obj["val"].should.equal(":ghost:"); | ||
}); | ||
return it(', emoji using http image url', function(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.should.be.an.Object; | ||
obj["key"].should.equal("icon_url"); | ||
@@ -114,3 +116,3 @@ obj["val"].should.equal("http://icons.iconarchive.com/icons/rokey/popo-emotions/128/after-boom-icon.png"); | ||
slack = new Slack(webhookToken, domain); | ||
return it(', without callback', function(done) { | ||
return it('without callback', function(done) { | ||
var feedback, method; | ||
@@ -117,0 +119,0 @@ method = "files.list"; |
{ | ||
"name": "slack-node", | ||
"version": "0.0.95", | ||
"version": "0.1.0", | ||
"description": "slack for node verision, full support", | ||
@@ -22,5 +22,5 @@ "main": "lib/index.js", | ||
"coffee-script": "~1.7.1", | ||
"mocha": "~1.18.2", | ||
"mocha": "^2.1.0", | ||
"should": "~3.3.1" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21104
206