UNPKG

593 BJavaScriptView Raw
1"use strict";
2
3var _ = require("lodash");
4
5module.exports = User;
6
7function 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
19User.prototype.setModes = function(modes, prefixLookup) {
20 // irc-framework sets character mode, but lounge works with symbols
21 this.modes = modes.map((mode) => prefixLookup[mode]);
22
23 this.mode = this.modes[0] || "";
24};
25
26User.prototype.toJSON = function() {
27 return {
28 nick: this.nick,
29 mode: this.mode,
30 lastMessage: this.lastMessage,
31 };
32};