diff mcabber/src/commands.c @ 568:eb1df2371581

Add "/room kick"
author Mikael Berthe <mikael@lilotux.net>
date Sat, 03 Dec 2005 13:32:29 +0100
parents 467fec046a9b
children 29806b0fe830
line wrap: on
line diff
--- a/mcabber/src/commands.c	Sat Dec 03 00:24:05 2005 +0100
+++ b/mcabber/src/commands.c	Sat Dec 03 13:32:29 2005 +0100
@@ -158,6 +158,7 @@
   // Room category
   compl_add_category_word(COMPL_ROOM, "invite");
   compl_add_category_word(COMPL_ROOM, "join");
+  compl_add_category_word(COMPL_ROOM, "kick");
   compl_add_category_word(COMPL_ROOM, "leave");
   compl_add_category_word(COMPL_ROOM, "names");
   compl_add_category_word(COMPL_ROOM, "nick");
@@ -1176,7 +1177,7 @@
 
   if (param_needed) {
     if (!arg) {
-      scr_LogPrint(LPRINT_NORMAL, "Wrong or missing parameter");
+      scr_LogPrint(LPRINT_NORMAL, "Missing parameter");
       return NULL;
     }
   }
@@ -1244,6 +1245,27 @@
   free_arg_lst(paramlst);
 }
 
+static void room_kick(gpointer bud, char *arg)
+{
+  char **paramlst;
+  gchar *nick;
+  const char *roomid = buddy_getjid(bud);
+
+  paramlst = split_arg(arg, 2, 1); // nickname, reason
+  nick = *paramlst;
+  arg = *(paramlst+1);
+
+  if (!nick || !*nick) {
+    scr_LogPrint(LPRINT_NORMAL, "Missing parameter (nickname)");
+    free_arg_lst(paramlst);
+    return;
+  }
+
+  jb_room_kickban(roomid, NULL, nick, 1, arg);
+
+  free_arg_lst(paramlst);
+}
+
 static void room_leave(gpointer bud, char *arg)
 {
   gchar *roomid, *utf8_nickname;
@@ -1376,6 +1398,9 @@
   } else if (!strcasecmp(subcmd, "invite"))  {
     if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL)
       room_invite(bud, arg);
+  } else if (!strcasecmp(subcmd, "kick"))  {
+    if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL)
+      room_kick(bud, arg);
   } else if (!strcasecmp(subcmd, "leave"))  {
     if ((arg = check_room_subcommand(arg, FALSE, bud)) != NULL)
       room_leave(bud, arg);