Fix broken queries

This commit is contained in:
Mattias Erming 2014-08-27 07:34:03 -07:00
parent 90cce21e3a
commit 5594d49d11
3 changed files with 5 additions and 7 deletions

View File

@ -1,7 +1,7 @@
{ {
"name": "shout", "name": "shout",
"description": "A web IRC client", "description": "A web IRC client",
"version": "0.12.1", "version": "0.12.2",
"author": "Mattias Erming", "author": "Mattias Erming",
"preferGlobal": true, "preferGlobal": true,
"bin": { "bin": {

View File

@ -5,14 +5,11 @@ module.exports = function(network, chan, cmd, args) {
if (cmd != "say" && cmd != "msg") { if (cmd != "say" && cmd != "msg") {
return; return;
} }
if (args.length === 0 || args[0] === "") { if (args.length === 0 || args[0] === "") {
return; return;
} }
var client = this; var client = this;
var irc = network.irc; var irc = network.irc;
var target = ""; var target = "";
if (cmd == "msg") { if (cmd == "msg") {
target = args.shift(); target = args.shift();
@ -22,10 +19,8 @@ module.exports = function(network, chan, cmd, args) {
} else { } else {
target = chan.name; target = chan.name;
} }
var text = args.join(" "); var text = args.join(" ");
irc.send(target, text); irc.send(target, text);
if (target == chan.name && typeof chan !== "undefined") { if (target == chan.name && typeof chan !== "undefined") {
irc.emit("message", { irc.emit("message", {
from: irc.me, from: irc.me,

View File

@ -6,7 +6,10 @@ module.exports = function(irc, network) {
var client = this; var client = this;
irc.on("message", function(data) { irc.on("message", function(data) {
var target = data.to; var target = data.to;
var chan = _.findWhere(network.channels, {name: target.charAt(0) == "#" ? target : data.from}); if (target == irc.me) {
target = data.from;
}
var chan = _.findWhere(network.channels, {name: target});
if (typeof chan === "undefined") { if (typeof chan === "undefined") {
chan = new Chan({ chan = new Chan({
type: Chan.Type.QUERY, type: Chan.Type.QUERY,