Skip to content

Commit

Permalink
m_message: imaginary tag propagation
Browse files Browse the repository at this point in the history
  • Loading branch information
RaitoBezarius committed Jul 19, 2022
1 parent 573a074 commit b37d22f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
3 changes: 2 additions & 1 deletion include/hook.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ enum message_type {
MESSAGE_TYPE_NOTICE,
MESSAGE_TYPE_PRIVMSG,
MESSAGE_TYPE_PART,
MESSAGE_TYPE_COUNT
MESSAGE_TYPE_COUNT,
MESSAGE_TYPE_TAGMSG
};

typedef struct
Expand Down
22 changes: 20 additions & 2 deletions modules/core/m_message.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@
#include "s_newconf.h"
#include "s_stats.h"
#include "tgchange.h"
#include "client_tags.h"
#include "inline/stringops.h"

static const char message_desc[] =
"Provides the PRIVMSG and NOTICE commands to send messages to users and channels";
"Provides the PRIVMSG, NOTICE, TAGMSG commands to send messages to users and channels with a support for echo-message";

static void process_client_tags(struct MsgBuf *, struct Client *);
static void m_message(enum message_type, struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static void m_privmsg(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
static void m_notice(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
Expand Down Expand Up @@ -80,15 +82,20 @@ struct Message notice_msgtab = {
"NOTICE", 0, 0, 0, 0,
{mg_unreg, {m_notice, 0}, {m_notice, 0}, {m_notice, 0}, mg_ignore, {m_notice, 0}}
};
struct Message tagmsg_msgtab = {
"TAGMSG", 0, 0, 0, 0,
{mg_unreg, {m_tagmsg, 0}, {mtag_msg, 0}, mg_ignore, mg_ignore, {m_tagmsg, 0}}
};
struct Message echo_msgtab = {
"ECHO", 0, 0, 0, 0,
{mg_unreg, mg_ignore, {m_echo, 3}, mg_ignore, mg_ignore, mg_ignore}
};

mapi_clist_av1 message_clist[] = { &privmsg_msgtab, &notice_msgtab, &echo_msgtab, NULL };
mapi_clist_av1 message_clist[] = { &privmsg_msgtab, &notice_msgtab, &echo_msgtab, &tagmsg_msgtab, NULL };

mapi_cap_list_av2 message_cap_list[] = {
{ MAPI_CAP_SERVER, "ECHO", NULL, &CAP_ECHO },
{ MAPI_CAP_SERVER, "message-tags", NULL, &CAP_MESSAGE_TAGS },
{ 0, NULL, NULL, NULL }
};

Expand Down Expand Up @@ -163,6 +170,7 @@ static void handle_special(enum message_type msgtype,
const char *cmdname[MESSAGE_TYPE_COUNT] = {
[MESSAGE_TYPE_PRIVMSG] = "PRIVMSG",
[MESSAGE_TYPE_NOTICE] = "NOTICE",
[MESSAGE_TYPE_TAGMSG] = "TAGMSG"
};

static void
Expand Down Expand Up @@ -217,6 +225,15 @@ m_message(enum message_type msgtype, struct MsgBuf *msgbuf_p,

for(i = 0; i < ntargets; i++)
{
/* Process client tags for each target
*/
for (unsigned int tag_index = 0; tag_index < msgbuf_p->n_tags ; tag_index++) {
MsgTag tag = msgbuf_p->tags[tag_index];
if (!accept_client_tag(tag.name, tag.value, &targets[i])) {
msgbuf_strip_tag(msgbuf_p, tag_name);
}
}

switch (targets[i].type)
{
case ENTITY_CHANNEL:
Expand Down Expand Up @@ -257,6 +274,7 @@ m_echo(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
{
case 'P': msgtype = MESSAGE_TYPE_PRIVMSG; break;
case 'N': msgtype = MESSAGE_TYPE_NOTICE; break;
case 'T': msgtype = MESSAGE_TYPE_TAGMSG; break;
default: return;
}

Expand Down

0 comments on commit b37d22f

Please sign in to comment.