mirror of
https://github.com/thelounge/thelounge.git
synced 2024-06-15 20:15:11 +02:00
Several ES6 additions are only available in strict mode. Example: > SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode Strict mode was also enabled in a few of our files already, and it is a good thing to have anyway.
31 lines
689 B
JavaScript
31 lines
689 B
JavaScript
"use strict";
|
|
|
|
var _ = require("lodash");
|
|
var Msg = require("../../models/msg");
|
|
|
|
module.exports = function(irc, network) {
|
|
var client = this;
|
|
irc.on("quit", function(data) {
|
|
network.channels.forEach(function(chan) {
|
|
var from = data.nick;
|
|
var user = _.find(chan.users, {name: from});
|
|
if (typeof user === "undefined") {
|
|
return;
|
|
}
|
|
chan.users = _.without(chan.users, user);
|
|
client.emit("users", {
|
|
chan: chan.id
|
|
});
|
|
var msg = new Msg({
|
|
time: data.time,
|
|
type: Msg.Type.QUIT,
|
|
mode: user.mode || "",
|
|
text: data.message || "",
|
|
hostmask: data.ident + "@" + data.hostname,
|
|
from: from
|
|
});
|
|
chan.pushMessage(client, msg);
|
|
});
|
|
});
|
|
};
|