1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-07 02:03:13 +02:00

irc: add command /setname, add support of message and capability "setname" (closes #1653)

This commit is contained in:
Sébastien Helleu
2021-06-12 21:18:42 +02:00
parent 0525922ee4
commit 70b66c4f6b
25 changed files with 473 additions and 78 deletions
+29 -1
View File
@@ -5669,6 +5669,27 @@ IRC_COMMAND_CALLBACK(squery)
return WEECHAT_RC_OK;
}
/*
* Callback for command "/setname": set real name.
*/
IRC_COMMAND_CALLBACK(setname)
{
IRC_BUFFER_GET_SERVER(buffer);
IRC_COMMAND_CHECK_SERVER("setname", 1, 1);
/* make C compiler happy */
(void) pointer;
(void) data;
WEECHAT_COMMAND_MIN_ARGS(2, "");
irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
"SETNAME :%s", argv_eol[1]);
return WEECHAT_RC_OK;
}
/*
* Callback for command "/squit": disconnects server links.
*/
@@ -6480,7 +6501,8 @@ irc_command_init ()
"\n"
"Capabilities supported by WeeChat are: "
"account-notify, away-notify, cap-notify, chghost, extended-join, "
"invite-notify, multi-prefix, server-time, userhost-in-names.\n"
"invite-notify, multi-prefix, server-time, setname, "
"userhost-in-names.\n"
"\n"
"The capabilities to automatically enable on servers can be set "
"in option irc.server_default.capabilities (or by server in "
@@ -7107,6 +7129,12 @@ irc_command_init ()
N_("service: name of service\n"
" text: text to send"),
NULL, &irc_command_squery, NULL, NULL);
weechat_hook_command (
"setname",
N_("set real name"),
N_("<realname>"),
N_("realname: new real name"),
NULL, &irc_command_setname, NULL, NULL);
weechat_hook_command (
"squit",
N_("disconnect server links"),
+1 -1
View File
@@ -56,7 +56,7 @@ struct t_irc_channel;
/* list of supported capabilities (for completion in command /cap) */
#define IRC_COMMAND_CAP_SUPPORTED_COMPLETION \
"account-notify|away-notify|cap-notify|chghost|extended-join|" \
"invite-notify|multi-prefix|server-time|userhost-in-names|%*"
"invite-notify|multi-prefix|server-time|setname|userhost-in-names|%*"
/* list of supported CTCPs (for completion in command /ctcp) */
#define IRC_COMMAND_CTCP_SUPPORTED_COMPLETION \
+53
View File
@@ -2846,6 +2846,58 @@ IRC_PROTOCOL_CALLBACK(quit)
return WEECHAT_RC_OK;
}
/*
* Callback for the IRC message "SETNAME": set real name
* (with capability "setname").
*
* Message looks like:
* :nick!user@host SETNAME :the realname
*/
IRC_PROTOCOL_CALLBACK(setname)
{
struct t_irc_channel *ptr_channel;
struct t_irc_nick *ptr_nick;
char *pos_realname, *realname_color;
IRC_PROTOCOL_MIN_ARGS(3);
pos_realname = (argv_eol[2][0] == ':') ? argv_eol[2] + 1 : argv_eol[2];
if (weechat_hashtable_has_key (server->cap_list, "setname"))
{
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->realname)
free (ptr_nick->realname);
ptr_nick->realname = strdup (pos_realname);
}
}
}
if (!ignored)
{
realname_color = irc_color_decode (
pos_realname,
weechat_config_boolean (irc_config_network_colors_receive));
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (server, NULL, command, NULL, NULL),
date,
irc_protocol_tags (command, NULL, NULL, NULL),
_("%sReal name set to: %s"),
weechat_prefix ("network"),
(realname_color) ? realname_color : "");
if (realname_color)
free (realname_color);
}
return WEECHAT_RC_OK;
}
/*
* Callback for an IRC message with mode and reason (numeric).
*/
@@ -6611,6 +6663,7 @@ irc_protocol_recv_command (struct t_irc_server *server,
IRCB(pong, 1, 0, pong), /* answer to a ping message */
IRCB(privmsg, 1, 1, privmsg), /* message received */
IRCB(quit, 1, 1, quit), /* close all connections and quit */
IRCB(setname, 0, 1, setname), /* set realname */
IRCB(topic, 0, 1, topic), /* get/set channel topic */
IRCB(wallops, 1, 1, wallops), /* wallops */
IRCB(warn, 1, 0, warn), /* warning received from server */