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