Search channel case insensitively
This commit is contained in:
parent
40677e3248
commit
e0fb454223
@ -55,6 +55,14 @@ Network.prototype.export = function() {
|
|||||||
return network;
|
return network;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Network.prototype.getChannel = function(name) {
|
||||||
|
name = name.toLowerCase();
|
||||||
|
|
||||||
|
return _.find(this.channels, function(that) {
|
||||||
|
return that.name.toLowerCase() === name;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
function prettify(host) {
|
function prettify(host) {
|
||||||
var name = capitalize(host.split(".")[1]);
|
var name = capitalize(host.split(".")[1]);
|
||||||
if (!name) {
|
if (!name) {
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
var _ = require("lodash");
|
|
||||||
|
|
||||||
exports.commands = ["msg", "say"];
|
exports.commands = ["msg", "say"];
|
||||||
|
|
||||||
exports.input = function(network, chan, cmd, args) {
|
exports.input = function(network, chan, cmd, args) {
|
||||||
@ -21,7 +19,7 @@ exports.input = function(network, chan, cmd, args) {
|
|||||||
var msg = args.join(" ");
|
var msg = args.join(" ");
|
||||||
irc.say(target, msg);
|
irc.say(target, msg);
|
||||||
|
|
||||||
var channel = _.find(network.channels, {name: target});
|
var channel = network.getChannel(target);
|
||||||
if (typeof channel !== "undefined") {
|
if (typeof channel !== "undefined") {
|
||||||
irc.emit("privmsg", {
|
irc.emit("privmsg", {
|
||||||
nick: irc.user.nick,
|
nick: irc.user.nick,
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
var _ = require("lodash");
|
|
||||||
|
|
||||||
exports.commands = ["notice"];
|
exports.commands = ["notice"];
|
||||||
|
|
||||||
exports.input = function(network, chan, cmd, args) {
|
exports.input = function(network, chan, cmd, args) {
|
||||||
@ -11,7 +9,7 @@ exports.input = function(network, chan, cmd, args) {
|
|||||||
var irc = network.irc;
|
var irc = network.irc;
|
||||||
irc.notice(args[0], message);
|
irc.notice(args[0], message);
|
||||||
|
|
||||||
var targetChan = _.find(network.channels, {name: args[0]});
|
var targetChan = network.getChannel(args[0]);
|
||||||
if (typeof targetChan === "undefined") {
|
if (typeof targetChan === "undefined") {
|
||||||
message = "{to " + args[0] + "} " + message;
|
message = "{to " + args[0] + "} " + message;
|
||||||
targetChan = chan;
|
targetChan = chan;
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
var _ = require("lodash");
|
|
||||||
var Msg = require("../../models/msg");
|
var Msg = require("../../models/msg");
|
||||||
|
|
||||||
module.exports = function(irc, network) {
|
module.exports = function(irc, network) {
|
||||||
@ -6,7 +5,7 @@ module.exports = function(irc, network) {
|
|||||||
irc.on("invite", function(data) {
|
irc.on("invite", function(data) {
|
||||||
var target = data.to;
|
var target = data.to;
|
||||||
|
|
||||||
var chan = _.find(network.channels, {name: data.channel});
|
var chan = network.getChannel(data.channel);
|
||||||
if (typeof chan === "undefined") {
|
if (typeof chan === "undefined") {
|
||||||
chan = network.channels[0];
|
chan = network.channels[0];
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
var _ = require("lodash");
|
|
||||||
var Chan = require("../../models/chan");
|
var Chan = require("../../models/chan");
|
||||||
var Msg = require("../../models/msg");
|
var Msg = require("../../models/msg");
|
||||||
var User = require("../../models/user");
|
var User = require("../../models/user");
|
||||||
@ -6,7 +5,7 @@ var User = require("../../models/user");
|
|||||||
module.exports = function(irc, network) {
|
module.exports = function(irc, network) {
|
||||||
var client = this;
|
var client = this;
|
||||||
irc.on("join", function(data) {
|
irc.on("join", function(data) {
|
||||||
var chan = _.find(network.channels, {name: data.channel});
|
var chan = network.getChannel(data.channel);
|
||||||
if (typeof chan === "undefined") {
|
if (typeof chan === "undefined") {
|
||||||
chan = new Chan({
|
chan = new Chan({
|
||||||
name: data.channel
|
name: data.channel
|
||||||
|
@ -4,7 +4,7 @@ var Msg = require("../../models/msg");
|
|||||||
module.exports = function(irc, network) {
|
module.exports = function(irc, network) {
|
||||||
var client = this;
|
var client = this;
|
||||||
irc.on("kick", function(data) {
|
irc.on("kick", function(data) {
|
||||||
var chan = _.find(network.channels, {name: data.channel});
|
var chan = network.getChannel(data.channel);
|
||||||
if (typeof chan === "undefined") {
|
if (typeof chan === "undefined") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ module.exports = function(irc, network) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var chan = _.find(network.channels, {name: data.target});
|
var chan = network.getChannel(data.target);
|
||||||
if (typeof chan === "undefined") {
|
if (typeof chan === "undefined") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
var _ = require("lodash");
|
|
||||||
var Chan = require("../../models/chan");
|
var Chan = require("../../models/chan");
|
||||||
var Msg = require("../../models/msg");
|
var Msg = require("../../models/msg");
|
||||||
var Helper = require("../../helper");
|
var Helper = require("../../helper");
|
||||||
@ -34,7 +33,7 @@ module.exports = function(irc, network) {
|
|||||||
target = data.nick;
|
target = data.nick;
|
||||||
}
|
}
|
||||||
|
|
||||||
var chan = _.find(network.channels, {name: target});
|
var chan = network.getChannel(target);
|
||||||
if (typeof chan === "undefined") {
|
if (typeof chan === "undefined") {
|
||||||
chan = new Chan({
|
chan = new Chan({
|
||||||
type: Chan.Type.QUERY,
|
type: Chan.Type.QUERY,
|
||||||
|
@ -10,7 +10,7 @@ module.exports = function(irc, network) {
|
|||||||
if (data.target === irc.user.nick) {
|
if (data.target === irc.user.nick) {
|
||||||
targetChan = network.channels[0];
|
targetChan = network.channels[0];
|
||||||
} else {
|
} else {
|
||||||
targetChan = _.find(network.channels, {name: data.target});
|
targetChan = network.getChannel(data.target);
|
||||||
if (typeof targetChan === "undefined") {
|
if (typeof targetChan === "undefined") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ var User = require("../../models/user");
|
|||||||
module.exports = function(irc, network) {
|
module.exports = function(irc, network) {
|
||||||
var client = this;
|
var client = this;
|
||||||
irc.on("userlist", function(data) {
|
irc.on("userlist", function(data) {
|
||||||
var chan = _.find(network.channels, {name: data.channel});
|
var chan = network.getChannel(data.channel);
|
||||||
if (typeof chan === "undefined") {
|
if (typeof chan === "undefined") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ var Msg = require("../../models/msg");
|
|||||||
module.exports = function(irc, network) {
|
module.exports = function(irc, network) {
|
||||||
var client = this;
|
var client = this;
|
||||||
irc.on("part", function(data) {
|
irc.on("part", function(data) {
|
||||||
var chan = _.find(network.channels, {name: data.channel});
|
var chan = network.getChannel(data.channel);
|
||||||
if (typeof chan === "undefined") {
|
if (typeof chan === "undefined") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
var _ = require("lodash");
|
|
||||||
var Msg = require("../../models/msg");
|
var Msg = require("../../models/msg");
|
||||||
|
|
||||||
module.exports = function(irc, network) {
|
module.exports = function(irc, network) {
|
||||||
var client = this;
|
var client = this;
|
||||||
irc.on("topic", function(data) {
|
irc.on("topic", function(data) {
|
||||||
var chan = _.find(network.channels, {name: data.channel});
|
var chan = network.getChannel(data.channel);
|
||||||
if (typeof chan === "undefined") {
|
if (typeof chan === "undefined") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -31,7 +30,7 @@ module.exports = function(irc, network) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
irc.on("topicsetby", function(data) {
|
irc.on("topicsetby", function(data) {
|
||||||
var chan = _.find(network.channels, {name: data.channel});
|
var chan = network.getChannel(data.channel);
|
||||||
if (typeof chan === "undefined") {
|
if (typeof chan === "undefined") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
var _ = require("lodash");
|
|
||||||
var Chan = require("../../models/chan");
|
var Chan = require("../../models/chan");
|
||||||
var Msg = require("../../models/msg");
|
var Msg = require("../../models/msg");
|
||||||
|
|
||||||
module.exports = function(irc, network) {
|
module.exports = function(irc, network) {
|
||||||
var client = this;
|
var client = this;
|
||||||
irc.on("whois", function(data) {
|
irc.on("whois", function(data) {
|
||||||
var chan = _.find(network.channels, {name: data.nick});
|
var chan = network.getChannel(data.nick);
|
||||||
if (typeof chan === "undefined") {
|
if (typeof chan === "undefined") {
|
||||||
chan = new Chan({
|
chan = new Chan({
|
||||||
type: Chan.Type.QUERY,
|
type: Chan.Type.QUERY,
|
||||||
|
Loading…
Reference in New Issue
Block a user