Handle CHGHOST cap

This commit is contained in:
Pavel Djundik 2017-09-19 18:22:50 +03:00 committed by Jérémie Astori
parent b80710ed82
commit b5d39b96b9
No known key found for this signature in database
GPG Key ID: B9A4F245CD67BDE8
7 changed files with 44 additions and 0 deletions

View File

@ -29,6 +29,9 @@ function updateText(condensed, addedTypes) {
case "back": case "back":
strings.push(obj[type] + (obj[type] > 1 ? " users have come back" : " user has come back")); strings.push(obj[type] + (obj[type] > 1 ? " users have come back" : " user has come back"));
break; break;
case "chghost":
strings.push(obj[type] + (obj[type] > 1 ? " users have changed hostname" : " user has changed hostname"));
break;
case "join": case "join":
strings.push(obj[type] + (obj[type] > 1 ? " users have joined the channel" : " user has joined the channel")); strings.push(obj[type] + (obj[type] > 1 ? " users have joined the channel" : " user has joined the channel"));
break; break;

View File

@ -84,12 +84,14 @@ const actionTypes = [
"action", "action",
"whois", "whois",
"ctcp", "ctcp",
"chghost",
"channel_list", "channel_list",
]; ];
const condensedTypes = [ const condensedTypes = [
"away", "away",
"back", "back",
"chghost",
"join", "join",
"part", "part",
"quit", "quit",

View File

@ -0,0 +1,4 @@
{{> ../user_name nick=from.nick mode=from.mode}}
has changed
{{#if new_ident}}username to <b>{{new_ident}}</b>{{#if new_host}}, and{{/if}}{{/if}}
{{#if new_host}}hostname to <i class="hostmask">{{new_host}}</i>{{/if}}

View File

@ -7,6 +7,7 @@ module.exports = {
back: require("./actions/back.tpl"), back: require("./actions/back.tpl"),
ban_list: require("./actions/ban_list.tpl"), ban_list: require("./actions/ban_list.tpl"),
channel_list: require("./actions/channel_list.tpl"), channel_list: require("./actions/channel_list.tpl"),
chghost: require("./actions/chghost.tpl"),
ctcp: require("./actions/ctcp.tpl"), ctcp: require("./actions/ctcp.tpl"),
invite: require("./actions/invite.tpl"), invite: require("./actions/invite.tpl"),
join: require("./actions/join.tpl"), join: require("./actions/join.tpl"),

View File

@ -20,6 +20,7 @@ var events = [
"unhandled", "unhandled",
"banlist", "banlist",
"ctcp", "ctcp",
"chghost",
"error", "error",
"invite", "invite",
"join", "join",
@ -255,6 +256,7 @@ Client.prototype.connect = function(args) {
tls: network.tls, tls: network.tls,
localAddress: config.bind, localAddress: config.bind,
rejectUnauthorized: false, rejectUnauthorized: false,
enable_chghost: true,
enable_echomessage: true, enable_echomessage: true,
auto_reconnect: true, auto_reconnect: true,
auto_reconnect_wait: 10000 + Math.floor(Math.random() * 1000), // If multiple users are connected to the same network, randomize their reconnections a little auto_reconnect_wait: 10000 + Math.floor(Math.random() * 1000), // If multiple users are connected to the same network, randomize their reconnections a little

View File

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

View File

@ -0,0 +1,31 @@
"use strict";
const Msg = require("../../models/msg");
module.exports = function(irc, network) {
const client = this;
// If server supports CHGHOST cap, then changing the hostname does not require
// sending PART and JOIN, which means less work for us over all
irc.on("user updated", function(data) {
const msg = new Msg({
time: data.time,
type: Msg.Type.CHGHOST,
new_ident: data.ident !== data.new_ident ? data.new_ident : "",
new_host: data.hostname !== data.new_host ? data.new_host : "",
self: data.nick === irc.user.nick,
});
network.channels.forEach((chan) => {
const user = chan.findUser(data.nick);
if (typeof user === "undefined") {
return;
}
msg.from = user;
chan.pushMessage(client, msg);
});
});
};