Permalink
Browse files

Change addbot command to use spaces. (#496)

Use spaces in the address instead of '/' or ':'. Command is now addbot handle address [bot-port [relay-port]].
For backward compatibility, address can still be built up like host[:bot-port[/relay-port]]. If host is in IPv6 format, ports van only be specified when using '[' ']'.
The separate port arguments are ignored if the old address format is used.
  • Loading branch information...
Cizzle authored and vanosg committed Dec 17, 2017
1 parent 1af4255 commit cb3bb7a4df63fc2ef26276cbf208cf3e4cdf00a8
Showing with 43 additions and 31 deletions.
  1. +9 −6 doc/sphinx_source/mainDocs/tcl-commands.rst
  2. +34 −25 src/tcluser.c
@@ -1,5 +1,5 @@
Eggdrop Tcl Commands
Last revised: June 20, 2016
Last revised: December 14, 2017
====================
Eggdrop Tcl Commands
@@ -353,16 +353,19 @@ adduser <handle> [hostmask]
Module: core
^^^^^^^^^^^^^^^^^^^^^^^^^
addbot <handle> <address>
^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
addbot <handle> <address> [botport [userport]]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Description: adds a new bot to the userlist with the handle and botaddress given (with no password and no flags). <address> format is one of:
- ipaddress/botport/userport
- ipaddress
- ipv4address:botport/userport [DEPRECATED]
- [ipv6address]:botport/userport [DEPRECATED]
Returns: 1 if successful; 0 if the bot already exists
NOTE 1: The []s around the ipv6address argument are literal []s, not optional arguments.
NOTE 2: In the deprecated formats, an additional botport and/or userport given as follow-on arguments are ignored.
Returns: 1 if successful; 0 if the bot already exists or a port is invalid
Module: core
View
@@ -303,7 +303,7 @@ static int tcl_addbot STDVAR
int i, colon=0, braced = 0, ipv6 = 0, count = 0;
BADARGS(3, 3, " handle address");
BADARGS(3, 5, " handle address ?telnet-port ?relay-port??");
/* Copy to adjustable char*'s */
strncpyz(hand, argv[1], sizeof hand);
@@ -337,50 +337,59 @@ static int tcl_addbot STDVAR
Tcl_AppendResult(irp, "0", NULL);
return TCL_OK;
}
/* Check that the char following the / is not null */
/* Check that the char following the / is not null */
if ((q = strrchr(addr, '/'))) {
if (!q[1]) {
*q = 0;
q = 0;
q = NULL;
}
}
/* Find ports, still allowing them in address for backward compat */
if (!ipv6) {
if (!(q = strchr(addr, ':'))) {
q = strchr(addr, '/');
}
q = strchr(addr, ':');
} else if (braced && (colon > braced)) {
q = strrchr(addr, ':');
} else {
q = strchr(addr, '/');
/* IPv6 address with no braces or braces without port(s) after */
q = NULL;
}
/* Verify ports */
if (q) {
/* Split and count */
/* Split and count, ignore any following args */
*q++ = 0;
p = strchr(q, '/');
if (p)
*p++ = 0;
} else {
/* No port in address field, check next args */
p = NULL;
if (argc == 4 || argc == 5) {
q = argv[3];
}
if (argc == 5) {
p = argv[4];
}
}
/* Verify ports */
#ifndef TLS
/* Check TLS */
if ((q && *q == '+') || (p && *p == '+')) {
Tcl_AppendResult(irp, "0", NULL);
return TCL_OK;
}
/* Check TLS */
if ((q && *q == '+') || (p && *p == '+')) {
Tcl_AppendResult(irp, "0", NULL);
return TCL_OK;
}
#endif
/* Verify */
if (!check_int_range(q, 0, 65536)) {
Tcl_AppendResult(irp, "0", NULL);
return TCL_OK;
}
/* check_int_range returns 0 if p is NULL */
if (p && !check_int_range(p, 0, 65536)) {
Tcl_AppendResult(irp, "0", NULL);
return TCL_OK;
}
/* Verify */
/* check_int_range returns 0 if q or p is NULL */
if (q && !check_int_range(q, 0, 65536)) {
Tcl_AppendResult(irp, "0", NULL);
return TCL_OK;
}
if (p && !check_int_range(p, 0, 65536)) {
Tcl_AppendResult(irp, "0", NULL);
return TCL_OK;
}
userlist = adduser(userlist, hand, "none", "-", USER_BOT);

0 comments on commit cb3bb7a

Please sign in to comment.