<commit_before>var _ = require("lodash");
var Chan = require("../../models/chan");

exports.commands = ["query"];

exports.input = function(network, chan, cmd, args) {
	if (args.length === 0) {
		return;
	}

	var target = args[0];
	var query = _.find(network.channels, {name: target});
	if (typeof query !== "undefined") {
		return;
	}

	// If target doesn't start with an allowed character, ignore
	if (!/^[a-zA-Z_\\\[\]{}^`|]/.test(target)) {
		return;
	}

	var newChan = new Chan({
		type: Chan.Type.QUERY,
		name: target
	});
	network.channels.push(newChan);
	this.emit("join", {
		network: network.id,
		chan: newChan
	});
};
<commit_msg>Prevent opening query windows for CHANTYPES and PREFIX<commit_after>var _ = require("lodash");
var Chan = require("../../models/chan");
var Msg = require("../../models/msg");

exports.commands = ["query"];

exports.input = function(network, chan, cmd, args) {
	if (args.length === 0) {
		return;
	}

	var target = args[0];
	var query = _.find(network.channels, {name: target});
	if (typeof query !== "undefined") {
		return;
	}

	var char = target[0];
	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;
	}

	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({
		type: Chan.Type.QUERY,
		name: target
	});
	network.channels.push(newChan);
	this.emit("join", {
		network: network.id,
		chan: newChan
	});
};

{'fraction_non_alphanumeric': 0.18661043753294676, 'fraction_numerical': 0.0036900369003690036, 'mean_word_length': 3.3136363636363635, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2823269', 'n_tokens_mistral': 759, 'n_tokens_neox': 669, 'n_words': 169}