hardlounge/src/plugins/irc-events/mode.js

35 lines
797 B
JavaScript
Raw Normal View History

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;
2015-09-30 22:39:57 +00:00
if (from.toLowerCase() === irc.me.toLowerCase()) {
2014-09-14 18:49:42 +00:00
self = true;
}
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,
2016-01-23 14:39:54 +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,
});
}
});
};