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

46 lines
965 B
JavaScript

"use strict";
var Msg = require("../../models/msg");
module.exports = function(irc, network) {
var client = this;
irc.on("topic", function(data) {
var chan = network.getChannel(data.channel);
if (typeof chan === "undefined") {
return;
}
var msg = new Msg({
time: data.time,
type: Msg.Type.TOPIC,
mode: (data.nick && chan.getMode(data.nick)) || "",
from: data.nick,
text: data.topic,
self: data.nick === irc.user.nick,
});
chan.pushMessage(client, msg);
chan.topic = data.topic;
client.emit("topic", {
chan: chan.id,
topic: chan.topic,
});
});
irc.on("topicsetby", function(data) {
var chan = network.getChannel(data.channel);
if (typeof chan === "undefined") {
return;
}
var msg = new Msg({
type: Msg.Type.TOPIC_SET_BY,
mode: chan.getMode(data.nick),
nick: data.nick,
when: new Date(data.when * 1000),
self: data.nick === irc.user.nick,
});
chan.pushMessage(client, msg);
});
};