summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog2
-rw-r--r--src/plugins/irc/irc-command.c17
-rw-r--r--src/plugins/irc/irc-protocol.c63
-rw-r--r--src/plugins/irc/irc-server.c26
-rw-r--r--src/plugins/irc/irc-server.h2
5 files changed, 65 insertions, 45 deletions
diff --git a/ChangeLog b/ChangeLog
index 412dbdb19..f49d971db 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -69,6 +69,8 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
* aspell: fix detection of nicks with non-alphanumeric chars
* guile: disable guile gmp allocator (fix crash on unload of relay plugin)
(bug #40628)
+* irc: use statusmsg from message 005 to check prefix char in status
+ notices/messages
* irc: remove display of channel in channel notices, display "PvNotice" for
channel welcome notices
* irc: add option irc.look.smart_filter_mode (task #12499)
diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c
index 001f221e6..484d16d20 100644
--- a/src/plugins/irc/irc-command.c
+++ b/src/plugins/irc/irc-command.c
@@ -2943,11 +2943,9 @@ int
irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc,
char **argv, char **argv_eol)
{
- char **targets;
- int num_targets, i, j, arg_target, arg_text, is_channel, msg_op_voice;
+ char **targets, *msg_pwd_hidden, *string;
+ int num_targets, i, j, arg_target, arg_text, is_channel, status_msg;
int hide_password;
- char *msg_pwd_hidden;
- char *string;
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
@@ -3009,13 +3007,14 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc,
{
is_channel = 0;
ptr_channel = NULL;
- msg_op_voice = 0;
- if (((targets[i][0] == '@') || (targets[i][0] == '+'))
+ status_msg = 0;
+ if (irc_server_prefix_char_statusmsg (ptr_server,
+ targets[i][0])
&& irc_channel_is_channel (ptr_server, targets[i] + 1))
{
ptr_channel = irc_channel_search (ptr_server, targets[i] + 1);
is_channel = 1;
- msg_op_voice = 1;
+ status_msg = 1;
}
else
{
@@ -3029,7 +3028,7 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc,
{
string = irc_color_decode (argv_eol[arg_text],
weechat_config_boolean (irc_config_network_colors_send));
- if (msg_op_voice)
+ if (status_msg)
{
/*
* message to channel ops/voiced
@@ -3283,7 +3282,7 @@ irc_command_notice (void *data, struct t_gui_buffer *buffer, int argc,
IRC_COMMAND_CHECK_SERVER("notice", 1);
is_channel = 0;
- if (((argv[arg_target][0] == '@') || (argv[arg_target][0] == '+'))
+ if (irc_server_prefix_char_statusmsg (ptr_server, argv[arg_target][0])
&& irc_channel_is_channel (ptr_server, argv[arg_target] + 1))
{
ptr_channel = irc_channel_search (ptr_server, argv[arg_target] + 1);
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c
index 46fc7258a..ba0723b43 100644
--- a/src/plugins/irc/irc-protocol.c
+++ b/src/plugins/irc/irc-protocol.c
@@ -1066,10 +1066,10 @@ IRC_PROTOCOL_CALLBACK(nick)
IRC_PROTOCOL_CALLBACK(notice)
{
- char *pos_target, *pos_args, *pos, end_char, *channel;
+ char *pos_target, *pos_args, *pos, end_char, *channel, status_notice[2];
struct t_irc_channel *ptr_channel;
struct t_irc_nick *ptr_nick;
- int notify_private, is_channel, is_channel_orig, notice_op, notice_voice;
+ int notify_private, is_channel, is_channel_orig;
struct t_gui_buffer *ptr_buffer;
IRC_PROTOCOL_MIN_ARGS(3);
@@ -1077,8 +1077,8 @@ IRC_PROTOCOL_CALLBACK(notice)
if (ignored)
return WEECHAT_RC_OK;
- notice_op = 0;
- notice_voice = 0;
+ status_notice[0] = '\0';
+ status_notice[1] = '\0';
if (argv[0][0] == ':')
{
@@ -1086,21 +1086,18 @@ IRC_PROTOCOL_CALLBACK(notice)
return WEECHAT_RC_ERROR;
pos_target = argv[2];
is_channel = irc_channel_is_channel (server, pos_target + 1);
- if ((pos_target[0] == '@') && is_channel)
+ if (is_channel
+ && irc_server_prefix_char_statusmsg (server, pos_target[0]))
{
+ status_notice[0] = pos_target[0];
pos_target++;
- notice_op = 1;
- }
- else if ((pos_target[0] == '+') && is_channel)
- {
- pos_target++;
- notice_voice = 1;
}
pos_args = (argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3];
- if (notice_op && (pos_args[0] == '@') && (pos_args[1] == ' '))
- pos_args += 2;
- else if (notice_voice && (pos_args[0] == '+') && (pos_args[1] == ' '))
+ if ((status_notice[0])
+ && (pos_args[0] == status_notice[0]) && (pos_args[1] == ' '))
+ {
pos_args += 2;
+ }
}
else
{
@@ -1182,13 +1179,14 @@ IRC_PROTOCOL_CALLBACK(notice)
"notify_message" :
weechat_config_string (irc_config_look_notice_welcome_tags),
nick),
- "%s%s%s%s%s%s(%s%s%s)%s: %s",
+ "%s%s%s%s%s%s%s(%s%s%s)%s: %s",
weechat_prefix ("network"),
IRC_COLOR_NOTICE,
(is_channel_orig) ? "" : "Pv",
/* TRANSLATORS: "Notice" is command name in IRC protocol (translation is frequently the same word) */
_("Notice"),
- (notice_op) ? "Op" : ((notice_voice) ? "Voice" : ""),
+ (status_notice[0]) ? ":" : "",
+ status_notice,
IRC_COLOR_CHAT_DELIMITERS,
irc_nick_color_for_message (server, ptr_nick, nick),
(nick && nick[0]) ? nick : "?",
@@ -1577,9 +1575,9 @@ IRC_PROTOCOL_CALLBACK(pong)
IRC_PROTOCOL_CALLBACK(privmsg)
{
- char *pos_args, *pos_target, str_tags[1024], *str_color;
+ char *pos_args, *pos_target, str_tags[1024], *str_color, status_msg[2];
const char *remote_nick, *pv_tags;
- int msg_op, msg_voice, is_channel, nick_is_me;
+ int is_channel, nick_is_me;
struct t_irc_channel *ptr_channel;
struct t_irc_nick *ptr_nick;
@@ -1591,26 +1589,18 @@ IRC_PROTOCOL_CALLBACK(privmsg)
pos_args = (argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3];
- msg_op = 0;
- msg_voice = 0;
+ status_msg[0] = '\0';
+ status_msg[1] = '\0';
pos_target = argv[2];
is_channel = irc_channel_is_channel (server, pos_target);
if (!is_channel)
{
- if (irc_channel_is_channel (server, pos_target + 1))
+ if (irc_channel_is_channel (server, pos_target + 1)
+ && irc_server_prefix_char_statusmsg (server, pos_target[0]))
{
- if (pos_target[0] == '@')
- {
- is_channel = 1;
- pos_target++;
- msg_op = 1;
- }
- else if (pos_target[0] == '+')
- {
- is_channel = 1;
- pos_target++;
- msg_voice = 1;
- }
+ is_channel = 1;
+ status_msg[0] = pos_target[0];
+ pos_target++;
}
}
@@ -1641,7 +1631,7 @@ IRC_PROTOCOL_CALLBACK(privmsg)
if (ptr_nick && !ptr_nick->host)
ptr_nick->host = strdup (address);
- if (msg_op || msg_voice)
+ if (status_msg[0])
{
/* message to channel ops/voiced (to "@#channel" or "+#channel") */
weechat_printf_date_tags (ptr_channel->buffer,
@@ -1649,10 +1639,11 @@ IRC_PROTOCOL_CALLBACK(privmsg)
irc_protocol_tags (command,
"notify_message",
nick),
- "%s%s%s%s(%s%s%s)%s: %s",
+ "%s%s%s%s%s(%s%s%s)%s: %s",
weechat_prefix ("network"),
"Msg",
- (msg_op) ? "Op" : ((msg_voice) ? "Voice" : ""),
+ (status_msg[0]) ? ":" : "",
+ status_msg,
IRC_COLOR_CHAT_DELIMITERS,
irc_nick_color_for_message (server, ptr_nick, nick),
(nick && nick[0]) ? nick : "?",
diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c
index 0e2d9199f..e58e3a59c 100644
--- a/src/plugins/irc/irc-server.c
+++ b/src/plugins/irc/irc-server.c
@@ -876,6 +876,32 @@ irc_server_get_chanmodes (struct t_irc_server *server)
}
/*
+ * Checks if a prefix char is valid for a status message
+ * (message sent for example to ops/voiced).
+ *
+ * The prefix (for example '@' or '+') must be in STATUSMSG,
+ * or in "prefix_chars" if STATUSMSG is not defined.
+ *
+ * Returns:
+ * 1: prefix is valid for a status message
+ * 0: prefix is NOT valid for a status message
+ */
+
+int
+irc_server_prefix_char_statusmsg (struct t_irc_server *server,
+ char prefix_char)
+{
+ const char *support_statusmsg;
+
+ support_statusmsg = irc_server_get_isupport_value (server, "STATUSMSG");
+ if (support_statusmsg)
+ return (strchr (support_statusmsg, prefix_char)) ? 1 : 0;
+
+ return (irc_server_get_prefix_char_index (server, prefix_char) >= 0) ?
+ 1 : 0;
+}
+
+/*
* Allocates a new server and adds it to the servers queue.
*
* Returns pointer to new server, NULL if error.
diff --git a/src/plugins/irc/irc-server.h b/src/plugins/irc/irc-server.h
index 07b208f0d..e3591768c 100644
--- a/src/plugins/irc/irc-server.h
+++ b/src/plugins/irc/irc-server.h
@@ -265,6 +265,8 @@ extern char irc_server_get_prefix_mode_for_char (struct t_irc_server *server,
extern char irc_server_get_prefix_char_for_mode (struct t_irc_server *server,
char mode);
extern const char *irc_server_get_chanmodes (struct t_irc_server *server);
+extern int irc_server_prefix_char_statusmsg (struct t_irc_server *server,
+ char prefix_char);
extern struct t_irc_server *irc_server_alloc (const char *name);
extern struct t_irc_server *irc_server_alloc_with_url (const char *irc_url);
extern void irc_server_apply_command_line_options (struct t_irc_server *server,