Track own host, handle CHGHOST

weechat-hashes
C. McEnroe 2020-03-22 14:32:20 -04:00
parent ccde1c2c8c
commit eb6316c235
3 changed files with 26 additions and 1 deletions

View File

@ -560,6 +560,13 @@ join = #ascii.town
.Re
.It
.Rs
.%A Christine Dodrill
.%T IRCv3.2 chghost Extension
.%I IRCv3 Working Group
.%U https://ircv3.net/specs/extensions/chghost-3.2
.Re
.It
.Rs
.%A Daniel Oaks
.%T IRC Formatting
.%I ircdocs

2
chat.h
View File

@ -97,6 +97,7 @@ extern struct Network {
#define ENUM_CAP \
X("causal.agency/consumer", CapConsumer) \
X("chghost", CapChghost) \
X("extended-join", CapExtendedJoin) \
X("invite-notify", CapInviteNotify) \
X("multi-prefix", CapMultiPrefix) \
@ -119,6 +120,7 @@ extern struct Self {
char *join;
char *nick;
char *user;
char *host;
enum Color color;
char *quit;
} self;

View File

@ -280,10 +280,13 @@ static void handleJoin(struct Message *msg) {
require(msg, true, 1);
uint id = idFor(msg->params[0]);
if (!strcmp(msg->nick, self.nick)) {
if (!self.user) {
if (!self.user || strcmp(self.user, msg->user)) {
set(&self.user, msg->user);
self.color = hash(msg->user);
}
if (!self.host || strcmp(self.host, msg->host)) {
set(&self.host, msg->host);
}
idColors[id] = hash(msg->params[0]);
completeTouch(None, msg->params[0], idColors[id]);
if (replies.join) {
@ -306,6 +309,18 @@ static void handleJoin(struct Message *msg) {
);
}
static void handleChghost(struct Message *msg) {
require(msg, true, 2);
if (strcmp(msg->nick, self.nick)) return;
if (!self.user || strcmp(self.user, msg->params[0])) {
set(&self.user, msg->params[0]);
self.color = hash(msg->params[0]);
}
if (!self.host || strcmp(self.host, msg->params[1])) {
set(&self.host, msg->params[1]);
}
}
static void handlePart(struct Message *msg) {
require(msg, true, 1);
uint id = idFor(msg->params[0]);
@ -1076,6 +1091,7 @@ static const struct Handler {
{ "906", handleErrorSASLFail },
{ "AUTHENTICATE", handleAuthenticate },
{ "CAP", handleCap },
{ "CHGHOST", handleChghost },
{ "ERROR", handleError },
{ "INVITE", handleInvite },
{ "JOIN", handleJoin },