2016-10-09 21:14:02 +02:00
|
|
|
"use strict";
|
|
|
|
|
2014-09-13 23:29:45 +02:00
|
|
|
var _ = require("lodash");
|
|
|
|
|
|
|
|
module.exports = User;
|
|
|
|
|
2016-09-24 18:34:35 +02:00
|
|
|
function User(attr, prefixLookup) {
|
2016-10-02 09:37:37 +02:00
|
|
|
_.defaults(this, attr, {
|
2016-09-24 18:34:35 +02:00
|
|
|
modes: [],
|
2017-06-01 20:54:46 +02:00
|
|
|
mode: "",
|
2016-09-24 18:34:35 +02:00
|
|
|
nick: ""
|
2016-10-02 09:37:37 +02:00
|
|
|
});
|
2016-09-24 18:34:35 +02:00
|
|
|
|
|
|
|
// irc-framework sets character mode, but lounge works with symbols
|
2017-04-08 14:34:31 +02:00
|
|
|
this.modes = this.modes.map((mode) => prefixLookup[mode]);
|
2016-09-24 18:34:35 +02:00
|
|
|
|
2017-06-01 20:54:46 +02:00
|
|
|
if (this.modes[0]) {
|
|
|
|
this.mode = this.modes[0];
|
|
|
|
}
|
2014-09-13 23:29:45 +02:00
|
|
|
}
|
2017-06-01 20:54:46 +02:00
|
|
|
|
|
|
|
User.prototype.toJSON = function() {
|
|
|
|
return {
|
|
|
|
nick: this.nick,
|
|
|
|
mode: this.mode,
|
|
|
|
};
|
|
|
|
};
|