hardlounge/src/models/user.js

33 lines
599 B
JavaScript
Raw Normal View History

"use strict";
2018-01-11 11:33:36 +00:00
const _ = require("lodash");
2014-09-13 21:29:45 +00:00
module.exports = User;
function User(attr, prefixLookup) {
_.defaults(this, attr, {
modes: [],
away: "",
mode: "",
nick: "",
lastMessage: 0,
});
this.setModes(this.modes, prefixLookup);
}
User.prototype.setModes = function(modes, prefixLookup) {
// irc-framework sets character mode, but The Lounge works with symbols
this.modes = modes.map((mode) => prefixLookup[mode]);
this.mode = this.modes[0] || "";
};
User.prototype.toJSON = function() {
return {
nick: this.nick,
mode: this.mode,
lastMessage: this.lastMessage,
};
};