Skip to content
Permalink
Browse files

Add tagmsg Tcl command

  • Loading branch information
vanosg committed Oct 28, 2019
1 parent 97f7960 commit efa731315d2c72c85c44069831bb38bca061d799
@@ -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]]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -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)
@@ -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);
@@ -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];
@@ -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}

0 comments on commit efa7313

Please sign in to comment.
You can’t perform that action at this time.