Add -k option for joining with keys

master
Curtis McEnroe 2019-07-02 18:40:06 -04:00
parent 426be32b1d
commit 906440968e
No known key found for this signature in database
GPG Key ID: CEA2F97ADCFCD77C
4 changed files with 15 additions and 2 deletions

View File

@ -13,6 +13,7 @@
.Op Fl a Ar auth .Op Fl a Ar auth
.Op Fl h Ar host .Op Fl h Ar host
.Op Fl j Ar chan .Op Fl j Ar chan
.Op Fl k Ar keys
.Op Fl l Ar path .Op Fl l Ar path
.Op Fl n Ar nick .Op Fl n Ar nick
.Op Fl p Ar port .Op Fl p Ar port
@ -58,6 +59,12 @@ after connecting.
.Ar chan .Ar chan
may be a comma-separated list. 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 .It Fl l Ar path
Log messages to Log messages to
subdirectories of subdirectories of

3
chat.c
View File

@ -53,13 +53,14 @@ int main(int argc, char *argv[]) {
setlocale(LC_CTYPE, ""); setlocale(LC_CTYPE, "");
int opt; 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) { switch (opt) {
break; case 'N': self.notify = true; break; case 'N': self.notify = true;
break; case 'W': self.webp = dupe(optarg); break; case 'W': self.webp = dupe(optarg);
break; case 'a': self.auth = dupe(optarg); break; case 'a': self.auth = dupe(optarg);
break; case 'h': self.host = dupe(optarg); break; case 'h': self.host = dupe(optarg);
break; case 'j': self.join = dupe(optarg); break; case 'j': self.join = dupe(optarg);
break; case 'k': self.keys = dupe(optarg);
break; case 'l': logOpen(optarg); break; case 'l': logOpen(optarg);
break; case 'n': self.nick = dupe(optarg); break; case 'n': self.nick = dupe(optarg);
break; case 'p': self.port = dupe(optarg); break; case 'p': self.port = dupe(optarg);

1
chat.h
View File

@ -43,6 +43,7 @@ struct {
char *user; char *user;
char *real; char *real;
char *join; char *join;
char *keys;
bool raw; bool raw;
bool notify; bool notify;
bool quit; bool quit;

View File

@ -138,7 +138,11 @@ static void handleReplyWelcome(char *prefix, char *params) {
self.nick = strdup(nick); self.nick = strdup(nick);
if (!self.nick) err(EX_OSERR, "strdup"); 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); tabTouch(TagStatus, self.nick);
uiLog(TagStatus, UICold, L"You have arrived"); uiLog(TagStatus, UICold, L"You have arrived");