2014-06-19 15:28:53 +00:00
|
|
|
var Chan = require("../models/chan");
|
|
|
|
var Msg = require("../models/msg");
|
|
|
|
|
|
|
|
module.exports = function(client, sockets) {
|
|
|
|
var network = this;
|
|
|
|
client.on("motd", function(data) {
|
|
|
|
var rows = data.motd;
|
|
|
|
var chan = network.channels[0];
|
2014-06-20 00:26:48 +00:00
|
|
|
var msg = new Msg({
|
|
|
|
type: "motd-toggle",
|
|
|
|
from: "-!-"
|
|
|
|
});
|
|
|
|
chan.addMsg(msg);
|
|
|
|
sockets.in("chat").emit("msg", {
|
|
|
|
id: chan.id,
|
|
|
|
msg: msg,
|
|
|
|
});
|
2014-06-19 15:28:53 +00:00
|
|
|
rows.forEach(function(text) {
|
|
|
|
var msg = new Msg({
|
|
|
|
type: "motd",
|
|
|
|
from: "-!-",
|
|
|
|
text: text,
|
|
|
|
});
|
|
|
|
chan.addMsg(msg);
|
|
|
|
sockets.in("chat").emit("msg", {
|
|
|
|
id: chan.id,
|
|
|
|
msg: msg,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|