mirror of
https://github.com/weechat/weechat.git
synced 2026-06-30 06:46:38 +02:00
irc: update message with number of nicks when joining a channel
Changed: - "N voices" to "N voiced" - "N normals" to "N regular"
This commit is contained in:
+15
-11
@@ -834,37 +834,41 @@ irc_nick_search (struct t_irc_server *server, struct t_irc_channel *channel,
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns number of nicks (total, op, halfop, voice, normal) on a channel.
|
||||
* Returns number of nicks (total, ops, halfops, voiced, regular) on a channel.
|
||||
*/
|
||||
|
||||
void
|
||||
irc_nick_count (struct t_irc_server *server, struct t_irc_channel *channel,
|
||||
int *total, int *count_op, int *count_halfop, int *count_voice,
|
||||
int *count_normal)
|
||||
int *total, int *count_ops, int *count_halfops,
|
||||
int *count_voiced, int *count_regular)
|
||||
{
|
||||
struct t_irc_nick *ptr_nick;
|
||||
|
||||
(*total) = 0;
|
||||
(*count_op) = 0;
|
||||
(*count_halfop) = 0;
|
||||
(*count_voice) = 0;
|
||||
(*count_normal) = 0;
|
||||
(*count_ops) = 0;
|
||||
(*count_halfops) = 0;
|
||||
(*count_voiced) = 0;
|
||||
(*count_regular) = 0;
|
||||
for (ptr_nick = channel->nicks; ptr_nick;
|
||||
ptr_nick = ptr_nick->next_nick)
|
||||
{
|
||||
(*total)++;
|
||||
if (irc_nick_is_op (server, ptr_nick))
|
||||
(*count_op)++;
|
||||
{
|
||||
(*count_ops)++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (irc_nick_has_prefix_mode (server, ptr_nick, 'h'))
|
||||
(*count_halfop)++;
|
||||
{
|
||||
(*count_halfops)++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (irc_nick_has_prefix_mode (server, ptr_nick, 'v'))
|
||||
(*count_voice)++;
|
||||
(*count_voiced)++;
|
||||
else
|
||||
(*count_normal)++;
|
||||
(*count_regular)++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,8 +87,8 @@ extern struct t_irc_nick *irc_nick_search (struct t_irc_server *server,
|
||||
const char *nickname);
|
||||
extern void irc_nick_count (struct t_irc_server *server,
|
||||
struct t_irc_channel *channel, int *total,
|
||||
int *count_op, int *count_halfop, int *count_voice,
|
||||
int *count_normal);
|
||||
int *count_ops, int *count_halfops,
|
||||
int *count_voiced, int *count_regular);
|
||||
extern void irc_nick_set_away (struct t_irc_server *server,
|
||||
struct t_irc_channel *channel,
|
||||
struct t_irc_nick *nick, int is_away);
|
||||
|
||||
@@ -6086,7 +6086,7 @@ IRC_PROTOCOL_CALLBACK(366)
|
||||
struct t_irc_channel *ptr_channel;
|
||||
struct t_infolist *infolist;
|
||||
struct t_config_option *ptr_option;
|
||||
int num_nicks, num_op, num_halfop, num_voice, num_normal;
|
||||
int num_nicks, num_ops, num_halfops, num_voiced, num_regular;
|
||||
char *str_params, str_count[1024], **str_nicks, *color;
|
||||
const char *prefix, *prefix_color, *nickname;
|
||||
|
||||
@@ -6190,12 +6190,15 @@ IRC_PROTOCOL_CALLBACK(366)
|
||||
}
|
||||
}
|
||||
|
||||
/* display number of nicks, ops, halfops & voices on the channel */
|
||||
/*
|
||||
* display the number of total nicks, ops, halfops, voiced and
|
||||
* regular on the channel
|
||||
*/
|
||||
if (weechat_hashtable_has_key (ptr_channel->join_msg_received, "366")
|
||||
|| weechat_hashtable_has_key (irc_config_hashtable_display_join_message, "366"))
|
||||
{
|
||||
irc_nick_count (server, ptr_channel, &num_nicks, &num_op, &num_halfop,
|
||||
&num_voice, &num_normal);
|
||||
irc_nick_count (server, ptr_channel, &num_nicks, &num_ops,
|
||||
&num_halfops, &num_voiced, &num_regular);
|
||||
str_nicks = weechat_string_dyn_alloc (1024);
|
||||
if (irc_server_get_prefix_mode_index (server, 'o') >= 0)
|
||||
{
|
||||
@@ -6203,9 +6206,9 @@ IRC_PROTOCOL_CALLBACK(366)
|
||||
"%s%s%d%s %s",
|
||||
(*str_nicks[0]) ? ", " : "",
|
||||
IRC_COLOR_CHAT_CHANNEL,
|
||||
num_op,
|
||||
num_ops,
|
||||
IRC_COLOR_RESET,
|
||||
NG_("op", "ops", num_op));
|
||||
NG_("op", "ops", num_ops));
|
||||
weechat_string_dyn_concat (str_nicks, str_count, -1);
|
||||
}
|
||||
if (irc_server_get_prefix_mode_index (server, 'h') >= 0)
|
||||
@@ -6214,9 +6217,9 @@ IRC_PROTOCOL_CALLBACK(366)
|
||||
"%s%s%d%s %s",
|
||||
(*str_nicks[0]) ? ", " : "",
|
||||
IRC_COLOR_CHAT_CHANNEL,
|
||||
num_halfop,
|
||||
num_halfops,
|
||||
IRC_COLOR_RESET,
|
||||
NG_("halfop", "halfops", num_halfop));
|
||||
NG_("halfop", "halfops", num_halfops));
|
||||
weechat_string_dyn_concat (str_nicks, str_count, -1);
|
||||
}
|
||||
if (irc_server_get_prefix_mode_index (server, 'v') >= 0)
|
||||
@@ -6225,18 +6228,18 @@ IRC_PROTOCOL_CALLBACK(366)
|
||||
"%s%s%d%s %s",
|
||||
(*str_nicks[0]) ? ", " : "",
|
||||
IRC_COLOR_CHAT_CHANNEL,
|
||||
num_voice,
|
||||
num_voiced,
|
||||
IRC_COLOR_RESET,
|
||||
NG_("voice", "voices", num_voice));
|
||||
NG_("voiced", "voiced", num_voiced));
|
||||
weechat_string_dyn_concat (str_nicks, str_count, -1);
|
||||
}
|
||||
snprintf (
|
||||
str_count, sizeof (str_count),
|
||||
/* TRANSLATORS: number of "normal" nicks on a channel (ie no op/voice), for example: "56 normals" */
|
||||
NG_("%s%s%d%s normal", "%s%s%d%s normals", num_normal),
|
||||
/* TRANSLATORS: number of "regular" nicks on a channel (ie not op/halfop/voiced), for example: "56 regular" */
|
||||
NG_("%s%s%d%s regular", "%s%s%d%s regular", num_regular),
|
||||
(*str_nicks[0]) ? ", " : "",
|
||||
IRC_COLOR_CHAT_CHANNEL,
|
||||
num_normal,
|
||||
num_regular,
|
||||
IRC_COLOR_RESET);
|
||||
weechat_string_dyn_concat (str_nicks, str_count, -1);
|
||||
weechat_printf_date_tags (
|
||||
|
||||
Reference in New Issue
Block a user