Skip to content

Commit

Permalink
Add tagmsg Tcl command
Browse files Browse the repository at this point in the history
  • Loading branch information
vanosg committed Oct 28, 2019
1 parent 1abe768 commit abdc2aa
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 1 deletion.
10 changes: 10 additions & 0 deletions doc/sphinx_source/mainDocs/tcl-commands.rst
Expand Up @@ -164,6 +164,16 @@ cap <active/available/raw> [arg]

Module: server

^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tagmsg <tag string> <target>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Description: sends an IRCv3 TAGMSG command to the target. Only works if message-tags as been negotiated with the server via the cap command. tag string is a single string containing the tags you wish to send separated by commas (do not include the @prefix), and target is the nickname or channel you wish to send the tags to.

Returns: nothing

Module: server

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
addserver <ip/host> [port [password]]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
1 change: 1 addition & 0 deletions src/mod/server.mod/server.h
Expand Up @@ -25,6 +25,7 @@

#define CAPMAX 499 /* (512 - "CAP REQ :XXX\r\n") */
#define TAGMAX 8191 /* Max size for IRCv3 message-tags */
#define MSGMAX 512 /* Max size of IRC message line */

#define check_tcl_ctcp(a,b,c,d,e,f) check_tcl_ctcpr(a,b,c,d,e,f,H_ctcp)
#define check_tcl_ctcr(a,b,c,d,e,f) check_tcl_ctcpr(a,b,c,d,e,f,H_ctcr)
Expand Down
2 changes: 1 addition & 1 deletion src/mod/server.mod/servmsg.c
Expand Up @@ -1120,7 +1120,7 @@ static void server_activity(int idx, char *msg, int len)
!match_ignore(from))) {
rawlen = egg_snprintf(s, sizeof s, "[@] ");
if (tag) {
rawlen += egg_snprintf(s + rawlen, sizeof s - rawlen, "%s", tag);
rawlen += egg_snprintf(s + rawlen, sizeof s - rawlen, "%s ", tag);
}
if (strcmp(from, "")) {
rawlen += egg_snprintf(s + rawlen, sizeof s - rawlen, "%s ", from);
Expand Down
29 changes: 29 additions & 0 deletions src/mod/server.mod/tclserv.c
Expand Up @@ -162,6 +162,34 @@ static int tcl_puthelp STDVAR
return TCL_OK;
}

/* Send a msg to the server prefixed with an IRCv3 message-tag */
static int tcl_tagmsg STDVAR {
char tag[TAGMAX];
char target[MSGMAX];
char *p;
BADARGS(3, 3, " tag target");

if (!msgtag) {
Tcl_AppendResult(irp, "message-tags not enabled, cannot send tag", NULL);
return TCL_ERROR;
}
strlcpy(tag, argv[1], sizeof tag);
strlcpy(target, argv[2], sizeof target);
if (*tag == '@') {
Tcl_AppendResult(irp, "tag cannot be prefixed with @", NULL);
return TCL_ERROR;
}
p = strchr(target, '\n');
if (p != NULL)
*p = 0;
p = strchr(target, '\r');
if (p != NULL)
*p = 0;
dprintf(DP_SERVER, "@%s TAGMSG %s\n", tag, target);
return TCL_OK;
}


/* Tcl interface to send CAP messages to server */
static int tcl_cap STDVAR {
char s[CAPMAX];
Expand Down Expand Up @@ -396,6 +424,7 @@ static tcl_cmds my_tcl_cmds[] = {
{"putserv", tcl_putserv},
{"putquick", tcl_putquick},
{"putnow", tcl_putnow},
{"tagmsg", tcl_tagmsg},
{"addserver", tcl_addserver},
{"delserver", tcl_delserver},
{NULL, NULL}
Expand Down

0 comments on commit abdc2aa

Please sign in to comment.