2016-10-09 19:14:02 +00:00
|
|
|
"use strict";
|
|
|
|
|
2018-01-11 11:33:36 +00:00
|
|
|
const _ = require("lodash");
|
2014-09-13 21:29:45 +00:00
|
|
|
|
|
|
|
module.exports = User;
|
|
|
|
|
2016-09-24 16:34:35 +00:00
|
|
|
function User(attr, prefixLookup) {
|
2016-10-02 07:37:37 +00:00
|
|
|
_.defaults(this, attr, {
|
2016-09-24 16:34:35 +00:00
|
|
|
modes: [],
|
2017-07-10 16:01:20 +00:00
|
|
|
away: "",
|
2017-06-01 18:54:46 +00:00
|
|
|
mode: "",
|
2017-07-10 10:56:37 +00:00
|
|
|
nick: "",
|
|
|
|
lastMessage: 0,
|
2016-10-02 07:37:37 +00:00
|
|
|
});
|
2016-09-24 16:34:35 +00:00
|
|
|
|
2017-07-11 14:40:43 +00:00
|
|
|
this.setModes(this.modes, prefixLookup);
|
|
|
|
}
|
|
|
|
|
|
|
|
User.prototype.setModes = function(modes, prefixLookup) {
|
2018-02-21 17:48:22 +00:00
|
|
|
// irc-framework sets character mode, but The Lounge works with symbols
|
2017-07-11 14:40:43 +00:00
|
|
|
this.modes = modes.map((mode) => prefixLookup[mode]);
|
2016-09-24 16:34:35 +00:00
|
|
|
|
2017-07-11 14:40:43 +00:00
|
|
|
this.mode = this.modes[0] || "";
|
|
|
|
};
|
2017-06-01 18:54:46 +00:00
|
|
|
|
|
|
|
User.prototype.toJSON = function() {
|
|
|
|
return {
|
|
|
|
nick: this.nick,
|
|
|
|
mode: this.mode,
|
2017-07-10 10:56:37 +00:00
|
|
|
lastMessage: this.lastMessage,
|
2017-06-01 18:54:46 +00:00
|
|
|
};
|
|
|
|
};
|