1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

XEP-0107: User Mood - Clean mood

* Bugfix in mood_autocomplete (wrong parameter)
 * Implemented /mood clean
 ______________________________________
/ Profanity! THE XMPP client with mood \
\ support!                             /
 --------------------------------------
   \
    \
        .--.
       |o_o |
       |:_/ |
      //   \ \
     (|     | )
    /'\_   _/`\
    \___)=(___/
This commit is contained in:
Stefan Kropp 2022-01-29 06:55:00 +01:00 committed by Michael Vetter
parent b1929068ff
commit 7a4cfc14d1
4 changed files with 22 additions and 14 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). Use tab to switch through predefined moods.")
CMD_ARGS( CMD_ARGS(
{ "set <mood>", "Setting your mood." }, { "set <mood>", "Setting your mood." },
{ "<text>", "Additional Text." }) { "<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 clean")
}, },
// NEXT-COMMAND (search helper) // NEXT-COMMAND (search helper)
}; };

View File

@ -9650,7 +9650,7 @@ gboolean
cmd_mood(ProfWin* window, const char* const command, gchar** args) cmd_mood(ProfWin* window, const char* const command, gchar** args)
{ {
if (g_strcmp0(args[0], "set") == 0) { if (g_strcmp0(args[0], "set") == 0) {
if(args[1]) { if (args[1]) {
cons_show("Your mood: %s", args[1]); cons_show("Your mood: %s", args[1]);
if (args[2]) { if (args[2]) {
publish_user_mood(args[1], args[2]); publish_user_mood(args[1], args[2]);
@ -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_set_name(x, mood);
xmpp_stanza_add_child(mood_t, x);
xmpp_stanza_t* text_t = xmpp_stanza_new(ctx); xmpp_stanza_t* text_t = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(text_t, STANZA_NAME_TEXT);
xmpp_stanza_add_child(mood_t, text_t);
xmpp_stanza_t* t = xmpp_stanza_new(ctx); xmpp_stanza_t* t = xmpp_stanza_new(ctx);
xmpp_stanza_set_text(t, text); if (mood) {
xmpp_stanza_add_child(text_t, t); xmpp_stanza_set_name(x, mood);
xmpp_stanza_add_child(mood_t, x);
xmpp_stanza_set_name(text_t, STANZA_NAME_TEXT);
xmpp_stanza_add_child(mood_t, text_t);
xmpp_stanza_set_text(t, text);
xmpp_stanza_add_child(text_t, t);
}
iq_send_stanza(iq); iq_send_stanza(iq);
xmpp_stanza_release(iq); xmpp_stanza_release(iq);