From cada00ab6ad21dac3706c891cba670dbf17e66d9 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Sun, 24 Apr 2016 18:12:54 +0300 Subject: [PATCH] Display unhandled numerics on the client --- client/css/style.css | 4 ++++ client/js/lounge.js | 10 ++++++---- client/themes/morning.css | 4 ++++ client/themes/zenburn.css | 4 ++++ client/views/msg_unhandled.tpl | 11 +++++++++++ src/client.js | 1 + src/models/msg.js | 1 + src/plugins/irc-events/unhandled.js | 18 ++++++++++++++++++ 8 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 client/views/msg_unhandled.tpl create mode 100644 src/plugins/irc-events/unhandled.js diff --git a/client/css/style.css b/client/css/style.css index 0bffa4dc..f8ecac6f 100644 --- a/client/css/style.css +++ b/client/css/style.css @@ -914,6 +914,10 @@ button { color: #f00; } +#chat .unhandled .from { + color: #eee; +} + #chat .msg.toggle .time { visibility: hidden; } diff --git a/client/js/lounge.js b/client/js/lounge.js index 694cf59e..4eb1b0f9 100644 --- a/client/js/lounge.js +++ b/client/js/lounge.js @@ -220,7 +220,7 @@ $(function() { } var chan = chat.find(target); - var msg; + var template = "msg"; if (highlights.some(function(h) { return data.msg.text.indexOf(h) > -1; @@ -243,11 +243,13 @@ $(function() { "ctcp", ].indexOf(type) !== -1) { data.msg.template = "actions/" + type; - msg = $(render("msg_action", data.msg)); - } else { - msg = $(render("msg", data.msg)); + template = "msg_action"; + } else if (type === "unhandled") { + template = "msg_unhandled"; } + var msg = $(render(template, data.msg)); + var text = msg.find(".text"); if (text.find("i").size() === 1) { text = text.find("i"); diff --git a/client/themes/morning.css b/client/themes/morning.css index 600f364e..5679ed48 100644 --- a/client/themes/morning.css +++ b/client/themes/morning.css @@ -195,6 +195,10 @@ body { color: #f92772; } +#chat .unhandled .from { + color: #99a2b4; +} + #chat .msg.quit .time, #chat .msg.quit .from button { color: #d0907d !important; diff --git a/client/themes/zenburn.css b/client/themes/zenburn.css index 494d25a8..92547a68 100644 --- a/client/themes/zenburn.css +++ b/client/themes/zenburn.css @@ -222,6 +222,10 @@ body { color: #bc6c4c; } +#chat .unhandled .from { + color: #aaa; +} + #chat .msg.quit .time, #chat .msg.quit .from button { color: #bc6c9c !important; diff --git a/client/views/msg_unhandled.tpl b/client/views/msg_unhandled.tpl new file mode 100644 index 00000000..25b568f9 --- /dev/null +++ b/client/views/msg_unhandled.tpl @@ -0,0 +1,11 @@ +
+ + {{tz time}} + + [{{command}}] + + {{#each params}} + {{this}} + {{/each}} + +
diff --git a/src/client.js b/src/client.js index 15e0830d..d1d51de6 100644 --- a/src/client.js +++ b/src/client.js @@ -13,6 +13,7 @@ module.exports = Client; var id = 0; var events = [ "connection", + "unhandled", "ctcp", "error", "invite", diff --git a/src/models/msg.js b/src/models/msg.js index 0f29d5ab..73c19ff1 100644 --- a/src/models/msg.js +++ b/src/models/msg.js @@ -1,6 +1,7 @@ var _ = require("lodash"); Msg.Type = { + UNHANDLED: "unhandled", ACTION: "action", ERROR: "error", INVITE: "invite", diff --git a/src/plugins/irc-events/unhandled.js b/src/plugins/irc-events/unhandled.js new file mode 100644 index 00000000..c089d0cf --- /dev/null +++ b/src/plugins/irc-events/unhandled.js @@ -0,0 +1,18 @@ +var Msg = require("../../models/msg"); + +module.exports = function(irc, network) { + var client = this; + + irc.on("unknown command", function(command) { + // Do not display users own name + if (command.params[0] === network.irc.user.nick) { + command.params.shift(); + } + + network.channels[0].pushMessage(client, new Msg({ + type: Msg.Type.UNHANDLED, + command: command.command, + params: command.params + })); + }); +};