diff options
author | Simmo Saan <simmo.saan@gmail.com> | 2015-12-30 17:20:58 +0200 |
---|---|---|
committer | Simmo Saan <simmo.saan@gmail.com> | 2017-11-05 13:24:12 +0200 |
commit | d3c79894e79146854c706a42dabff3443e03ae42 (patch) | |
tree | ea2c016a05b69588d4cab46a21f7a6f71344762c /src/plugins/irc/irc-protocol.c | |
parent | b55c158280c3e09a839817e6d441bd71c1fe916d (diff) | |
download | weechat-d3c79894e79146854c706a42dabff3443e03ae42.zip |
irc: add support for IRCv3.2 chghost
Diffstat (limited to 'src/plugins/irc/irc-protocol.c')
-rw-r--r-- | src/plugins/irc/irc-protocol.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index 67b0109cd..0c0b59fa1 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -638,6 +638,43 @@ IRC_PROTOCOL_CALLBACK(cap) } /* + * Callback for the IRC message "CHGHOST": user/host change of a nick (with + * capability "chghost"): + * http://ircv3.net/specs/extensions/chghost-3.2.html + * + * Message looks like: + * :nick!user@host CHGHOST user new.host.goes.here + * :nick!user@host CHGHOST newuser host + * :nick!user@host CHGHOST newuser new.host.goes.here + */ + +IRC_PROTOCOL_CALLBACK(chghost) +{ + int length; + struct t_irc_channel *ptr_channel; + struct t_irc_nick *ptr_nick; + + IRC_PROTOCOL_MIN_ARGS(4); + + for (ptr_channel = server->channels; ptr_channel; + ptr_channel = ptr_channel->next_channel) + { + ptr_nick = irc_nick_search (server, ptr_channel, nick); + if (ptr_nick) + { + if (ptr_nick->host) + free (ptr_nick->host); + length = strlen (argv[2]) + 1 + strlen (argv[3]) + 1; + ptr_nick->host = malloc (length); + if (ptr_nick->host) + snprintf (ptr_nick->host, length, "%s@%s", argv[2], argv[3]); + } + } + + return WEECHAT_RC_OK; +} + +/* * Callback for the IRC message "ERROR". * * Message looks like: @@ -5706,6 +5743,7 @@ irc_protocol_recv_command (struct t_irc_server *server, { "authenticate", /* authenticate */ 1, 0, &irc_protocol_cb_authenticate }, { "away", /* away (cap away-notify) */ 1, 0, &irc_protocol_cb_away }, { "cap", /* client capability */ 1, 0, &irc_protocol_cb_cap }, + { "chghost", /* user/host change (cap chghost) */ 1, 0, &irc_protocol_cb_chghost }, { "error", /* error received from IRC server */ 1, 0, &irc_protocol_cb_error }, { "invite", /* invite a nick on a channel */ 1, 0, &irc_protocol_cb_invite }, { "join", /* join a channel */ 1, 0, &irc_protocol_cb_join }, |