about summary refs log tree commit diff stats
path: root/src/command
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-10-05 03:52:55 +0100
committerJames Booth <boothj5@gmail.com>2014-10-05 03:52:55 +0100
commitac7bc02c63a5aed8decfcbbdc5582e9e5b389030 (patch)
tree302fa5fcd1ea72e67071d2043051eef3fef12ea1 /src/command
parent7584ddaa62033f876b78a4de8b32d8e1e90e0619 (diff)
downloadprofani-tty-ac7bc02c63a5aed8decfcbbdc5582e9e5b389030.tar.gz
Added /room kick command
Diffstat (limited to 'src/command')
-rw-r--r--src/command/command.c10
-rw-r--r--src/command/commands.c16
2 files changed, 26 insertions, 0 deletions
diff --git a/src/command/command.c b/src/command/command.c
index 1f8977b7..90f168d1 100644
--- a/src/command/command.c
+++ b/src/command/command.c
@@ -1251,6 +1251,7 @@ cmd_init(void)
     autocomplete_add(room_ac, "config");
     autocomplete_add(room_ac, "info");
     autocomplete_add(room_ac, "subject");
+    autocomplete_add(room_ac, "kick");
     autocomplete_add(room_ac, "role");
     autocomplete_add(room_ac, "affiliation");
 
@@ -2311,6 +2312,15 @@ _room_autocomplete(char *input, int *size)
         return result;
     }
 
+    char *recipient = ui_current_recipient();
+    Autocomplete nick_ac = muc_roster_ac(recipient);
+    if (nick_ac != NULL) {
+        result = autocomplete_param_with_ac(input, size, "/room kick", nick_ac, TRUE);
+        if (result != NULL) {
+            return result;
+        }
+    }
+
     result = autocomplete_param_with_ac(input, size, "/room", room_ac, TRUE);
     if (result != NULL) {
         return result;
diff --git a/src/command/commands.c b/src/command/commands.c
index ad8e93ea..39981b5f 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -2127,6 +2127,7 @@ cmd_room(gchar **args, struct cmd_help_t help)
             (g_strcmp0(args[0], "destroy") != 0) &&
             (g_strcmp0(args[0], "config") != 0) &&
             (g_strcmp0(args[0], "subject") != 0) &&
+            (g_strcmp0(args[0], "kick") != 0) &&
             (g_strcmp0(args[0], "role") != 0) &&
             (g_strcmp0(args[0], "affiliation") != 0) &&
             (g_strcmp0(args[0], "info") != 0)) {
@@ -2179,6 +2180,21 @@ cmd_room(gchar **args, struct cmd_help_t help)
         return TRUE;
     }
 
+    if (g_strcmp0(args[0], "kick") == 0) {
+        char *nick = args[1];
+        if (nick) {
+            if (muc_roster_contains_nick(room, nick)) {
+                char *reason = args[2];
+                iq_room_kick_occupant(room, nick, reason);
+            } else {
+                win_save_vprint(window, '!', NULL, 0, 0, "", "Occupant does not exist: %s", nick);
+            }
+        } else {
+            cons_show("Usage: %s", help.usage);
+        }
+        return TRUE;
+    }
+
     if (g_strcmp0(args[0], "affiliation") == 0) {
         char *cmd = args[1];
         if (cmd == NULL) {