summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-07-02 18:40:06 -0400
committerJune McEnroe <june@causal.agency>2019-07-02 18:40:06 -0400
commit906440968e658629a3722ebc8d8405cbbb7b4d1d (patch)
tree7555c879b99b4756d42bce475c53e1ed233f805c
parentAdd optional key to /join (diff)
downloadcatgirl-906440968e658629a3722ebc8d8405cbbb7b4d1d.tar.gz
catgirl-906440968e658629a3722ebc8d8405cbbb7b4d1d.zip
Add -k option for joining with keys
Diffstat (limited to '')
-rw-r--r--catgirl.17
-rw-r--r--chat.c3
-rw-r--r--chat.h1
-rw-r--r--handle.c6
4 files changed, 15 insertions, 2 deletions
diff --git a/catgirl.1 b/catgirl.1
index 4d8176f..93ed604 100644
--- a/catgirl.1
+++ b/catgirl.1
@@ -13,6 +13,7 @@
 .Op Fl a Ar auth
 .Op Fl h Ar host
 .Op Fl j Ar chan
+.Op Fl k Ar keys
 .Op Fl l Ar path
 .Op Fl n Ar nick
 .Op Fl p Ar port
@@ -58,6 +59,12 @@ after connecting.
 .Ar chan
 may be a comma-separated list.
 .
+.It Fl k Ar keys
+Set keys for channels in
+.Fl j .
+.Ar keys
+may be a comma-separated list.
+.
 .It Fl l Ar path
 Log messages to
 subdirectories of
diff --git a/chat.c b/chat.c
index 2ec20bd..a9677cf 100644
--- a/chat.c
+++ b/chat.c
@@ -53,13 +53,14 @@ int main(int argc, char *argv[]) {
 	setlocale(LC_CTYPE, "");
 
 	int opt;
-	while (0 < (opt = getopt(argc, argv, "NW:a:h:j:l:n:p:r:u:vw:"))) {
+	while (0 < (opt = getopt(argc, argv, "NW:a:h:j:k:l:n:p:r:u:vw:"))) {
 		switch (opt) {
 			break; case 'N': self.notify = true;
 			break; case 'W': self.webp = dupe(optarg);
 			break; case 'a': self.auth = dupe(optarg);
 			break; case 'h': self.host = dupe(optarg);
 			break; case 'j': self.join = dupe(optarg);
+			break; case 'k': self.keys = dupe(optarg);
 			break; case 'l': logOpen(optarg);
 			break; case 'n': self.nick = dupe(optarg);
 			break; case 'p': self.port = dupe(optarg);
diff --git a/chat.h b/chat.h
index a3ce3f9..71a96ff 100644
--- a/chat.h
+++ b/chat.h
@@ -43,6 +43,7 @@ struct {
 	char *user;
 	char *real;
 	char *join;
+	char *keys;
 	bool raw;
 	bool notify;
 	bool quit;
diff --git a/handle.c b/handle.c
index a46c149..4f9015c 100644
--- a/handle.c
+++ b/handle.c
@@ -138,7 +138,11 @@ static void handleReplyWelcome(char *prefix, char *params) {
 		self.nick = strdup(nick);
 		if (!self.nick) err(EX_OSERR, "strdup");
 	}
-	if (self.join) ircFmt("JOIN %s\r\n", self.join);
+	if (self.join && self.keys) {
+		ircFmt("JOIN %s %s\r\n", self.join, self.keys);
+	} else if (self.join) {
+		ircFmt("JOIN %s\r\n", self.join);
+	}
 	tabTouch(TagStatus, self.nick);
 
 	uiLog(TagStatus, UICold, L"You have arrived");