mirror of
https://github.com/weechat/weechat.git
synced 2026-06-28 05:46:38 +02:00
irc: add options and display SETNAME command in channels and private buffers (closes #1805)
New options: - irc.color.message_setname - irc.look.smart_filter_setname
This commit is contained in:
@@ -1176,7 +1176,7 @@ irc_channel_join_smart_filtered_unmask (struct t_irc_channel *channel,
|
||||
const char *nick)
|
||||
{
|
||||
int i, unmask_delay, length_tags, nick_found, join, account;
|
||||
int chghost, nick_changed, smart_filtered, remove_smart_filter;
|
||||
int chghost, setname, nick_changed, smart_filtered, remove_smart_filter;
|
||||
time_t *ptr_time, date_min;
|
||||
struct t_hdata *hdata_line, *hdata_line_data;
|
||||
struct t_gui_line *own_lines;
|
||||
@@ -1254,6 +1254,7 @@ irc_channel_join_smart_filtered_unmask (struct t_irc_channel *channel,
|
||||
join = 0;
|
||||
account = 0;
|
||||
chghost = 0;
|
||||
setname = 0;
|
||||
nick_changed = 0;
|
||||
irc_nick1 = NULL;
|
||||
irc_nick2 = NULL;
|
||||
@@ -1271,6 +1272,8 @@ irc_channel_join_smart_filtered_unmask (struct t_irc_channel *channel,
|
||||
account = 1;
|
||||
else if (strcmp (tags[i], "irc_chghost") == 0)
|
||||
chghost = 1;
|
||||
else if (strcmp (tags[i], "irc_setname") == 0)
|
||||
setname = 1;
|
||||
else if (strcmp (tags[i], "irc_nick") == 0)
|
||||
nick_changed = 1;
|
||||
else if (strncmp (tags[i], "irc_nick1_", 10) == 0)
|
||||
@@ -1294,7 +1297,8 @@ irc_channel_join_smart_filtered_unmask (struct t_irc_channel *channel,
|
||||
break;
|
||||
remove_smart_filter = 1;
|
||||
}
|
||||
else if (nick_found && (join || account || chghost) && smart_filtered)
|
||||
else if (nick_found && (join || account || chghost || setname)
|
||||
&& smart_filtered)
|
||||
{
|
||||
remove_smart_filter = 1;
|
||||
}
|
||||
|
||||
@@ -88,6 +88,7 @@
|
||||
#define IRC_COLOR_MESSAGE_CHGHOST weechat_color(weechat_config_string(irc_config_color_message_chghost))
|
||||
#define IRC_COLOR_MESSAGE_KICK weechat_color(weechat_config_string(irc_config_color_message_kick))
|
||||
#define IRC_COLOR_MESSAGE_QUIT weechat_color(weechat_config_string(irc_config_color_message_quit))
|
||||
#define IRC_COLOR_MESSAGE_SETNAME weechat_color(weechat_config_string(irc_config_color_message_setname))
|
||||
#define IRC_COLOR_REASON_KICK weechat_color(weechat_config_string(irc_config_color_reason_kick))
|
||||
#define IRC_COLOR_REASON_QUIT weechat_color(weechat_config_string(irc_config_color_reason_quit))
|
||||
#define IRC_COLOR_TOPIC_CURRENT weechat_color(weechat_config_string(irc_config_color_topic_current))
|
||||
|
||||
@@ -110,6 +110,7 @@ struct t_config_option *irc_config_look_smart_filter_join_unmask;
|
||||
struct t_config_option *irc_config_look_smart_filter_mode;
|
||||
struct t_config_option *irc_config_look_smart_filter_nick;
|
||||
struct t_config_option *irc_config_look_smart_filter_quit;
|
||||
struct t_config_option *irc_config_look_smart_filter_setname;
|
||||
struct t_config_option *irc_config_look_temporary_servers;
|
||||
struct t_config_option *irc_config_look_topic_strip_colors;
|
||||
|
||||
@@ -129,6 +130,7 @@ struct t_config_option *irc_config_color_message_chghost;
|
||||
struct t_config_option *irc_config_color_message_join;
|
||||
struct t_config_option *irc_config_color_message_kick;
|
||||
struct t_config_option *irc_config_color_message_quit;
|
||||
struct t_config_option *irc_config_color_message_setname;
|
||||
struct t_config_option *irc_config_color_mirc_remap;
|
||||
struct t_config_option *irc_config_color_nick_prefixes;
|
||||
struct t_config_option *irc_config_color_notice;
|
||||
@@ -3234,6 +3236,13 @@ irc_config_init ()
|
||||
N_("enable smart filter for \"part\" and \"quit\" messages"),
|
||||
NULL, 0, 0, "on", NULL, 0,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
irc_config_look_smart_filter_setname = weechat_config_new_option (
|
||||
irc_config_file, ptr_section,
|
||||
"smart_filter_setname", "boolean",
|
||||
/* TRANSLATORS: please do not translate "setname" */
|
||||
N_("enable smart filter for \"setname\" messages"),
|
||||
NULL, 0, 0, "on", NULL, 0,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
irc_config_look_temporary_servers = weechat_config_new_option (
|
||||
irc_config_file, ptr_section,
|
||||
"temporary_servers", "boolean",
|
||||
@@ -3339,7 +3348,8 @@ irc_config_init ()
|
||||
irc_config_color_message_chghost = weechat_config_new_option (
|
||||
irc_config_file, ptr_section,
|
||||
"message_chghost", "color",
|
||||
N_("color for text in chghost messages"),
|
||||
/* TRANSLATORS: please do not translate "chghost" */
|
||||
N_("color for text in \"chghost\" messages"),
|
||||
NULL, -1, 0, "brown", NULL, 0,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
irc_config_color_message_join = weechat_config_new_option (
|
||||
@@ -3360,6 +3370,13 @@ irc_config_init ()
|
||||
N_("color for text in part/quit messages"),
|
||||
NULL, -1, 0, "red", NULL, 0,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
irc_config_color_message_setname = weechat_config_new_option (
|
||||
irc_config_file, ptr_section,
|
||||
"message_setname", "color",
|
||||
/* TRANSLATORS: please do not translate "setname" */
|
||||
N_("color for text in \"setname\" messages"),
|
||||
NULL, -1, 0, "brown", NULL, 0,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
irc_config_color_mirc_remap = weechat_config_new_option (
|
||||
irc_config_file, ptr_section,
|
||||
"mirc_remap", "string",
|
||||
|
||||
@@ -150,6 +150,7 @@ extern struct t_config_option *irc_config_look_smart_filter_join_unmask;
|
||||
extern struct t_config_option *irc_config_look_smart_filter_mode;
|
||||
extern struct t_config_option *irc_config_look_smart_filter_nick;
|
||||
extern struct t_config_option *irc_config_look_smart_filter_quit;
|
||||
extern struct t_config_option *irc_config_look_smart_filter_setname;
|
||||
extern struct t_config_option *irc_config_look_temporary_servers;
|
||||
extern struct t_config_option *irc_config_look_topic_strip_colors;
|
||||
|
||||
@@ -166,6 +167,7 @@ extern struct t_config_option *irc_config_color_message_chghost;
|
||||
extern struct t_config_option *irc_config_color_message_join;
|
||||
extern struct t_config_option *irc_config_color_message_kick;
|
||||
extern struct t_config_option *irc_config_color_message_quit;
|
||||
extern struct t_config_option *irc_config_color_message_setname;
|
||||
extern struct t_config_option *irc_config_color_mirc_remap;
|
||||
extern struct t_config_option *irc_config_color_nick_prefixes;
|
||||
extern struct t_config_option *irc_config_color_notice;
|
||||
|
||||
@@ -3059,9 +3059,10 @@ IRC_PROTOCOL_CALLBACK(quit)
|
||||
|
||||
IRC_PROTOCOL_CALLBACK(setname)
|
||||
{
|
||||
int local_setname;
|
||||
int local_setname, setname_enabled, smart_filter;
|
||||
struct t_irc_channel *ptr_channel;
|
||||
struct t_irc_nick *ptr_nick;
|
||||
struct t_irc_channel_speaking *ptr_nick_speaking;
|
||||
char *str_realname, *realname_color;
|
||||
|
||||
IRC_PROTOCOL_MIN_PARAMS(1);
|
||||
@@ -3073,53 +3074,105 @@ IRC_PROTOCOL_CALLBACK(setname)
|
||||
if (!str_realname)
|
||||
return WEECHAT_RC_ERROR;
|
||||
|
||||
if (weechat_hashtable_has_key (server->cap_list, "setname"))
|
||||
realname_color = irc_color_decode (
|
||||
str_realname,
|
||||
weechat_config_boolean (irc_config_network_colors_receive));
|
||||
|
||||
setname_enabled = (weechat_hashtable_has_key (server->cap_list, "setname"));
|
||||
|
||||
for (ptr_channel = server->channels; ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
for (ptr_channel = server->channels; ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
switch (ptr_channel->type)
|
||||
{
|
||||
ptr_nick = irc_nick_search (server, ptr_channel, nick);
|
||||
if (ptr_nick)
|
||||
{
|
||||
if (ptr_nick->realname)
|
||||
free (ptr_nick->realname);
|
||||
ptr_nick->realname = strdup (str_realname);
|
||||
}
|
||||
case IRC_CHANNEL_TYPE_PRIVATE:
|
||||
if (!ignored
|
||||
&& !local_setname
|
||||
&& (irc_server_strcasecmp (server,
|
||||
ptr_channel->name, nick) == 0))
|
||||
{
|
||||
weechat_printf_date_tags (
|
||||
irc_msgbuffer_get_target_buffer (
|
||||
server, NULL, command, NULL, ptr_channel->buffer),
|
||||
date,
|
||||
irc_protocol_tags (command, tags, NULL, NULL, NULL),
|
||||
_("%s%s%s%s has changed real name to %s\"%s%s%s\"%s"),
|
||||
weechat_prefix ("network"),
|
||||
irc_nick_color_for_msg (server, 1, NULL, nick),
|
||||
nick,
|
||||
IRC_COLOR_MESSAGE_SETNAME,
|
||||
IRC_COLOR_CHAT_DELIMITERS,
|
||||
IRC_COLOR_RESET,
|
||||
(realname_color) ? realname_color : "",
|
||||
IRC_COLOR_CHAT_DELIMITERS,
|
||||
IRC_COLOR_RESET);
|
||||
}
|
||||
break;
|
||||
case IRC_CHANNEL_TYPE_CHANNEL:
|
||||
ptr_nick = irc_nick_search (server, ptr_channel, nick);
|
||||
if (ptr_nick)
|
||||
{
|
||||
if (!ignored && !local_setname)
|
||||
{
|
||||
ptr_nick_speaking = ((weechat_config_boolean (irc_config_look_smart_filter))
|
||||
&& (weechat_config_boolean (irc_config_look_smart_filter_setname))) ?
|
||||
irc_channel_nick_speaking_time_search (server, ptr_channel, nick, 1) : NULL;
|
||||
smart_filter = (!local_setname
|
||||
&& weechat_config_boolean (irc_config_look_smart_filter)
|
||||
&& weechat_config_boolean (irc_config_look_smart_filter_setname)
|
||||
&& !ptr_nick_speaking);
|
||||
|
||||
weechat_printf_date_tags (
|
||||
irc_msgbuffer_get_target_buffer (
|
||||
server, NULL, command, NULL, ptr_channel->buffer),
|
||||
date,
|
||||
irc_protocol_tags (
|
||||
command,
|
||||
tags,
|
||||
smart_filter ? "irc_smart_filter" : NULL,
|
||||
NULL,
|
||||
NULL),
|
||||
_("%s%s%s%s has changed real name to %s\"%s%s%s\"%s"),
|
||||
weechat_prefix ("network"),
|
||||
irc_nick_color_for_msg (server, 1, NULL, nick),
|
||||
nick,
|
||||
IRC_COLOR_MESSAGE_SETNAME,
|
||||
IRC_COLOR_CHAT_DELIMITERS,
|
||||
IRC_COLOR_RESET,
|
||||
(realname_color) ? realname_color : "",
|
||||
IRC_COLOR_CHAT_DELIMITERS,
|
||||
IRC_COLOR_RESET);
|
||||
}
|
||||
if (setname_enabled)
|
||||
{
|
||||
if (ptr_nick->realname)
|
||||
free (ptr_nick->realname);
|
||||
ptr_nick->realname = strdup (str_realname);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ignored)
|
||||
if (!ignored && local_setname)
|
||||
{
|
||||
realname_color = irc_color_decode (
|
||||
str_realname,
|
||||
weechat_config_boolean (irc_config_network_colors_receive));
|
||||
if (local_setname)
|
||||
{
|
||||
weechat_printf_date_tags (
|
||||
irc_msgbuffer_get_target_buffer (server, NULL, command, NULL, NULL),
|
||||
date,
|
||||
irc_protocol_tags (command, tags, NULL, NULL, NULL),
|
||||
_("%sYour real name has been set to \"%s\""),
|
||||
weechat_prefix ("network"),
|
||||
(realname_color) ? realname_color : "");
|
||||
}
|
||||
else
|
||||
{
|
||||
weechat_printf_date_tags (
|
||||
irc_msgbuffer_get_target_buffer (server, NULL, command, NULL, NULL),
|
||||
date,
|
||||
irc_protocol_tags (command, tags, NULL, NULL, NULL),
|
||||
_("%sReal name of %s%s%s has been set to \"%s\""),
|
||||
weechat_prefix ("network"),
|
||||
irc_nick_color_for_msg (server, 1, NULL, nick),
|
||||
nick,
|
||||
IRC_COLOR_RESET,
|
||||
(realname_color) ? realname_color : "");
|
||||
}
|
||||
if (realname_color)
|
||||
free (realname_color);
|
||||
weechat_printf_date_tags (
|
||||
irc_msgbuffer_get_target_buffer (server, NULL, command, NULL, NULL),
|
||||
date,
|
||||
irc_protocol_tags (command, tags, NULL, NULL, NULL),
|
||||
_("%s%sYour real name has been set to %s\"%s%s%s\"%s"),
|
||||
weechat_prefix ("network"),
|
||||
IRC_COLOR_MESSAGE_SETNAME,
|
||||
IRC_COLOR_CHAT_DELIMITERS,
|
||||
IRC_COLOR_RESET,
|
||||
(realname_color) ? realname_color : "",
|
||||
IRC_COLOR_CHAT_DELIMITERS,
|
||||
IRC_COLOR_RESET);
|
||||
}
|
||||
|
||||
if (realname_color)
|
||||
free (realname_color);
|
||||
|
||||
free (str_realname);
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
Reference in New Issue
Block a user