Let user know someone is making a CTCP request against their nick

This commit is contained in:
Jérémie Astori 2018-01-02 00:29:29 -05:00
parent da0ab54292
commit e03694b49c
No known key found for this signature in database
GPG key ID: B9A4F245CD67BDE8
5 changed files with 21 additions and 4 deletions

View file

@ -236,6 +236,7 @@ kbd {
#chat .topic .from::before, #chat .topic .from::before,
#chat .mode .from::before, #chat .mode .from::before,
#chat .ctcp .from::before, #chat .ctcp .from::before,
#chat .ctcp_request .from::before,
#chat .whois .from::before, #chat .whois .from::before,
#chat .nick .from::before, #chat .nick .from::before,
#chat .action .from::before, #chat .action .from::before,
@ -351,7 +352,8 @@ kbd {
color: #2ecc40; color: #2ecc40;
} }
#chat .ctcp .from::before { #chat .ctcp .from::before,
#chat .ctcp_request .from::before {
content: "\f0f6"; /* http://fontawesome.io/icon/file-text-o/ */ content: "\f0f6"; /* http://fontawesome.io/icon/file-text-o/ */
} }

View file

@ -1,2 +1,2 @@
{{> ../user_name from}} {{> ../user_name from}}
<b>{{ctcpType}}</b> <span class="ctcp-message">{{{parse ctcpMessage}}}</span> <span class="ctcp-message">{{{parse ctcpMessage}}}</span>

View file

@ -0,0 +1,3 @@
{{> ../user_name from}}
sent a <abbr title="Client-to-client_protocol">CTCP</abbr> request:
<span class="ctcp-message">{{{parse ctcpMessage}}}</span>

View file

@ -62,6 +62,7 @@ Msg.Type = {
PART: "part", PART: "part",
QUIT: "quit", QUIT: "quit",
CTCP: "ctcp", CTCP: "ctcp",
CTCP_REQUEST: "ctcp_request",
CHGHOST: "chghost", CHGHOST: "chghost",
TOPIC: "topic", TOPIC: "topic",
TOPIC_SET_BY: "topic_set_by", TOPIC_SET_BY: "topic_set_by",

View file

@ -2,6 +2,7 @@
const Helper = require("../../helper"); const Helper = require("../../helper");
const Msg = require("../../models/msg"); const Msg = require("../../models/msg");
const User = require("../../models/user");
const pkg = require("../../../package.json"); const pkg = require("../../../package.json");
const ctcpResponses = { const ctcpResponses = {
@ -16,19 +17,19 @@ const ctcpResponses = {
module.exports = function(irc, network) { module.exports = function(irc, network) {
const client = this; const client = this;
const lobby = network.channels[0];
irc.on("ctcp response", function(data) { irc.on("ctcp response", function(data) {
let chan = network.getChannel(data.nick); let chan = network.getChannel(data.nick);
if (typeof chan === "undefined") { if (typeof chan === "undefined") {
chan = network.channels[0]; chan = lobby;
} }
const msg = new Msg({ const msg = new Msg({
type: Msg.Type.CTCP, type: Msg.Type.CTCP,
time: data.time, time: data.time,
from: chan.getUser(data.nick), from: chan.getUser(data.nick),
ctcpType: data.type,
ctcpMessage: data.message, ctcpMessage: data.message,
}); });
chan.pushMessage(client, msg); chan.pushMessage(client, msg);
@ -40,5 +41,15 @@ module.exports = function(irc, network) {
if (response) { if (response) {
irc.ctcpResponse(data.nick, data.type, response(data)); irc.ctcpResponse(data.nick, data.type, response(data));
} }
// Let user know someone is making a CTCP request against their nick
const msg = new Msg({
type: Msg.Type.CTCP_REQUEST,
time: data.time,
from: new User({nick: data.nick}),
hostmask: data.ident + "@" + data.hostname,
ctcpMessage: data.message,
});
lobby.pushMessage(client, msg);
}); });
}; };