Add support for raw message tags to the plugin api.

This commit is contained in:
DasBrain 2021-05-24 07:36:22 +02:00
parent 65edc9ad9a
commit 0562f6d6a4
4 changed files with 8 additions and 5 deletions

View File

@ -52,6 +52,7 @@ typedef struct _hexchat_context hexchat_context;
typedef struct typedef struct
{ {
time_t server_time_utc; /* 0 if not used */ time_t server_time_utc; /* 0 if not used */
const char* tags; /* Only for server events. NULL if the server sent no tags. */
} hexchat_event_attrs; } hexchat_event_attrs;
#ifndef PLUGIN_C #ifndef PLUGIN_C

View File

@ -636,11 +636,12 @@ hexchat_event_attrs_free (hexchat_plugin *ph, hexchat_event_attrs *attrs)
int int
plugin_emit_server (session *sess, char *name, char *word[], char *word_eol[], plugin_emit_server (session *sess, char *name, char *word[], char *word_eol[],
time_t server_time) time_t server_time, const char* tags)
{ {
hexchat_event_attrs attrs; hexchat_event_attrs attrs;
attrs.server_time_utc = server_time; attrs.server_time_utc = server_time;
attrs.tags = tags;
return plugin_hook_run (sess, name, word, word_eol, &attrs, return plugin_hook_run (sess, name, word, word_eol, &attrs,
HOOK_SERVER | HOOK_SERVER_ATTRS); HOOK_SERVER | HOOK_SERVER_ATTRS);

View File

@ -172,7 +172,7 @@ void plugin_kill_all (void);
void plugin_auto_load (session *sess); void plugin_auto_load (session *sess);
int plugin_emit_command (session *sess, char *name, char *word[], char *word_eol[]); int plugin_emit_command (session *sess, char *name, char *word[], char *word_eol[]);
int plugin_emit_server (session *sess, char *name, char *word[], char *word_eol[], int plugin_emit_server (session *sess, char *name, char *word[], char *word_eol[],
time_t server_time); time_t server_time, const char* tags);
int plugin_emit_print (session *sess, char *word[], time_t server_time); int plugin_emit_print (session *sess, char *word[], time_t server_time);
int plugin_emit_dummy_print (session *sess, char *name); int plugin_emit_dummy_print (session *sess, char *name);
int plugin_emit_keypress (session *sess, unsigned int state, unsigned int keyval, gunichar key); int plugin_emit_keypress (session *sess, unsigned int state, unsigned int keyval, gunichar key);

View File

@ -1541,10 +1541,11 @@ irc_inline (server *serv, char *buf, int len)
/* Python relies on this */ /* Python relies on this */
word[PDIWORDS] = NULL; word[PDIWORDS] = NULL;
word_eol[PDIWORDS] = NULL; word_eol[PDIWORDS] = NULL;
char* tags = NULL;
if (*buf == '@') if (*buf == '@')
{ {
char *tags = buf + 1; /* skip the '@' */ *tags = buf + 1; /* skip the '@' */
char *sep = strchr (buf, ' '); char *sep = strchr (buf, ' ');
if (!sep) if (!sep)
@ -1578,7 +1579,7 @@ irc_inline (server *serv, char *buf, int len)
word_eol[1] = buf; /* keep the ":" for plugins */ word_eol[1] = buf; /* keep the ":" for plugins */
if (plugin_emit_server (sess, type, word, word_eol, if (plugin_emit_server (sess, type, word, word_eol,
tags_data.timestamp)) tags_data.timestamp, tags))
goto xit; goto xit;
word[1]++; word[1]++;
@ -1589,7 +1590,7 @@ irc_inline (server *serv, char *buf, int len)
word[0] = type = word[1]; word[0] = type = word[1];
if (plugin_emit_server (sess, type, word, word_eol, if (plugin_emit_server (sess, type, word, word_eol,
tags_data.timestamp)) tags_data.timestamp, tags))
goto xit; goto xit;
} }