hardlounge/lib/plugins/notice.js

24 lines
515 B
JavaScript
Raw Normal View History

2014-06-19 15:28:53 +00:00
var Chan = require("../models/chan");
var Msg = require("../models/msg");
2014-06-23 17:28:36 +00:00
module.exports = function(slate, network) {
var client = this;
slate.on("notice", function(data) {
2014-06-19 15:28:53 +00:00
var chan = network.channels[0];
var from = data.from || "-!-";
if (data.to == "*" || data.from.indexOf(".") !== -1) {
from = "-!-";
}
var msg = new Msg({
type: "notice",
from: from,
text: data.message,
});
chan.addMsg(msg);
2014-06-23 17:28:36 +00:00
client.emit("msg", {
2014-06-19 15:28:53 +00:00
id: chan.id,
msg: msg,
});
});
};