2014-09-13 21:29:45 +00:00
|
|
|
var _ = require("lodash");
|
|
|
|
var Msg = require("../../models/msg");
|
|
|
|
|
|
|
|
module.exports = function(irc, network) {
|
|
|
|
var client = this;
|
|
|
|
irc.on("mode", function(data) {
|
|
|
|
var chan = _.findWhere(network.channels, {name: data.target});
|
|
|
|
if (typeof chan !== "undefined") {
|
|
|
|
setTimeout(function() {
|
|
|
|
irc.write("NAMES " + data.target);
|
|
|
|
}, 200);
|
2014-10-04 12:31:45 +00:00
|
|
|
var from = data.nick;
|
|
|
|
if (from.indexOf(".") !== -1) {
|
|
|
|
from = data.target;
|
2014-09-13 21:29:45 +00:00
|
|
|
}
|
2014-09-14 18:49:42 +00:00
|
|
|
var self = false;
|
2014-10-04 12:31:45 +00:00
|
|
|
if (from.toLowerCase() == irc.me.toLowerCase()) {
|
2014-09-14 18:49:42 +00:00
|
|
|
self = true;
|
2014-09-14 17:06:56 +00:00
|
|
|
}
|
2014-09-13 21:29:45 +00:00
|
|
|
var msg = new Msg({
|
|
|
|
type: Msg.Type.MODE,
|
2014-10-04 12:31:45 +00:00
|
|
|
mode: chan.getMode(from),
|
|
|
|
from: from,
|
2014-09-13 21:29:45 +00:00
|
|
|
text: data.mode + " " + data.client,
|
2014-09-14 18:49:42 +00:00
|
|
|
self: self
|
2014-09-13 21:29:45 +00:00
|
|
|
});
|
|
|
|
chan.messages.push(msg);
|
|
|
|
client.emit("msg", {
|
|
|
|
chan: chan.id,
|
|
|
|
msg: msg,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|