Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Kicking users to another channel

Help
sdf oij
2009-01-12
2013-02-13
  • sdf oij
    sdf oij
    2009-01-12

    I want to be able to kick users that dont behave over to a "shame channel" in order to give them a private warning before kicking them out.

    can annybody help me with this one?

     
  • Phoenix psyhub
    Phoenix psyhub
    2011-09-24

    I've been working on this too.
    I've got as far as adding a function to send a message from the target user to the server with "/join <channel>" when an admin types "/move <user> <channel>" - but that in itself isn't enough to cause the user to move.
    I think I'm missing something on the javascript side here.

    Has anyone else had any success?

     
  • Phoenix psyhub
    Phoenix psyhub
    2011-09-25

    Hi, the following code will send a message "Command: /move <channel>" to the target user.
    I have no idea how to pick up the message in javascript (as I'm useless with that) and call the function to switch channel.

    So far everything I've tried has knackered the javascript - so if anyone's got some ideas, please shout!
    (it just needs to detect the "Command: /move" and execute AjaxChat.SendMessageWrapper('/join <channel>'); - any thoughts??)

    function parseCustomCommands($text, $textParts) {
                    switch($textParts) {
                    case '/move':
    if($this->getUserRole() == AJAX_CHAT_ADMIN || $this->getUserRole() == AJAX_CHAT_MODERATOR) {

            $toUserID = $this->getIDFromName($textParts);

            $this->insertCustomMessage(
                    $this->getUserID(),
                    'Command',
                    $this->getUserRole(),
                    $this->getPrivateMessageID($toUserID),
                    '/move '.$textParts
            );

                                    return true;
    }
                            default:
                                    return false;
            break;
    //end of move command
    }

     
  • Phoenix psyhub
    Phoenix psyhub
    2012-04-17

    I have also added the following in the custom.js:

    ajaxChat.moveUserChannel = function(text) {
            var splitText = messageText.split(" ");
            if (/\/move/.test(splitText))
            {
                            text=text.replace(/\/move/gi, 'You have been moved by a moderator to: ');
                            this.clearChatList();
                            this.clearOnlineUsersList();
                            this.setSelectedChannel(splitText);
                            this.channelName = splitText;
                            this.channelSwitch = true;
            }
    }

    Then I have added a call to
                    this.moveUserChannel(messageText);
    into chat.js

    The problem I have now though is that it keeps calling the function, trapping the user in a room … HELP!!!
    I need a way to run this once, then remove the message??

     
  • Phoenix psyhub
    Phoenix psyhub
    2012-04-17

    it's a little over the top, but I've used cookies … This works and is tested!!

    ajaxChat.customOnNewMessage = function(dateObject, userID, userName, userRole, messageID, messageText, channelID, ip) {
       var textParts = messageText.split(" ");
       var messageCookie = this.readCookie(this.sessionName + '_ignore_' + messageID);
            if (/\/move/.test(textParts) && ! messageCookie)
            {
                            this.createCookie(this.sessionName + '_ignore_' + messageID, true, 1);
                            this.clearChatList();
                            this.clearOnlineUsersList();
                            this.setSelectedChannel(textParts);
                            this.channelName = textParts;
                            this.channelSwitch = true;
            }
            return true;
    }

     
  • Phoenix psyhub
    Phoenix psyhub
    2012-04-17

    ok - this is more simple - add it to the end of your js/custom.js

    ajaxChat.customOnNewMessage = function(dateObject, userID, userName, userRole, messageID, messageText, channelID, ip) {
       var textParts = messageText.split(" ");
       var messageCookie = this.readCookie(this.sessionName + '_ignore_' + messageID);
            if (/\/move/.test(textParts) && ! messageCookie)
            {
                            ajaxChat.sendMessageWrapper(('/join ' + textParts))
                            this.createCookie(this.sessionName + '_ignore_' + messageID, true, 1);
            }
            return true;
    }

     
  • Phoenix psyhub
    Phoenix psyhub
    2012-04-17

    Then add this to lib/class/CustomAJAXChat.php (remember to remove the function wrapper if you have other functions):

    function parseCustomCommands($text, $textParts) {
                    switch($textParts) {
                    case '/move':
            if($this->getUserRole() == AJAX_CHAT_ADMIN || $this->getUserRole() == AJAX_CHAT_MODERATOR) {
    //        $toUserID = $this->getIDFromName($textParts);
                    if($this->isAllowedToSendPrivateMessage()) {
                            if(count($textParts) < 3) {
                                    if(count($textParts) == 2) {
                                            $this->insertChatBotMessage(
                                                    $this->getPrivateMessageID(),
                                                    '/error MissingText'
                                            );
                                    } else {
                                            $this->insertChatBotMessage(
                                                    $this->getPrivateMessageID(),
                                                    '/error MissingUserName'
                                            );
                                    }
                            } else {
                                    // Get UserID from UserName:
                                    $toUserID = $this->getIDFromName($textParts);
                                    if($toUserID === null) {
                                            if($this->getQueryUserName() !== null) {
                                                    // Close the current query:

                                                    $this->insertMessage('/query');
                                            } else {
                                                    $this->insertChatBotMessage(
                                                            $this->getPrivateMessageID(),
                                                            '/error UserNameNotFound '.$textParts
                                                    );
                                            }
                                    } else {
                     $channelName=$textParts;
                     $userID=$this->getPrivateMessageID($toUserID);
                     $channelID = $this->getChannelIDFromChannelName($channelName);
                     if ($this->validateChannel($channelID)) {
                                            // Private message to requested User:
                                            $this->insertCustomMessage(
                                                    $this->getUserID(),
                                                    'ChatMessage',
                                                    '4',
                                                    $userID,
                                                    '/move '.implode(' ', array_slice($textParts, 2))
                                            );

                     } else {
                           // Invalid channel:
                            $text = '/error InvalidChannelName '.$channelName;
                            $this->insertChatBotMessage(
                                    $this->getPrivateMessageID(),
                                    $text
                            );
                            return;
                     }
                                    }
                            }
                    } else {
                            $this->insertChatBotMessage(
                                    $this->getPrivateMessageID(),
                                    '/error Movement is not allowed by you'
                            );
                    }

                                    return true;
    }
                            default:
                                    return false;
            break;
    //end of move command
    }

     
  • Phoenix psyhub
    Phoenix psyhub
    2012-04-23

    I modified the php so that  /move <username> just sets the third element of textParts to be the current user channel.
    Then I added this to the bottom of custom.js:

           // Override to add custom user menu items:
            // Return a string with list items ( <li>menuItem</li> )
            // encodedUserName contains the userName ready to be used for javascript links
            // userID is only available for the online users menu - not for the inline user menu
            // use (encodedUserName == this.encodedUserName) to check for the current user
    ajaxChat.getCustomUserMenuItems = function(encodedUserName, userID) {
            var custommenu;
            if((this.userRole == 2 || this.userRole == 3) && this.userID != userID) {
                    custommenu = '<li><a href="javascript:ajaxChat.sendMessageWrapper(\'/move ' + encodedUserName + '\')">move</a></li>';
            } else {
                    custommenu = '';
            }
            return custommenu;
    }

    If you need the full code, just message me ;)

     
  • pastorvictor
    pastorvictor
    2013-02-13

    I'd like the whole code, please, but I don't know how to message you on here. I'm very interested in this /move command.