|
|
@@ -28,6 +28,7 @@ const SLACK_ENDPOINT = "https://slack.com/api/"
|
|
|
,removeMsg: "chat.delete"
|
|
|
,postFile: "files.upload"
|
|
|
,setActive: "users.setActive"
|
|
|
+ ,setPresence: "users.setPresence"
|
|
|
,emojiList: "emoji.list"
|
|
|
,slashList: "commands.list"
|
|
|
,slashExec: "chat.command"
|
|
|
@@ -112,9 +113,12 @@ Slack.prototype.connect = function(cb) {
|
|
|
Slack.prototype.sendCommand = function(room, cmd, arg) {
|
|
|
if (cmd.name === "/away") {
|
|
|
// intercept away commands
|
|
|
- // FIXME set presence
|
|
|
- // Should be idempotent
|
|
|
- console.log("SET AWAY", !this.data.self.presence);
|
|
|
+ // TODO should be idempotent
|
|
|
+ httpsRequest(
|
|
|
+ SLACK_ENDPOINT
|
|
|
+ +GETAPI.setPresence
|
|
|
+ +"?token=" +this.token
|
|
|
+ +"&presence=" +(this.data.self.presence ? "away": "auto"));
|
|
|
} else {
|
|
|
httpsRequest(
|
|
|
SLACK_ENDPOINT
|
|
|
@@ -228,6 +232,7 @@ Slack.prototype.onMessage = function(msg, t) {
|
|
|
_this.data.updateStatic(msgContent, now);
|
|
|
_this.connected = true;
|
|
|
_this.unstackPendingMessages();
|
|
|
+ _this.ping();
|
|
|
});
|
|
|
});
|
|
|
} else if (this.connected) {
|