summary refs log tree commit diff
path: root/client.c
diff options
context:
space:
mode:
Diffstat (limited to 'client.c')
-rw-r--r--client.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/client.c b/client.c
index 6ac0869..9bbc5d9 100644
--- a/client.c
+++ b/client.c
@@ -41,7 +41,7 @@ struct Client {
 	struct tls *tls;
 	enum Need need;
 	size_t consumer;
-	bool serverTime;
+	enum Cap caps;
 	char buf[1024];
 	size_t len;
 	bool error;
@@ -158,13 +158,17 @@ static void handleCap(struct Client *client, struct Message *msg) {
 
 	} else if (!strcmp(msg->params[0], "LS")) {
 		if (client->need) client->need |= NeedCapEnd;
-		clientFormat(client, ":%s CAP * LS :server-time\r\n", ORIGIN);
+		clientFormat(
+			client, ":%s CAP * LS :%s\r\n",
+			ORIGIN, capList(CapServerTime)
+		);
 
 	} else if (!strcmp(msg->params[0], "REQ") && msg->params[1]) {
 		if (client->need) client->need |= NeedCapEnd;
-		if (!strcmp(msg->params[1], "server-time")) {
-			client->serverTime = true;
-			clientFormat(client, ":%s CAP * ACK :server-time\r\n", ORIGIN);
+		enum Cap caps = capParse(msg->params[1]);
+		if (caps == CapServerTime) {
+			client->caps |= caps;
+			clientFormat(client, ":%s CAP * ACK :%s\r\n", ORIGIN, msg->params[1]);
 		} else {
 			clientFormat(client, ":%s CAP * NAK :%s\r\n", ORIGIN, msg->params[1]);
 		}
@@ -172,7 +176,7 @@ static void handleCap(struct Client *client, struct Message *msg) {
 	} else if (!strcmp(msg->params[0], "LIST")) {
 		clientFormat(
 			client, ":%s CAP * LIST :%s\r\n",
-			ORIGIN, (client->serverTime ? "server-time" : "")
+			ORIGIN, capList(client->caps)
 		);
 
 	} else {
@@ -277,7 +281,7 @@ void clientConsume(struct Client *client) {
 	time_t time;
 	const char *line = ringPeek(&time, client->consumer);
 	if (!line) return;
-	if (client->serverTime) {
+	if (client->caps & CapServerTime) {
 		char ts[sizeof("YYYY-MM-DDThh:mm:ss.sssZ")];
 		struct tm *tm = gmtime(&time);
 		strftime(ts, sizeof(ts), "%FT%T.000Z", tm);
l/commit/ui.c?h=twitch&id=872608e5c4fb814604a359a4b8b2f3bcf317cf0f&follow=1'>Factor out IRC formatting parsingJune McEnroe 2018-09-11Add /help equivalent to /manJune McEnroe 2018-09-11Don't render every PM as a pingJune McEnroe 2018-09-11Add urlOpenMatchJune McEnroe 2018-09-10Depend on man.sh for chroot.tar targetJune McEnroe 2018-09-10Set LESSSECURE=1 in man.shJune McEnroe 2018-09-10Add /man commandJune McEnroe 2018-09-10Install man page in chrootJune McEnroe 2018-09-10Install man pageJune McEnroe 2018-09-10Split keys into subsections and document colorsJune McEnroe 2018-09-10Add "blank" lines to chatte.1June McEnroe 2018-09-10Document key bindings in chatte.1June McEnroe 2018-09-08Document slash commands in chatte.1June McEnroe