# HG changeset patch # User Matti Hamalainen # Date 1215614860 -10800 # Node ID 3b67a9a806a74ba9a709efd41a41987f62a50b16 # Parent 78d26025645015cc727448d8d0178cb3e2aac8b6 Added /color command to change colour. diff -r 78d260256450 -r 3b67a9a806a7 nnchat.c --- a/nnchat.c Sun Jul 06 13:51:48 2008 +0300 +++ b/nnchat.c Wed Jul 09 17:47:40 2008 +0300 @@ -628,7 +628,7 @@ int handleUserInput(int sock, char *buf, size_t bufLen) { - char *tmpStr, *tmpStr2; + char *tmpStr, *tmpStr2, tmpBuf[4096]; BOOL result; /* Trim right */ @@ -641,20 +641,27 @@ /* Check command */ if (*buf == 0) { return 1; + } else if (!strncmp(buf, "/color ", 7)) { + if (sscanf(buf+7, "%6x", &optUserColor) != 1) { + printMsg("Invalid color value '%s'\n", buf+7); + return 1; + } + printMsg("Setting color to %06X", optUserColor); + sendUserMsg(sock, optUserName2, "%%2FSetFontColor%%20%%2Dcolor%%20%06X", optUserColor); + return 0; } else if (!strncmp(buf, "/msg ", 5)) { - char tmpBuf[4096]; if (setTarget) { snprintf(tmpBuf, sizeof(tmpBuf), "/prv -to %s -msg %s", setTarget, buf+5); buf = tmpBuf; } else { - fprintf(stderr, "No target set!\n"); + printMsg("No target set!\n"); return 1; } } else if (!strncmp(buf, "/to ", 4)) { buf += 4; th_free(setTarget); setTarget = th_strdup(buf); - fprintf(stderr, "Set prv target to '%s'\n", setTarget); + printMsg("Set prv target to '%s'\n", setTarget); return 0; }