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

irc: add "user" in output of irc_message_parse (closes #136)

This commit is contained in:
Sébastien Helleu
2019-09-27 20:52:00 +02:00
parent 3f33b327b1
commit ae38b11407
36 changed files with 259 additions and 185 deletions
+1
View File
@@ -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, "
+15 -3
View File
@@ -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)
+3 -2
View File
@@ -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,
+5 -4
View File
@@ -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)
+6 -5
View File
@@ -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);