changeset 25:3b67a9a806a7

Added /color command to change colour.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 09 Jul 2008 17:47:40 +0300
parents 78d260256450
children b84fc46c6035
files nnchat.c
diffstat 1 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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;
 	}