Merge pull request #286 from thelounge/xpaw/unknown-command

Display unhandled numerics on the client
This commit is contained in:
Jérémie Astori 2016-07-05 23:23:15 -04:00 committed by GitHub
commit b3d3582d2f
8 changed files with 49 additions and 4 deletions

View File

@ -914,6 +914,10 @@ button {
color: #f00; color: #f00;
} }
#chat .unhandled .from {
color: #eee;
}
#chat .msg.toggle .time { #chat .msg.toggle .time {
visibility: hidden; visibility: hidden;
} }

View File

@ -222,7 +222,7 @@ $(function() {
} }
var chan = chat.find(target); var chan = chat.find(target);
var msg; var template = "msg";
if (!data.msg.highlight && !data.msg.self && (type === "message" || type === "notice") && highlights.some(function(h) { if (!data.msg.highlight && !data.msg.self && (type === "message" || type === "notice") && highlights.some(function(h) {
return data.msg.text.indexOf(h) > -1; return data.msg.text.indexOf(h) > -1;
@ -245,11 +245,13 @@ $(function() {
"ctcp", "ctcp",
].indexOf(type) !== -1) { ].indexOf(type) !== -1) {
data.msg.template = "actions/" + type; data.msg.template = "actions/" + type;
msg = $(render("msg_action", data.msg)); template = "msg_action";
} else { } else if (type === "unhandled") {
msg = $(render("msg", data.msg)); template = "msg_unhandled";
} }
var msg = $(render(template, data.msg));
var text = msg.find(".text"); var text = msg.find(".text");
if (text.find("i").size() === 1) { if (text.find("i").size() === 1) {
text = text.find("i"); text = text.find("i");

View File

@ -195,6 +195,10 @@ body {
color: #f92772; color: #f92772;
} }
#chat .unhandled .from {
color: #99a2b4;
}
#chat .msg.quit .time, #chat .msg.quit .time,
#chat .msg.quit .from button { #chat .msg.quit .from button {
color: #d0907d !important; color: #d0907d !important;

View File

@ -222,6 +222,10 @@ body {
color: #bc6c4c; color: #bc6c4c;
} }
#chat .unhandled .from {
color: #aaa;
}
#chat .msg.quit .time, #chat .msg.quit .time,
#chat .msg.quit .from button { #chat .msg.quit .from button {
color: #bc6c9c !important; color: #bc6c9c !important;

View File

@ -0,0 +1,11 @@
<div class="msg {{type}}{{#if self}} self{{/if}}{{#if highlight}} highlight{{/if}}">
<span class="time">
{{tz time}}
</span>
<span class="from">[{{command}}]</span>
<span class="text">
{{#each params}}
<span>{{this}}</span>
{{/each}}
</span>
</div>

View File

@ -13,6 +13,7 @@ module.exports = Client;
var id = 0; var id = 0;
var events = [ var events = [
"connection", "connection",
"unhandled",
"ctcp", "ctcp",
"error", "error",
"invite", "invite",

View File

@ -1,6 +1,7 @@
var _ = require("lodash"); var _ = require("lodash");
Msg.Type = { Msg.Type = {
UNHANDLED: "unhandled",
ACTION: "action", ACTION: "action",
ERROR: "error", ERROR: "error",
INVITE: "invite", INVITE: "invite",

View File

@ -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
}));
});
};