summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/irc/irc-info.c1
-rw-r--r--src/plugins/irc/irc-message.c18
-rw-r--r--src/plugins/irc/irc-message.h5
-rw-r--r--src/plugins/irc/irc-notify.c9
-rw-r--r--src/plugins/irc/irc-server.c11
5 files changed, 30 insertions, 14 deletions
diff --git a/src/plugins/irc/irc-info.c b/src/plugins/irc/irc-info.c
index 51eed3b61..3136618fb 100644
--- a/src/plugins/irc/irc-info.c
+++ b/src/plugins/irc/irc-info.c
@@ -1118,6 +1118,7 @@ irc_info_init ()
N_("\"tags\": tags, "
"\"message_without_tags\": message without the tags, "
"\"nick\": nick, "
+ "\"user\": user, "
"\"host\": host, "
"\"command\": command, "
"\"channel\": channel, "
diff --git a/src/plugins/irc/irc-message.c b/src/plugins/irc/irc-message.c
index 4350128e2..db3ca51a6 100644
--- a/src/plugins/irc/irc-message.c
+++ b/src/plugins/irc/irc-message.c
@@ -53,6 +53,7 @@
* tags: "time=2015-06-27T16:40:35.000Z"
* msg_without_tags: ":nick!user@host PRIVMSG #weechat :hello!"
* nick: "nick"
+ * user: "user"
* host: "nick!user@host"
* command: "PRIVMSG"
* channel: "#weechat"
@@ -67,7 +68,7 @@
void
irc_message_parse (struct t_irc_server *server, const char *message,
char **tags, char **message_without_tags, char **nick,
- char **host, char **command, char **channel,
+ char **user, char **host, char **command, char **channel,
char **arguments, char **text,
int *pos_command, int *pos_arguments, int *pos_channel,
int *pos_text)
@@ -80,6 +81,8 @@ irc_message_parse (struct t_irc_server *server, const char *message,
*message_without_tags = NULL;
if (nick)
*nick = NULL;
+ if (user)
+ *user = NULL;
if (host)
*host = NULL;
if (command)
@@ -146,6 +149,11 @@ irc_message_parse (struct t_irc_server *server, const char *message,
/* if the prefix doesn't contain a '!', split the nick at '@' */
if (!pos2 || (pos && pos2 > pos))
pos2 = pos3;
+ if (pos2 && pos3 && (pos3 > pos2))
+ {
+ if (user)
+ *user = weechat_strndup (pos2 + 1, pos3 - pos2 - 1);
+ }
if (pos2 && (!pos || pos > pos2))
{
if (nick)
@@ -336,14 +344,14 @@ struct t_hashtable *
irc_message_parse_to_hashtable (struct t_irc_server *server,
const char *message)
{
- char *tags, *message_without_tags, *nick, *host, *command, *channel;
+ char *tags, *message_without_tags, *nick, *user, *host, *command, *channel;
char *arguments, *text, str_pos[32];
char empty_str[1] = { '\0' };
int pos_command, pos_arguments, pos_channel, pos_text;
struct t_hashtable *hashtable;
irc_message_parse (server, message, &tags, &message_without_tags, &nick,
- &host, &command, &channel, &arguments, &text,
+ &user, &host, &command, &channel, &arguments, &text,
&pos_command, &pos_arguments, &pos_channel, &pos_text);
hashtable = weechat_hashtable_new (32,
@@ -359,6 +367,8 @@ irc_message_parse_to_hashtable (struct t_irc_server *server,
(message_without_tags) ? message_without_tags : empty_str);
weechat_hashtable_set (hashtable, "nick",
(nick) ? nick : empty_str);
+ weechat_hashtable_set (hashtable, "user",
+ (user) ? user : empty_str);
weechat_hashtable_set (hashtable, "host",
(host) ? host : empty_str);
weechat_hashtable_set (hashtable, "command",
@@ -384,6 +394,8 @@ irc_message_parse_to_hashtable (struct t_irc_server *server,
free (message_without_tags);
if (nick)
free (nick);
+ if (user)
+ free (user);
if (host)
free (host);
if (command)
diff --git a/src/plugins/irc/irc-message.h b/src/plugins/irc/irc-message.h
index f1902c2c3..1cac89d0d 100644
--- a/src/plugins/irc/irc-message.h
+++ b/src/plugins/irc/irc-message.h
@@ -25,8 +25,9 @@ struct t_irc_channel;
extern void irc_message_parse (struct t_irc_server *server, const char *message,
char **tags, char **message_without_tags,
- char **nick, char **host, char **command,
- char **channel, char **arguments, char **text,
+ char **nick, char **user, char **host,
+ char **command, char **channel,
+ char **arguments, char **text,
int *pos_command, int *pos_arguments,
int *pos_channel, int *pos_text);
extern struct t_hashtable *irc_message_parse_to_hashtable (struct t_irc_server *server,
diff --git a/src/plugins/irc/irc-notify.c b/src/plugins/irc/irc-notify.c
index 3c913063d..80c170562 100644
--- a/src/plugins/irc/irc-notify.c
+++ b/src/plugins/irc/irc-notify.c
@@ -869,8 +869,8 @@ irc_notify_hsignal_cb (const void *pointer, void *data, const char *signal,
for (i = 0; i < num_messages; i++)
{
irc_message_parse (ptr_server, messages[i], NULL, NULL, NULL,
- NULL, NULL, NULL, &arguments, NULL, NULL,
- NULL, NULL, NULL);
+ NULL, NULL, NULL, NULL, &arguments, NULL,
+ NULL, NULL, NULL, NULL);
if (arguments)
{
pos = strchr (arguments, ' ');
@@ -967,8 +967,9 @@ irc_notify_hsignal_cb (const void *pointer, void *data, const char *signal,
for (i = 0; i < num_messages; i++)
{
irc_message_parse (ptr_server, messages[i], NULL, NULL,
- NULL, NULL, &irc_cmd, NULL, &arguments,
- NULL, NULL, NULL, NULL, NULL);
+ NULL, NULL, NULL, &irc_cmd, NULL,
+ &arguments, NULL, NULL, NULL, NULL,
+ NULL);
if (irc_cmd && arguments)
{
if (strcmp (irc_cmd, "401") == 0)
diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c
index 57acf0436..d4171fd39 100644
--- a/src/plugins/irc/irc-server.c
+++ b/src/plugins/irc/irc-server.c
@@ -2499,7 +2499,8 @@ irc_server_send_one_msg (struct t_irc_server *server, int flags,
msg_encoded = NULL;
irc_message_parse (server, ptr_msg, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, &pos_channel, &pos_text);
+ NULL, NULL, NULL, NULL, NULL, &pos_channel,
+ &pos_text);
switch (IRC_SERVER_OPTION_INTEGER(server,
IRC_SERVER_OPTION_CHARSET_MESSAGE))
{
@@ -2710,8 +2711,8 @@ irc_server_sendf (struct t_irc_server *server, int flags, const char *tags,
{
/* run modifier "irc_out1_xxx" (like "irc_out_xxx", but before split) */
irc_message_parse (server, items[i], NULL, NULL,
- &nick, NULL, &command, &channel, NULL, NULL, NULL,
- NULL, NULL, NULL);
+ &nick, NULL, NULL, &command, &channel, NULL, NULL,
+ NULL, NULL, NULL, NULL);
snprintf (str_modifier, sizeof (str_modifier),
"irc_out1_%s",
(command) ? command : "unknown");
@@ -2972,7 +2973,7 @@ irc_server_msgq_flush ()
ptr_data);
irc_message_parse (irc_recv_msgq->server,
- ptr_data, NULL, NULL, NULL, NULL,
+ ptr_data, NULL, NULL, NULL, NULL, NULL,
&command, NULL, NULL, NULL, NULL, NULL,
NULL, NULL);
snprintf (str_modifier, sizeof (str_modifier),
@@ -3013,7 +3014,7 @@ irc_server_msgq_flush ()
}
irc_message_parse (irc_recv_msgq->server, ptr_msg,
- NULL, NULL, &nick, &host,
+ NULL, NULL, &nick, NULL, &host,
&command, &channel, &arguments,
NULL, NULL, NULL,
&pos_channel, &pos_text);