Gateway v6 support

This commit is contained in:
abalabahaha
2016-09-18 09:26:29 +09:00
parent d96f5d1e30
commit 34323c869e
10 changed files with 113 additions and 44 deletions

View File

@@ -28,18 +28,28 @@ var PMChannel = (function (_Channel) {
_inherits(PMChannel, _Channel);
function PMChannel(data, client) {
var _this = this;
_classCallCheck(this, PMChannel);
_Channel.call(this, data, client);
this.type = data.type || "text";
this.type = data.type;
this.lastMessageID = data.last_message_id || data.lastMessageID;
this.messages = new _UtilCache2["default"]("id", client.options.maxCachedMessages);
this.recipient = this.client.internal.users.add(new _User2["default"](data.recipient, this.client));
if (data.recipients instanceof _UtilCache2["default"]) {
this.recipients = data.recipients;
} else {
this.recipients = new _UtilCache2["default"]();
data.recipients.forEach(function (recipient) {
_this.recipients.add(_this.client.internal.users.add(new _User2["default"](recipient, _this.client)));
});
}
this.name = data.name !== undefined ? data.name : this.name;
this.owner = data.owner || this.client.internal.users.get("id", data.owner_id);
this.icon = data.icon !== undefined ? data.icon : this.icon;
}
/* warning! may return null */
PMChannel.prototype.toString = function toString() {
return this.recipient.toString();
};
@@ -105,6 +115,13 @@ var PMChannel = (function (_Channel) {
};
_createClass(PMChannel, [{
key: "recipient",
get: function get() {
return this.recipients[0];
}
/* warning! may return null */
}, {
key: "lastMessage",
get: function get() {
return this.messages.get("id", this.lastMessageID);