1
1
mirror of https://github.com/profanity-im/profanity.git synced 2025-01-03 14:57:42 -05:00

Merge branch 'DebXWoody/usermoodimprovement1'

This commit is contained in:
Michael Vetter 2022-01-30 18:25:47 +01:00
commit f14f9afe03
4 changed files with 24 additions and 16 deletions

View File

@ -1063,6 +1063,7 @@ cmd_ac_init(void)
mood_ac = autocomplete_new(); mood_ac = autocomplete_new();
autocomplete_add(mood_ac, "set"); autocomplete_add(mood_ac, "set");
autocomplete_add(mood_ac, "clean");
mood_type_ac = autocomplete_new(); mood_type_ac = autocomplete_new();
autocomplete_add(mood_type_ac, "afraid"); autocomplete_add(mood_type_ac, "afraid");
autocomplete_add(mood_type_ac, "amazed"); autocomplete_add(mood_type_ac, "amazed");
@ -4243,7 +4244,7 @@ _mood_autocomplete(ProfWin* window, const char* const input, gboolean previous)
{ {
char* result = NULL; char* result = NULL;
result = autocomplete_param_with_ac(input, "/mood", status_ac, TRUE, previous); result = autocomplete_param_with_ac(input, "/mood", mood_ac, TRUE, previous);
if (result) { if (result) {
return result; return result;
} }

View File

@ -2680,20 +2680,23 @@ static struct cmd_t command_defs[] = {
}, },
{ "/mood", { "/mood",
parse_args, 2, 3, NULL, parse_args, 1, 3, NULL,
CMD_NOSUBFUNCS CMD_NOSUBFUNCS
CMD_MAINFUNC(cmd_mood) CMD_MAINFUNC(cmd_mood)
CMD_TAGS( CMD_TAGS(
CMD_TAG_CHAT) CMD_TAG_CHAT)
CMD_SYN( CMD_SYN(
"/mood set <mood> [text]") "/mood set <mood> [text]",
"/mood clean")
CMD_DESC( CMD_DESC(
"Set your mood (XEP-0107). Use tab to switch through predefined moods.") "Set your mood (XEP-0107).")
CMD_ARGS( CMD_ARGS(
{ "set <mood>", "Setting your mood." }, { "set <mood> <", "Set user mood to <mood> with an optional [text]. Use /mood set <tab> to toggle through predfined moods." },
{ "<text>", "Additional Text." }) { "clean", "Clean your user mood." })
CMD_EXAMPLES( CMD_EXAMPLES(
"/mood set happy \"So happy to use Profanity!\"") "/mood set happy \"So happy to use Profanity!\"",
"/mood set amazed",
"/mood clean")
}, },
// NEXT-COMMAND (search helper) // NEXT-COMMAND (search helper)
}; };

View File

@ -9658,6 +9658,9 @@ cmd_mood(ProfWin* window, const char* const command, gchar** args)
publish_user_mood(args[1], args[1]); publish_user_mood(args[1], args[1]);
} }
} }
} else if (g_strcmp0(args[0], "clean") == 0) {
cons_show("Cleaning your user mood.");
publish_user_mood(NULL, NULL);
} }
return TRUE; return TRUE;
} }

View File

@ -2828,17 +2828,18 @@ publish_user_mood(const char* const mood, const char* const text)
xmpp_stanza_add_child(item, mood_t); xmpp_stanza_add_child(item, mood_t);
xmpp_stanza_t* x = xmpp_stanza_new(ctx); xmpp_stanza_t* x = xmpp_stanza_new(ctx);
xmpp_stanza_t* text_t = xmpp_stanza_new(ctx);
xmpp_stanza_t* t = xmpp_stanza_new(ctx);
if (mood) {
xmpp_stanza_set_name(x, mood); xmpp_stanza_set_name(x, mood);
xmpp_stanza_add_child(mood_t, x); xmpp_stanza_add_child(mood_t, x);
xmpp_stanza_t* text_t = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(text_t, STANZA_NAME_TEXT); xmpp_stanza_set_name(text_t, STANZA_NAME_TEXT);
xmpp_stanza_add_child(mood_t, text_t); xmpp_stanza_add_child(mood_t, text_t);
xmpp_stanza_t* t = xmpp_stanza_new(ctx);
xmpp_stanza_set_text(t, text); xmpp_stanza_set_text(t, text);
xmpp_stanza_add_child(text_t, t); xmpp_stanza_add_child(text_t, t);
}
iq_send_stanza(iq); iq_send_stanza(iq);
xmpp_stanza_release(iq); xmpp_stanza_release(iq);