|
|
@@ -377,6 +377,34 @@ SlackBot.prototype.setPresence = function(presenceStr, t) {
|
|
|
this.version = Math.max(t, this.version);
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * @constructor
|
|
|
+ * @param {*} data
|
|
|
+**/
|
|
|
+function SlackCommand(data) {
|
|
|
+ /** @const @type {string} */
|
|
|
+ this.desc = data["desc"];
|
|
|
+ /** @const @type {string} */
|
|
|
+ this.name = data["name"];
|
|
|
+ /** @const @type {string} */
|
|
|
+ this.type = data["type"];
|
|
|
+ /** @const @type {string} */
|
|
|
+ this.usage = data["usage"];
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @param {number} t
|
|
|
+ * @return {Object}
|
|
|
+**/
|
|
|
+SlackCommand.prototype.toStatic = function(t) {
|
|
|
+ return {
|
|
|
+ "desc": this.desc
|
|
|
+ ,"name": this.name
|
|
|
+ ,"type": this.type
|
|
|
+ ,"usage": this.usage
|
|
|
+ };
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* @constructor
|
|
|
**/
|
|
|
@@ -395,8 +423,10 @@ function SlackData(slack) {
|
|
|
this.self = null;
|
|
|
/** @type {Object.<string, SlackBot>} */
|
|
|
this.bots = {};
|
|
|
- /** @type {Object.<string, string>} */
|
|
|
- this.emojis = {};
|
|
|
+ /** @type {{version: number, data: Object.<string, string>}} */
|
|
|
+ this.emojis = { version: 0, data: {} };
|
|
|
+ /** @type {{version: number, data: Object.<string, SlackCommand>}} */
|
|
|
+ this.commands = {version: 0, data: {} };
|
|
|
/** @type {Object.<string, Object.<string, number>>} */
|
|
|
this.typing = {};
|
|
|
|
|
|
@@ -579,9 +609,21 @@ SlackData.prototype.updateStatic = function(data, t) {
|
|
|
groupObj = this.groups[data["groups"][i]["id"]] = new SlackGroup(data["groups"][i]["id"]);
|
|
|
groupObj.update(this, data["groups"][i], t);
|
|
|
}
|
|
|
- if (data["emojis"]) this.emojis = data["emojis"];
|
|
|
- if (!this.team) this.team = new SlackTeam(data["team"]["id"]);
|
|
|
- this.team.update(data["team"], t);
|
|
|
+ if (data["emojis"]) {
|
|
|
+ this.emojis.data = data["emojis"];
|
|
|
+ this.emojis.version = t;
|
|
|
+ }
|
|
|
+ if (data["commands"] !== undefined){
|
|
|
+ this.commands.data = {};
|
|
|
+ for (var i in data["commands"]) {
|
|
|
+ this.commands.data[i] = new SlackCommand(data["commands"][i]);
|
|
|
+ }
|
|
|
+ this.commands.version = t;
|
|
|
+ }
|
|
|
+ if (data["team"]) {
|
|
|
+ if (!this.team) this.team = new SlackTeam(data["team"]["id"]);
|
|
|
+ this.team.update(data["team"], t);
|
|
|
+ }
|
|
|
this.staticV = Math.max(this.staticV, t);
|
|
|
if (data["self"]) {
|
|
|
this.self = this.getMember(data["self"]["id"]);
|
|
|
@@ -647,9 +689,15 @@ SlackData.prototype.buildStatic = function(t, now) {
|
|
|
"id": this.self.id
|
|
|
,"prefs": this.self.prefs.toStatic(t)
|
|
|
}
|
|
|
- ,"emojis": this.emojis
|
|
|
+ ,"emojis": this.emojis.version > t ? this.emojis.data : undefined
|
|
|
+ ,"commands": undefined
|
|
|
,"typing": undefined
|
|
|
};
|
|
|
+ if (this.commands.version > t) {
|
|
|
+ res["commands"] = {};
|
|
|
+ for (var i in this.commands.data)
|
|
|
+ res["commands"][i] = this.commands.data[i].toStatic(t);
|
|
|
+ }
|
|
|
for (var chanId in this.channels) {
|
|
|
var chan = this.channels[chanId].toStatic(t);
|
|
|
if (chan)
|