|
|
@@ -140,12 +140,12 @@ Slack.prototype.sendCommand = function(room, cmd, arg) {
|
|
|
+"?token=" +this.token
|
|
|
+"&command=" +encodeURIComponent(cmd.name)
|
|
|
+"&disp=" +encodeURIComponent(cmd.name)
|
|
|
- +"&channel=" +room.id
|
|
|
+ +"&channel=" +room.remoteId
|
|
|
+"&text=" +arg);
|
|
|
}
|
|
|
|
|
|
Slack.prototype.sendTyping = function(room) {
|
|
|
- this.rtm.send('{"id":' +this.rtmId++ +',"type":"typing","channel":"' +room.id +'"}');
|
|
|
+ this.rtm.send('{"id":' +this.rtmId++ +',"type":"typing","channel":"' +room.remoteId +'"}');
|
|
|
}
|
|
|
|
|
|
Slack.prototype.getSlashCommands = function(cb) {
|
|
|
@@ -234,7 +234,7 @@ Slack.prototype.onMessage = function(msg, t) {
|
|
|
}
|
|
|
this.data.onMessage(msg, t);
|
|
|
if ((msg["channel"] || msg["channel_id"] || (msg["item"] && msg["item"]["channel"])) && msg["type"] && UPDATE_LIVE.indexOf(msg["type"]) !== -1) {
|
|
|
- var channelId = msg["channel"] || msg["channel_id"] || msg["item"]["channel"]
|
|
|
+ var channelId = this.data.team.id +(msg["channel"] || msg["channel_id"] || msg["item"]["channel"])
|
|
|
,channel = this.data.channels[msg["channel"]]
|
|
|
,histo = this.history[channelId];
|
|
|
if (histo) {
|
|
|
@@ -245,7 +245,7 @@ Slack.prototype.onMessage = function(msg, t) {
|
|
|
if (channel)
|
|
|
channel.setLastMsg(lastMsg, t);
|
|
|
} else if (channel) {
|
|
|
- this.fetchHistory(this.data.channels[this.data.team.id +'|' +msg["channel"]]);
|
|
|
+ this.fetchHistory(channel);
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
@@ -257,16 +257,16 @@ Slack.prototype.onMessage = function(msg, t) {
|
|
|
Slack.prototype.markRead = function(chan, ts) {
|
|
|
var apiURI;
|
|
|
|
|
|
- if (chan.id[0] === 'C')
|
|
|
+ if (chan.remoteId[0] === 'C')
|
|
|
apiURI = SLACK_ENDPOINT+GETAPI.read.channel;
|
|
|
- else if (chan.id[0] === 'G')
|
|
|
+ else if (chan.remoteId[0] === 'G')
|
|
|
apiURI = SLACK_ENDPOINT+GETAPI.read.group;
|
|
|
- else if (chan.id[0] === 'D')
|
|
|
+ else if (chan.remoteId[0] === 'D')
|
|
|
apiURI = SLACK_ENDPOINT+GETAPI.read.im;
|
|
|
|
|
|
httpsRequest(apiURI
|
|
|
+"?token=" +this.token
|
|
|
- +"&channel="+chan.id
|
|
|
+ +"&channel="+chan.remoteId
|
|
|
+"&ts="+ts);
|
|
|
};
|
|
|
|
|
|
@@ -339,7 +339,7 @@ Slack.prototype.openUploadFileStream = function(channel, contentType, callback)
|
|
|
,method: 'POST'
|
|
|
,path: SLACK_ENDPOINT_PATH +GETAPI.postFile
|
|
|
+"?token=" +this.token
|
|
|
- +"&channels=" +channel.id
|
|
|
+ +"&channels=" +channel.remoteId
|
|
|
,headers: {
|
|
|
"Content-Type": contentType
|
|
|
}
|
|
|
@@ -402,7 +402,7 @@ Slack.prototype.openUploadFileStream = function(channel, contentType, callback)
|
|
|
,method: 'POST'
|
|
|
,path: SLACK_ENDPOINT_PATH +GETAPI.postFile
|
|
|
+"?token=" +this.token
|
|
|
- +"&channels=" +channel.id
|
|
|
+ +"&channels=" +channel.remoteId
|
|
|
,headers: {
|
|
|
"Content-Type": contentType
|
|
|
}
|
|
|
@@ -436,7 +436,7 @@ Slack.prototype.addReaction = function(channel, msgId, reaction) {
|
|
|
httpsRequest(SLACK_ENDPOINT +GETAPI.addReaction
|
|
|
+"?token=" +this.token
|
|
|
+"&name=" +reaction
|
|
|
- +"&channel="+channel.id
|
|
|
+ +"&channel="+channel.remoteId
|
|
|
+"×tamp="+msgId);
|
|
|
}
|
|
|
|
|
|
@@ -449,7 +449,7 @@ Slack.prototype.removeReaction = function(channel, msgId, reaction) {
|
|
|
httpsRequest(SLACK_ENDPOINT +GETAPI.removeReaction
|
|
|
+"?token=" +this.token
|
|
|
+"&name=" +reaction
|
|
|
- +"&channel="+channel.id
|
|
|
+ +"&channel="+channel.remoteId
|
|
|
+"×tamp="+msgId);
|
|
|
}
|
|
|
|
|
|
@@ -460,7 +460,7 @@ Slack.prototype.removeReaction = function(channel, msgId, reaction) {
|
|
|
Slack.prototype.sendMeMsg = function(channel, text) {
|
|
|
httpsRequest(SLACK_ENDPOINT +GETAPI.postMeMsg
|
|
|
+"?token=" +this.token
|
|
|
- +"&channel=" +channel.id
|
|
|
+ +"&channel=" +channel.remoteId
|
|
|
+"&text=" +text.join("\n")
|
|
|
+"&as_user=true");
|
|
|
};
|
|
|
@@ -474,7 +474,7 @@ Slack.prototype.sendMsg = function(channel, text, attachments) {
|
|
|
if (attachments) {
|
|
|
httpsRequest(SLACK_ENDPOINT +GETAPI.postMsg
|
|
|
+"?token=" +this.token
|
|
|
- +"&channel=" +channel.id
|
|
|
+ +"&channel=" +channel.remoteId
|
|
|
+"&text=" +text.join("\n")
|
|
|
+ (attachments ? ("&attachments=" +encodeURIComponent(JSON.stringify(attachments))) : "")
|
|
|
+"&as_user=true");
|
|
|
@@ -490,7 +490,7 @@ Slack.prototype.sendMsg = function(channel, text, attachments) {
|
|
|
user: this.data.self.id,
|
|
|
text: fullDecodedText
|
|
|
};
|
|
|
- this.rtm.send('{"id":' +this.rtmId++ +',"type":"message","channel":"' +channel.id +'", "text":' +JSON.stringify(fullDecodedText) +'}');
|
|
|
+ this.rtm.send('{"id":' +this.rtmId++ +',"type":"message","channel":"' +channel.remoteId +'", "text":' +JSON.stringify(fullDecodedText) +'}');
|
|
|
}
|
|
|
};
|
|
|
|
|
|
@@ -501,7 +501,7 @@ Slack.prototype.sendMsg = function(channel, text, attachments) {
|
|
|
Slack.prototype.removeMsg = function(channel, msgId) {
|
|
|
httpsRequest(SLACK_ENDPOINT +GETAPI.removeMsg
|
|
|
+"?token=" +this.token
|
|
|
- +"&channel=" +channel.id
|
|
|
+ +"&channel=" +channel.remoteId
|
|
|
+"&ts=" +msgId
|
|
|
+"&as_user=true");
|
|
|
};
|
|
|
@@ -514,7 +514,7 @@ Slack.prototype.removeMsg = function(channel, msgId) {
|
|
|
Slack.prototype.editMsg = function(channel, msgId, text) {
|
|
|
httpsRequest(SLACK_ENDPOINT +GETAPI.editMsg
|
|
|
+"?token=" +this.token
|
|
|
- +"&channel=" +channel.id
|
|
|
+ +"&channel=" +channel.remoteId
|
|
|
+"&ts=" +msgId
|
|
|
+"&text=" +text.join("\n")
|
|
|
+"&as_user=true");
|