]> code.citadel.org Git - citadel.git/commitdiff
* Added /kick command to chat. /ban coming soon.
authorArt Cancro <ajc@citadel.org>
Sun, 29 Feb 2004 23:26:48 +0000 (23:26 +0000)
committerArt Cancro <ajc@citadel.org>
Sun, 29 Feb 2004 23:26:48 +0000 (23:26 +0000)
citadel/ChangeLog
citadel/serv_chat.c
citadel/user_ops.c

index dd501dfbd7cff67aa33740ffa98e35c18165c0d3..db6a7da4c23b00b16f6036e0b873410e8c6b489d 100644 (file)
@@ -1,4 +1,7 @@
  $Log$
+ Revision 614.57  2004/02/29 23:26:48  ajc
+ * Added /kick command to chat.  /ban coming soon.
+
  Revision 614.56  2004/02/28 16:37:41  ajc
  * setup.c: removed an unused temp file name variable
 
@@ -5428,4 +5431,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
-
index a91dd162fdfab31afec56c012362e9dddf2ffedf..c4bb1f4249f392ff69e94efa21def556ea726fb3 100644 (file)
 struct ChatLine *ChatQueue = NULL;
 int ChatLastMsg = 0;
 
-
-
+/*
+ * This message can be set to anything you want, but it is
+ * checked for consistency so don't move it away from here.
+ */
+#define KICKEDMSG "You have been kicked out of this room."
 
 void allwrite(char *cmdbuf, int flag, char *username)
 {
@@ -70,6 +73,8 @@ void allwrite(char *cmdbuf, int flag, char *username)
                snprintf(bcast, sizeof bcast, "%s|%s", un, cmdbuf);
        } else if (flag == 2) {
                snprintf(bcast, sizeof bcast, ":|<%s whispers %s>", un, cmdbuf);
+       } else if (flag == 3) {
+               snprintf(bcast, sizeof bcast, ":|%s", KICKEDMSG);
        }
        if ((strcasecmp(cmdbuf, "NOOP")) && (flag != 2)) {
                fp = fopen(CHATLOG, "a");
@@ -310,6 +315,9 @@ void cmd_chat(char *argbuf)
                                        cprintf(":|/whobbs (list users in chat -and- elsewhere) \n");
                                        cprintf(":|/me     ('action' line, ala irc) \n");
                                        cprintf(":|/msg    (send private message, ala irc) \n");
+                                       if (is_room_aide()) {
+                                               cprintf(":|/kick   (kick another user out of this room) \n");
+                                       }
                                        cprintf(":|/quit   (return to the BBS) \n");
                                        cprintf(":|\n");
                                        ok_cmd = 1;
@@ -337,6 +345,22 @@ void cmd_chat(char *argbuf)
                                                cprintf(":|User not found.\n");
                                        cprintf("\n");
                                }
+                               /* The /kick function is implemented by sending a specific
+                                * message to the kicked-out user's context.  When that message
+                                * is processed by the read loop, that context will exit.
+                                */
+                               if ( (!strncasecmp(cmdbuf, "/kick ", 6)) && (is_room_aide()) ) {
+                                       ok_cmd = 1;
+                                       strptr1 = &cmdbuf[6];
+                                       strcat(strptr1, " ");
+                                       if ((t_context = find_context(&strptr1))) {
+                                               allwrite(strptr1, 3, CC->curr_user);
+                                               if (strcasecmp(CC->curr_user, t_context->curr_user))
+                                                       allwrite(strptr1, 2, t_context->curr_user);
+                                       } else
+                                               cprintf(":|User not found.\n");
+                                       cprintf("\n");
+                               }
                                if ((cmdbuf[0] != '/') && (strlen(cmdbuf) > 0)) {
                                        ok_cmd = 1;
                                        allwrite(cmdbuf, 0, NULL);
@@ -358,7 +382,15 @@ void cmd_chat(char *argbuf)
                        for (clptr = ChatQueue; clptr != NULL; clptr = clptr->next) {
                                if ((clptr->chat_seq > MyLastMsg) && ((!clptr->chat_username[0]) || (!strncasecmp(un, clptr->chat_username, 32)))) {
                                        if ((!clptr->chat_room[0]) || (!strncasecmp(CC->room.QRname, clptr->chat_room, ROOMNAMELEN))) {
+                                               /* Output new chat data */
                                                cprintf("%s\n", clptr->chat_text);
+
+                                               /* See if we've been force-quitted (kicked etc.) */
+                                               if (!strcmp(&clptr->chat_text[2], KICKEDMSG)) {
+                                                       cprintf("000\n");
+                                                       CC->cs_flags = CC->cs_flags - CS_CHAT;
+                                                       return;
+                                               }
                                        }
                                }
                        }
index 014d6e2ac7c6262dbc2b3311a348c9bcc29fa2df..a85a553ad8197b60cb3b639df692ac2b5817dd81 100644 (file)
@@ -1129,8 +1129,8 @@ void cmd_invt_kick(char *iuser, int op)
                cprintf("%d No such user.\n", ERROR + NO_SUCH_USER);
                return;
        }
-       CtdlGetRelationship(&vbuf, &USscratch, &CC->room);
 
+       CtdlGetRelationship(&vbuf, &USscratch, &CC->room);
        if (op == 1) {
                vbuf.v_flags = vbuf.v_flags & ~V_FORGET & ~V_LOCKOUT;
                vbuf.v_flags = vbuf.v_flags | V_ACCESS;