summary refs log tree commit diff
path: root/input.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2018-08-13 13:49:03 -0400
committerJune McEnroe <june@causal.agency>2018-08-13 13:49:03 -0400
commit2ae5b6b9ab2a528425c1c5265b04bb01a5246e29 (patch)
tree499faf3fd2401818005aed8c3af56206b224830b /input.c
parentFactor out input param and add tagFind (diff)
downloadcatgirl-2ae5b6b9ab2a528425c1c5265b04bb01a5246e29.tar.gz
catgirl-2ae5b6b9ab2a528425c1c5265b04bb01a5246e29.zip
Add /query, /part and /close
Closing a channel before parting it is a bit weird, but if I send a PART
on /close, it would get reopened again to show the part message.
Diffstat (limited to '')
-rw-r--r--input.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/input.c b/input.c
index 9f7eddf..2d9bc46 100644
--- a/input.c
+++ b/input.c
@@ -64,6 +64,21 @@ static void inputJoin(struct Tag tag, char *params) {
 	ircFmt("JOIN %s\r\n", chan);
 }
 
+static void inputPart(struct Tag tag, char *params) {
+	if (params) {
+		ircFmt("PART %s :%s\r\n", tag.name, params);
+	} else {
+		ircFmt("PART %s :Goodbye\r\n", tag.name);
+	}
+}
+
+static void inputQuery(struct Tag tag, char *params) {
+	(void)tag;
+	char *nick = param("/query", &params, "name");
+	tabTouch(TAG_NONE, nick);
+	uiViewTag(tagFor(nick));
+}
+
 static void inputWho(struct Tag tag, char *params) {
 	(void)params;
 	ircFmt("WHO %s\r\n", tag.name);
@@ -113,15 +128,24 @@ static void inputView(struct Tag tag, char *params) {
 	}
 }
 
+static void inputClose(struct Tag tag, char *params) {
+	(void)params;
+	uiCloseTag(tag);
+	tabRemove(TAG_NONE, tag.name);
+}
+
 static const struct {
 	const char *command;
 	Handler handler;
 } COMMANDS[] = {
+	{ "/close", inputClose },
 	{ "/join", inputJoin },
 	{ "/me", inputMe },
 	{ "/names", inputWho },
 	{ "/nick", inputNick },
 	{ "/open", inputOpen },
+	{ "/part", inputPart },
+	{ "/query", inputQuery },
 	{ "/quit", inputQuit },
 	{ "/topic", inputTopic },
 	{ "/url", inputUrl },