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":
strings.push(obj[type] + (obj[type] > 1 ? " users have come back" : " user has come back"));
break;
case "chghost":
strings.push(obj[type] + (obj[type] > 1 ? " users have changed hostname" : " user has changed hostname"));
break;
case "join":
strings.push(obj[type] + (obj[type] > 1 ? " users have joined the channel" : " user has joined the channel"));
break;

View file

@ -84,12 +84,14 @@ const actionTypes = [
"action",
"whois",
"ctcp",
"chghost",
"channel_list",
];
const condensedTypes = [
"away",
"back",
"chghost",
"join",
"part",
"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"),
ban_list: require("./actions/ban_list.tpl"),
channel_list: require("./actions/channel_list.tpl"),
chghost: require("./actions/chghost.tpl"),
ctcp: require("./actions/ctcp.tpl"),
invite: require("./actions/invite.tpl"),
join: require("./actions/join.tpl"),

View file

@ -20,6 +20,7 @@ var events = [
"unhandled",
"banlist",
"ctcp",
"chghost",
"error",
"invite",
"join",
@ -255,6 +256,7 @@ Client.prototype.connect = function(args) {
tls: network.tls,
localAddress: config.bind,
rejectUnauthorized: false,
enable_chghost: true,
enable_echomessage: 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

View file

@ -56,6 +56,7 @@ Msg.Type = {
PART: "part",
QUIT: "quit",
CTCP: "ctcp",
CHGHOST: "chghost",
TOPIC: "topic",
TOPIC_SET_BY: "topic_set_by",
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);
});
});
};