From 7d7c3edcec13e49203ce75254aa2bdc6bcb0678c Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Thu, 24 Mar 2016 22:40:36 +0200 Subject: [PATCH] Add a query command that simply opens a query window --- client/js/lounge.js | 1 + src/client.js | 1 + src/plugins/inputs/query.js | 26 ++++++++++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 src/plugins/inputs/query.js diff --git a/client/js/lounge.js b/client/js/lounge.js index 1efc0f20..7dfa56d8 100644 --- a/client/js/lounge.js +++ b/client/js/lounge.js @@ -17,6 +17,7 @@ $(function() { "/notice", "/op", "/part", + "/query", "/quit", "/raw", "/say", diff --git a/src/client.js b/src/client.js index 3663c28d..9e0856e0 100644 --- a/src/client.js +++ b/src/client.js @@ -42,6 +42,7 @@ var inputs = [ "kick", "mode", "notice", + "query", "quit", "raw", "topic", diff --git a/src/plugins/inputs/query.js b/src/plugins/inputs/query.js new file mode 100644 index 00000000..53548bf3 --- /dev/null +++ b/src/plugins/inputs/query.js @@ -0,0 +1,26 @@ +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 + }); +};