mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Parsing optional args for cmd_join
This commit is contained in:
parent
ced6e7f411
commit
28425060bc
@ -235,9 +235,9 @@ static struct cmd_t command_defs[] =
|
||||
NULL } } },
|
||||
|
||||
{ "/join",
|
||||
cmd_join, parse_args_with_freetext, 1, 3, NULL,
|
||||
{ "/join room[@server] [nick] [password]", "Join a chat room.",
|
||||
{ "/join room[@server] [nick] [password]",
|
||||
cmd_join, parse_args, 1, 5, NULL,
|
||||
{ "/join room[@server] [nick value] [passwd value]", "Join a chat room.",
|
||||
{ "/join room[@server] [nick value] [passwd value]",
|
||||
"--------------------------",
|
||||
"Join a chat room at the conference server.",
|
||||
"If nick is specified you will join with this nickname.",
|
||||
@ -246,8 +246,8 @@ static struct cmd_t command_defs[] =
|
||||
"If the room doesn't exist, and the server allows it, a new one will be created.",
|
||||
"",
|
||||
"Example : /join jdev@conference.jabber.org",
|
||||
"Example : /join jdev@conference.jabber.org mynick",
|
||||
"Example : /join private@conference.jabber.org mynick mypassword",
|
||||
"Example : /join jdev@conference.jabber.org nick mynick",
|
||||
"Example : /join private@conference.jabber.org nick mynick passwd mypassword",
|
||||
"Example : /join jdev (as user@jabber.org will join jdev@conference.jabber.org)",
|
||||
NULL } } },
|
||||
|
||||
|
@ -1610,20 +1610,45 @@ cmd_join(gchar **args, struct cmd_help_t help)
|
||||
room = room_str->str;
|
||||
}
|
||||
|
||||
// nick supplied
|
||||
// Additional args supplied
|
||||
if (num_args > 1) {
|
||||
char *opt1 = args[1];
|
||||
char *opt1val = args[2];
|
||||
char *opt2 = args[3];
|
||||
char *opt2val = args[4];
|
||||
if (opt1 != NULL) {
|
||||
if (opt1val == NULL) {
|
||||
cons_show("Usage: %s", help.usage);
|
||||
cons_show("");
|
||||
return TRUE;
|
||||
}
|
||||
if (strcmp(opt1, "nick") == 0) {
|
||||
nick = strdup(opt1val);
|
||||
} else if (strcmp(opt1, "passwd") == 0) {
|
||||
passwd = strdup(opt1val);
|
||||
} else {
|
||||
cons_show("Usage: %s", help.usage);
|
||||
cons_show("");
|
||||
return TRUE;
|
||||
}
|
||||
if (opt2 != NULL) {
|
||||
if (strcmp(opt2, "nick") == 0) {
|
||||
nick = strdup(opt2val);
|
||||
} else if (strcmp(opt2, "passwd") == 0) {
|
||||
passwd = strdup(opt2val);
|
||||
} else {
|
||||
cons_show("Usage: %s", help.usage);
|
||||
cons_show("");
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
nick = args[1];
|
||||
|
||||
// otherwise use account preference
|
||||
} else {
|
||||
nick = account->muc_nick;
|
||||
}
|
||||
|
||||
// pass supplied
|
||||
if (num_args == 3) {
|
||||
passwd = args[2];
|
||||
}
|
||||
|
||||
Jid *room_jid = jid_create_from_bare_and_resource(room, nick);
|
||||
|
||||
if (!muc_room_is_active(room_jid)) {
|
||||
|
Loading…
Reference in New Issue
Block a user