2014-09-13 21:29:45 +00:00
|
|
|
var Msg = require("../../models/msg");
|
|
|
|
|
|
|
|
module.exports = function(irc, network) {
|
|
|
|
var client = this;
|
|
|
|
irc.on("topic", function(data) {
|
2016-03-20 14:28:47 +00:00
|
|
|
var chan = network.getChannel(data.channel);
|
2014-09-13 21:29:45 +00:00
|
|
|
if (typeof chan === "undefined") {
|
|
|
|
return;
|
|
|
|
}
|
2015-04-26 22:20:54 +00:00
|
|
|
|
2014-09-13 21:29:45 +00:00
|
|
|
var msg = new Msg({
|
2016-03-12 09:36:55 +00:00
|
|
|
time: data.time,
|
2014-09-13 21:29:45 +00:00
|
|
|
type: Msg.Type.TOPIC,
|
2016-03-08 09:26:43 +00:00
|
|
|
mode: (data.nick && chan.getMode(data.nick)) || "",
|
|
|
|
from: data.nick,
|
|
|
|
text: data.topic,
|
|
|
|
self: data.nick === irc.user.nick
|
2014-09-13 21:29:45 +00:00
|
|
|
});
|
|
|
|
chan.messages.push(msg);
|
|
|
|
client.emit("msg", {
|
|
|
|
chan: chan.id,
|
|
|
|
msg: msg
|
|
|
|
});
|
2016-03-08 09:26:43 +00:00
|
|
|
|
|
|
|
chan.topic = data.topic;
|
2014-10-10 20:05:25 +00:00
|
|
|
client.emit("topic", {
|
|
|
|
chan: chan.id,
|
2015-04-26 22:20:54 +00:00
|
|
|
topic: chan.topic
|
2014-10-10 20:05:25 +00:00
|
|
|
});
|
2014-09-13 21:29:45 +00:00
|
|
|
});
|
2016-03-08 09:26:43 +00:00
|
|
|
|
|
|
|
irc.on("topicsetby", function(data) {
|
2016-03-20 14:28:47 +00:00
|
|
|
var chan = network.getChannel(data.channel);
|
2016-03-08 09:26:43 +00:00
|
|
|
if (typeof chan === "undefined") {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var msg = new Msg({
|
|
|
|
type: Msg.Type.TOPIC_SET_BY,
|
|
|
|
mode: chan.getMode(data.nick),
|
|
|
|
nick: data.nick,
|
2016-03-20 17:18:43 +00:00
|
|
|
when: new Date(data.when * 1000),
|
2016-03-08 09:26:43 +00:00
|
|
|
self: data.nick === irc.user.nick
|
|
|
|
});
|
|
|
|
chan.messages.push(msg);
|
|
|
|
client.emit("msg", {
|
|
|
|
chan: chan.id,
|
|
|
|
msg: msg
|
|
|
|
});
|
|
|
|
});
|
2014-09-13 21:29:45 +00:00
|
|
|
};
|