slack-client
Advanced tools
Comparing version 1.2.2 to 1.3.1
{ | ||
"name": "slack-client", | ||
"version": "1.2.2", | ||
"version": "1.3.1", | ||
"description": "A library for creating a full Slack client", | ||
@@ -5,0 +5,0 @@ "main": "./index", |
@@ -11,3 +11,3 @@ # Node.js Slack Client Library | ||
This code has been built to support our [hubot-slack](https://github.com/slackhq/hubot-slack) adapter. Most other functionality isn't yet supported, and documentation is minimal, at best. | ||
This code has been built to support our [hubot-slack](https://github.com/slackhq/hubot-slack) adapter. Most other functionality isn't yet supported, and documentation is minimal, at best. A simple example of how to use this module from Node.js can be found in the `examples` directory. | ||
@@ -14,0 +14,0 @@ ## Contribute |
@@ -20,2 +20,3 @@ var Channel, Message, | ||
this._onFetchHistory = __bind(this._onFetchHistory, this); | ||
this._onPostMessage = __bind(this._onPostMessage, this); | ||
this._typingTimeout = __bind(this._typingTimeout, this); | ||
@@ -129,2 +130,18 @@ this._typing = {}; | ||
Channel.prototype.postMessage = function(data) { | ||
var params; | ||
params = data; | ||
params.channel = this.id; | ||
if (data.attachments) { | ||
params.attachments = JSON.stringify(data.attachments); | ||
} | ||
this._client.logger.debug(data); | ||
this._client.logger.debug(params); | ||
return this._client._apiCall("chat.postMessage", params, this._onPostMessage); | ||
}; | ||
Channel.prototype._onPostMessage = function(data) { | ||
return this._client.logger.debug(data); | ||
}; | ||
Channel.prototype.sendMessage = function(message) { | ||
@@ -131,0 +148,0 @@ message.channel = this.id; |
@@ -119,4 +119,2 @@ var Bot, Channel, Client, DM, EventEmitter, Group, Log, Message, Team, User, WebSocket, https, querystring, | ||
return function() { | ||
_this.emit('open'); | ||
_this.connected = true; | ||
_this._connAttempts = 0; | ||
@@ -385,3 +383,3 @@ _this._lastPong = Date.now(); | ||
channel = _ref[id]; | ||
if (channel.unread_count != null) { | ||
if (channel.unread_count > 0) { | ||
unreads.push(channel); | ||
@@ -393,3 +391,3 @@ } | ||
dm = _ref1[id]; | ||
if (dm.unread_count != null) { | ||
if (dm.unread_count > 0) { | ||
unreads.push(dm); | ||
@@ -401,3 +399,3 @@ } | ||
group = _ref2[id]; | ||
if (group.unread_count != null) { | ||
if (group.unread_count > 0) { | ||
unreads.push(group); | ||
@@ -414,3 +412,4 @@ } | ||
case "hello": | ||
return this.connected = true; | ||
this.connected = true; | ||
return this.emit('open'); | ||
case "presence_change": | ||
@@ -574,2 +573,3 @@ u = this.getUserByID(message.user); | ||
m = this._pending[message.reply_to]; | ||
m._onMessageSent(message); | ||
channel = this.getChannelGroupOrDMByID(m); | ||
@@ -600,3 +600,4 @@ if (channel) { | ||
this._pending[message.id] = message; | ||
return this.ws.send(JSON.stringify(message)); | ||
this.ws.send(JSON.stringify(message)); | ||
return message; | ||
} | ||
@@ -603,0 +604,0 @@ }; |
@@ -1,2 +0,3 @@ | ||
var Message; | ||
var Message, | ||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; | ||
@@ -10,2 +11,4 @@ Message = (function() { | ||
} | ||
this.deleteMessage = __bind(this.deleteMessage, this); | ||
this.updateMessage = __bind(this.updateMessage, this); | ||
for (k in data || {}) { | ||
@@ -88,2 +91,41 @@ this[k] = data[k]; | ||
Message.prototype.updateMessage = function(new_text) { | ||
var params; | ||
params = { | ||
"ts": this.ts, | ||
"channel": this.channel, | ||
"text": new_text | ||
}; | ||
if (this.ts) { | ||
this._client.logger.debug("Sending message change request"); | ||
this._client.logger.debug(params); | ||
return this._client._apiCall("chat.update", params, this._onUpdateMessage); | ||
} | ||
}; | ||
Message.prototype._onUpdateMessage = function(data) { | ||
return this._client.logger.debug(data); | ||
}; | ||
Message.prototype.deleteMessage = function() { | ||
var params; | ||
params = { | ||
"ts": this.ts, | ||
"channel": this.channel | ||
}; | ||
if (this.ts) { | ||
this._client.logger.debug("Sending message delete request"); | ||
this._client.logger.debug(params); | ||
return this._client._apiCall("chat.delete", params, this._onDeleteMessage); | ||
} | ||
}; | ||
Message.prototype._onDeleteMessage = function(data) { | ||
return this._client.logger.debug(data); | ||
}; | ||
Message.prototype._onMessageSent = function(data) { | ||
return this.ts = data.ts; | ||
}; | ||
return Message; | ||
@@ -90,0 +132,0 @@ |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
43256
16
1205