Prevent opening query windows for CHANTYPES and PREFIX
This commit is contained in:
parent
829b879f55
commit
338116a01e
@ -1,5 +1,6 @@
|
|||||||
var _ = require("lodash");
|
var _ = require("lodash");
|
||||||
var Chan = require("../../models/chan");
|
var Chan = require("../../models/chan");
|
||||||
|
var Msg = require("../../models/msg");
|
||||||
|
|
||||||
exports.commands = ["query"];
|
exports.commands = ["query"];
|
||||||
|
|
||||||
@ -14,11 +15,31 @@ exports.input = function(network, chan, cmd, args) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If target doesn't start with an allowed character, ignore
|
var char = target[0];
|
||||||
if (!/^[a-zA-Z_\\\[\]{}^`|]/.test(target)) {
|
if (network.irc.network.options.CHANTYPES && network.irc.network.options.CHANTYPES.indexOf(char) !== -1) {
|
||||||
|
this.emit("msg", {
|
||||||
|
chan: chan.id,
|
||||||
|
msg: new Msg({
|
||||||
|
type: Msg.Type.ERROR,
|
||||||
|
text: "You can not open query windows for channels, use /join instead."
|
||||||
|
})
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (var i = 0; i < network.irc.network.options.PREFIX.length; i++) {
|
||||||
|
if (network.irc.network.options.PREFIX[i].symbol === char) {
|
||||||
|
this.emit("msg", {
|
||||||
|
chan: chan.id,
|
||||||
|
msg: new Msg({
|
||||||
|
type: Msg.Type.ERROR,
|
||||||
|
text: "You can not open query windows for names starting with a user prefix."
|
||||||
|
})
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var newChan = new Chan({
|
var newChan = new Chan({
|
||||||
type: Chan.Type.QUERY,
|
type: Chan.Type.QUERY,
|
||||||
name: target
|
name: target
|
||||||
|
Loading…
Reference in New Issue
Block a user