1 | "use strict";
|
2 |
|
3 | var _ = require("lodash");
|
4 |
|
5 | module.exports = User;
|
6 |
|
7 | function User(attr, prefixLookup) {
|
8 | _.defaults(this, attr, {
|
9 | modes: [],
|
10 | away: "",
|
11 | mode: "",
|
12 | nick: "",
|
13 | lastMessage: 0,
|
14 | });
|
15 |
|
16 | this.setModes(this.modes, prefixLookup);
|
17 | }
|
18 |
|
19 | User.prototype.setModes = function(modes, prefixLookup) {
|
20 |
|
21 | this.modes = modes.map((mode) => prefixLookup[mode]);
|
22 |
|
23 | this.mode = this.modes[0] || "";
|
24 | };
|
25 |
|
26 | User.prototype.toJSON = function() {
|
27 | return {
|
28 | nick: this.nick,
|
29 | mode: this.mode,
|
30 | lastMessage: this.lastMessage,
|
31 | };
|
32 | };
|