thelounge/src/plugins/irc-events/topic.js
Jérémie Astori caa46042bf Enforce strict mode across all JS files with ESLint
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.
2016-10-09 15:14:02 -04:00

46 lines
962 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);
});
};