mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
xep-0308: Make /correct work without quotation marks
Now we can specify an unlimited amount of arguments for commands. Maybe this is also helpful for other commands that use quotation marks so far.
This commit is contained in:
parent
1072cdab0a
commit
8f37afcd37
@ -3765,9 +3765,8 @@ _correct_autocomplete(ProfWin *window, const char *const input, gboolean previou
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GString *result_str = g_string_new("/correct \"");
|
||||
GString *result_str = g_string_new("/correct ");
|
||||
g_string_append(result_str, last_message);
|
||||
g_string_append(result_str, "\"");
|
||||
char *result = result_str->str;
|
||||
g_string_free(result_str, FALSE);
|
||||
|
||||
|
@ -2382,7 +2382,7 @@ static struct cmd_t command_defs[] =
|
||||
},
|
||||
|
||||
{ "/correct",
|
||||
parse_args, 1, 1, NULL,
|
||||
parse_args, 1, -1, NULL,
|
||||
CMD_NOSUBFUNCS
|
||||
CMD_MAINFUNC(cmd_correct)
|
||||
CMD_TAGS(
|
||||
@ -2393,10 +2393,8 @@ static struct cmd_t command_defs[] =
|
||||
CMD_DESC(
|
||||
"Correct and resend the last message (XEP-0308).")
|
||||
CMD_ARGS(
|
||||
{ "\"message\"", "The corrected message. Multiple words need quotation marks."})
|
||||
CMD_EXAMPLES(
|
||||
"/correct Profanity",
|
||||
"/correct \"Profanity is the best\"")
|
||||
{ "message", "The corrected message."})
|
||||
CMD_NOEXAMPLES
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -8701,7 +8701,10 @@ cmd_correct(ProfWin *window, const char *const command, gchar **args)
|
||||
}
|
||||
|
||||
// send message again, with replace flag
|
||||
cl_ev_send_msg_correct(chatwin, args[0], FALSE, TRUE);
|
||||
gchar *message = g_strjoinv(" ", args);
|
||||
cl_ev_send_msg_correct(chatwin, message, FALSE, TRUE);
|
||||
|
||||
free(message);
|
||||
return TRUE;
|
||||
} else if (window->type == WIN_MUC) {
|
||||
ProfMucWin *mucwin = (ProfMucWin*)window;
|
||||
@ -8713,7 +8716,10 @@ cmd_correct(ProfWin *window, const char *const command, gchar **args)
|
||||
}
|
||||
|
||||
// send message again, with replace flag
|
||||
cl_ev_send_muc_msg_corrected(mucwin, args[0], FALSE, TRUE);
|
||||
gchar *message = g_strjoinv(" ", args);
|
||||
cl_ev_send_muc_msg_corrected(mucwin, message, FALSE, TRUE);
|
||||
|
||||
free(message);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@
|
||||
*
|
||||
* inp - The line of input
|
||||
* min - The minimum allowed number of arguments
|
||||
* max - The maximum allowed number of arguments
|
||||
* max - The maximum allowed number of arguments, -1 for infinite
|
||||
*
|
||||
* Returns - An NULL terminated array of strings representing the arguments
|
||||
* of the command, or NULL if the validation fails.
|
||||
@ -135,7 +135,7 @@ parse_args(const char *const inp, int min, int max, gboolean *result)
|
||||
int num = g_slist_length(tokens) - 1;
|
||||
|
||||
// if num args not valid return NULL
|
||||
if ((num < min) || (num > max)) {
|
||||
if ((num < min) || ((max != -1) && (num > max))) {
|
||||
g_slist_free_full(tokens, free);
|
||||
g_free(copy);
|
||||
*result = FALSE;
|
||||
|
Loading…
Reference in New Issue
Block a user