thelounge/src/plugins/irc-events/away.js
Jérémie Astori 1dc92d8934
Enforce dangling commas with ESLint
¯\_(ツ)_/¯
2017-11-15 01:35:15 -05:00

31 lines
594 B
JavaScript

"use strict";
const _ = require("lodash");
const Msg = require("../../models/msg");
module.exports = function(irc, network) {
const client = this;
irc.on("away", (data) => {
const away = data.message;
network.channels.forEach((chan) => {
const user = _.find(chan.users, {nick: data.nick});
if (!user || user.away === away) {
return;
}
const msg = new Msg({
type: away ? Msg.Type.AWAY : Msg.Type.BACK,
text: away || "",
time: data.time,
from: data.nick,
mode: user.mode,
});
chan.pushMessage(client, msg);
user.away = away;
});
});
};