From f731707fe7c90484ee28e5d22df2e0b74f31a616 Mon Sep 17 00:00:00 2001 From: Mattias Erming Date: Sun, 18 May 2014 18:18:19 +0200 Subject: [PATCH] Added '/ame' and '/amsg' command --- README.md | 5 +++-- client/js/chat.js | 3 +++ lib/server.js | 31 +++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b2b5074..74489cf 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,8 @@ Run your IRC client on a server and access it from the web browser. This gives y ### Commands These are the commands currently implemented: -- [ ] /ame -- [ ] /amsg +- [x] /ame +- [x] /amsg - [x] /close - [x] /connect - [x] /deop @@ -29,6 +29,7 @@ These are the commands currently implemented: - [x] /say - [x] /send - [x] /server +- [ ] /slap - [ ] /time - [x] /topic - [ ] /version diff --git a/client/js/chat.js b/client/js/chat.js index 823c63f..1dd5b7f 100644 --- a/client/js/chat.js +++ b/client/js/chat.js @@ -3,6 +3,8 @@ $(function() { var sidebar = $("#sidebar"); var commands = [ + "/ame", + "/amsg", "/close", "/connect", "/deop", @@ -187,6 +189,7 @@ $(function() { return; } input.val(""); + input.prev(".hint").val(""); socket.emit("input", { id: form.data("target"), text: text, diff --git a/lib/server.js b/lib/server.js index 2200bd2..97aeec4 100644 --- a/lib/server.js +++ b/lib/server.js @@ -186,6 +186,37 @@ function input(data) { }); break; + case "ame": + var type = "action"; + case "amsg": + var user = client.me; + var text = args.slice(1).join(" "); + var channels = []; + network.channels.forEach(function(chan) { + if (chan.type == "channel") { + channels.push(chan.name); + var msg = new Msg({ + type: type, + from: user, + text: text, + }); + chan.messages.push(msg) + sockets.emit("msg", { + id: chan.id, + msg: msg, + }); + } + }); + client[type || "send"]( + channels, + text + ); + break; + + case "ame": + console.log("AME"); + break; + case "server": case "connect": if (args[1]) {