Skip to content

Commit

Permalink
Modify CAP Tcl interface
Browse files Browse the repository at this point in the history
  • Loading branch information
vanosg committed Jul 17, 2019
1 parent 4494efe commit b186222
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
4 changes: 2 additions & 2 deletions doc/sphinx_source/mainDocs/tcl-commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@ clearqueue <queue>
Module: server

^^^^^^^^^^^^^^^^^^^^^^^
cap <sub-command> [arg]
cap <active/available/raw> [arg]
^^^^^^^^^^^^^^^^^^^^^^^

Description: sends a raw CAP command to the server. Sub-commands can be the valid CAP client sub-ccommands of LS, LIST, REQ, or END; or the eggdrop internal commands of -list or -active. -list will show the capabilities supported on the current server, -active will show any capabilities already negotiated by Eggdrop with the server. If sending a REQ, use arg to pass the requested capability to the server.
Description: displays CAP status or sends a raw CAP command to the server. "available" will list the capabilities supported by the server, "active" will list the capabilities Eggdrop has negotiated with the server, and raw will send a raw CAP command to the server. If sending a raw command, it must be submitted in arg as a single string. For example, to request capabilities foo and bar, you would use [cap raw "REQ :foo bar"].

Returns: nothing

Expand Down
26 changes: 14 additions & 12 deletions src/mod/server.mod/tclserv.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,21 +167,23 @@ static int tcl_cap STDVAR {
char s[CAPMAX];
BADARGS(2, 3, " sub-cmd ?arg?");

simple_sprintf(s, "CAP requires a sub-command");
if (!strcasecmp(argv[1], "-list")) {
if (!strcasecmp(argv[1], "available")) {
Tcl_AppendResult(irp, cap.supported, NULL);
return TCL_OK;
} else if (!strcasecmp(argv[1], "-active")) {
} else if (!strcasecmp(argv[1], "active")) {
Tcl_AppendResult(irp, cap.negotiated, NULL);
return TCL_OK;
}
if (argc == 2) {
simple_sprintf(s, "CAP %s", argv[1]);
}
else if (argc == 3) {
simple_sprintf(s, "CAP %s :%s", argv[1], argv[2]);
} else if (!strcasecmp(argv[1], "raw")) {
if (argc == 3) {
simple_sprintf(s, "CAP %s", argv[2]);
dprintf(DP_SERVER, "%s\n", s);
} else {
Tcl_AppendResult(irp, "Raw requires a CAP sub-command to be provided",
NULL);
return TCL_ERROR;
}
} else {
Tcl_AppendResult(irp, "Invalid cap command", NULL);
}
dprintf(DP_SERVER, "%s\n", s);
// simple_sprintf(s, "CAP %s :%s", argv[1], argv[2]);
return TCL_OK;
}

Expand Down

0 comments on commit b186222

Please sign in to comment.