From b5571f8fdb7fc2d9385af0786eb5146abf3bb725 Mon Sep 17 00:00:00 2001 From: Mattias Erming Date: Fri, 14 Mar 2014 15:26:00 +0100 Subject: [PATCH] Added /kick command --- lib/server.js | 51 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/lib/server.js b/lib/server.js index e474326b..2334983a 100644 --- a/lib/server.js +++ b/lib/server.js @@ -163,14 +163,34 @@ function handleInput(input) { case "NICK": var irc = network.irc; if (typeof irc !== "undefined") { - irc.send(cmd, argv[1] || config.nick); + irc.send("NICK", argv[1] || config.nick); + } + break; + + case "KICK": + var irc = network.irc; + if (argv[1] && typeof irc !== "undefined") { + irc.send( + "KICK", + target.channel.get("name"), + argv[1] + ); } break; case "WHOIS": var irc = network.irc; if (typeof irc !== "undefined") { - irc.send(cmd, argv[1] || target.channel.get("name")); + irc.send("WHOIS", argv[1] || target.channel.get("name")); + } + break; + + // This command is used for debugging purposes. + // Send raw commands. + case "SEND": + var irc = network.irc; + if (typeof irc !== "undefined") { + irc.send.apply(irc, argv.splice(1)); } break; @@ -273,6 +293,7 @@ function handleEvent(argv) { name: argv.nick }) ); + var messages = channel.get("messages"); messages.add( new models.Message({ @@ -303,6 +324,32 @@ function handleEvent(argv) { } break; + case "KICK": + var channel = channels.findWhere({ + name: argv.args[0] + }); + + var users = channel.get("users"); + if (argv.args[1] == network.get("nick")) { + users.reset(); + } else { + users.remove( + users.findWhere({ + name: argv.args[1] + }) + ); + } + + var messages = channel.get("messages"); + messages.add( + new models.Message({ + user: argv.args[1], + text: "was kicked from " + argv.args[0] + " by " + argv.nick, + type: "kick" + }) + ); + break; + case "TOPIC": var channel = channels.findWhere({name: argv.args[0]}); var messages = channel.get("messages");