about summary refs log tree commit diff stats
path: root/src/command
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2021-03-18 20:32:12 +0100
committerMichael Vetter <jubalh@iodoru.org>2021-03-25 11:05:58 +0100
commitfde0a0d1c65ff61eb3d5bb9c07d6974d4fdac1f6 (patch)
tree5665fcc576e40222f0ed1e3e9bb1d2ba55b31b89 /src/command
parent064174efa3604404fd1b8a5c34cf69ed93ab12dc (diff)
downloadprofani-tty-fde0a0d1c65ff61eb3d5bb9c07d6974d4fdac1f6.tar.gz
Add support to register with a room
`/affiliation register` can now be used to register a nickname with a
MUC.

Tested with a server without forms. Couldn't find a server which
supports forms yet.

Implements https://github.com/profanity-im/profanity/issues/1210
Diffstat (limited to 'src/command')
-rw-r--r--src/command/cmd_ac.c1
-rw-r--r--src/command/cmd_defs.c6
-rw-r--r--src/command/cmd_funcs.c5
3 files changed, 10 insertions, 2 deletions
diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c
index a2d949eb..a4338143 100644
--- a/src/command/cmd_ac.c
+++ b/src/command/cmd_ac.c
@@ -756,6 +756,7 @@ cmd_ac_init(void)
     affiliation_cmd_ac = autocomplete_new();
     autocomplete_add(affiliation_cmd_ac, "list");
     autocomplete_add(affiliation_cmd_ac, "request");
+    autocomplete_add(affiliation_cmd_ac, "register");
     autocomplete_add(affiliation_cmd_ac, "set");
 
     role_cmd_ac = autocomplete_new();
diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c
index 55f58b49..c756c169 100644
--- a/src/command/cmd_defs.c
+++ b/src/command/cmd_defs.c
@@ -695,14 +695,16 @@ static struct cmd_t command_defs[] = {
       CMD_SYN(
               "/affiliation set <affiliation> <jid> [<reason>]",
               "/affiliation list [<affiliation>]",
-              "/affiliation request")
+              "/affiliation request",
+              "/affiliation register")
       CMD_DESC(
               "Manage room affiliations. "
               "Affiliation may be one of owner, admin, member, outcast or none.")
       CMD_ARGS(
               { "set <affiliation> <jid> [<reason>]", "Set the affiliation of user with jid, with an optional reason." },
               { "list [<affiliation>]", "List all users with the specified affiliation, or all if none specified." },
-              { "request", "Request voice."})
+              { "request", "Request voice."},
+              { "register", "Register your nickname with the MUC."})
       CMD_NOEXAMPLES
     },
 
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c
index 657850e2..07a444f7 100644
--- a/src/command/cmd_funcs.c
+++ b/src/command/cmd_funcs.c
@@ -4166,6 +4166,11 @@ cmd_affiliation(ProfWin* window, const char* const command, gchar** args)
         return TRUE;
     }
 
+    if (g_strcmp0(cmd, "register") == 0) {
+        iq_muc_register_nick(mucwin->roomjid);
+        return TRUE;
+    }
+
     cons_bad_cmd_usage(command);
     return TRUE;
 }