Add /ctcp command and handle ctcp responses
This commit is contained in:
parent
2a7a93d207
commit
16370d8fcc
@ -827,6 +827,11 @@ button,
|
||||
color: #2ecc40;
|
||||
}
|
||||
|
||||
#chat .ctcp .from:before {
|
||||
font-family: FontAwesome;
|
||||
content: "\f0f6";
|
||||
}
|
||||
|
||||
#chat .whois .from:before {
|
||||
font-family: FontAwesome;
|
||||
content: "\f007";
|
||||
|
@ -225,6 +225,7 @@ $(function() {
|
||||
"topic_set_by",
|
||||
"action",
|
||||
"whois",
|
||||
"ctcp",
|
||||
].indexOf(type) !== -1) {
|
||||
data.msg.template = "actions/" + type;
|
||||
msg = $(render("msg_action", data.msg));
|
||||
|
2
client/views/actions/ctcp.tpl
Normal file
2
client/views/actions/ctcp.tpl
Normal file
@ -0,0 +1,2 @@
|
||||
<a href="#" class="user" data-name="{{from}}">{{from}}</a>
|
||||
<b>{{ctcpType}}</b> {{ctcpMessage}}
|
@ -30,6 +30,7 @@ var events = [
|
||||
"whois"
|
||||
];
|
||||
var inputs = [
|
||||
"ctcp",
|
||||
"msg",
|
||||
"part",
|
||||
"action",
|
||||
|
@ -14,6 +14,7 @@ Msg.Type = {
|
||||
PART: "part",
|
||||
QUIT: "quit",
|
||||
TOGGLE: "toggle",
|
||||
CTCP: "ctcp",
|
||||
TOPIC: "topic",
|
||||
TOPIC_SET_BY: "topic_set_by",
|
||||
WHOIS: "whois"
|
||||
|
8
src/plugins/inputs/ctcp.js
Normal file
8
src/plugins/inputs/ctcp.js
Normal file
@ -0,0 +1,8 @@
|
||||
exports.commands = ["ctcp"];
|
||||
|
||||
exports.input = function(network, chan, cmd, args) {
|
||||
if (args.length > 1) {
|
||||
var irc = network.irc;
|
||||
irc.ctcpRequest(args[0], args.slice(1).join(" "));
|
||||
}
|
||||
};
|
@ -1,15 +1,38 @@
|
||||
var pkg = require(process.cwd() + "/package.json");
|
||||
var Msg = require("../../models/msg");
|
||||
|
||||
module.exports = function(irc, network) {
|
||||
var client = this;
|
||||
|
||||
irc.on("ctcp response", function(data) {
|
||||
var chan = network.getChannel(data.nick);
|
||||
if (typeof chan === "undefined") {
|
||||
chan = network.channels[0];
|
||||
}
|
||||
|
||||
var msg = new Msg({
|
||||
type: Msg.Type.CTCP,
|
||||
time: data.time,
|
||||
from: data.nick,
|
||||
ctcpType: data.type,
|
||||
ctcpMessage: data.message
|
||||
});
|
||||
chan.messages.push(msg);
|
||||
client.emit("msg", {
|
||||
chan: chan.id,
|
||||
msg: msg
|
||||
});
|
||||
});
|
||||
|
||||
module.exports = function(irc/* , network */) {
|
||||
irc.on("ctcp request", function(data) {
|
||||
switch (data.type) {
|
||||
case "VERSION":
|
||||
irc.ctcpResponse(data.nick, "VERSION " + pkg.name + " " + pkg.version);
|
||||
irc.ctcpResponse(data.nick, "VERSION", pkg.name + " " + pkg.version);
|
||||
break;
|
||||
case "PING":
|
||||
var split = data.message.split(" ");
|
||||
if (split.length === 2) {
|
||||
irc.ctcpResponse(data.nick, "PING " + split[1]);
|
||||
irc.ctcpResponse(data.nick, "PING", split[1]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user