Ejemplo n.º 1
0
        protected virtual void Kick(Message msg)
        {
            if (!this.isOP)
            {
                return;
            }
            string nick = msg.stringFormat.Substring(6, msg.stringFormat.Length - 7);

            GHub.client.user.User clnt = (GHub.client.user.User) this.ClientList.Get(nick);

            if (clnt != null)
            {
                clnt.closeAndRemoveUser();
                return;
            }


            for (int eachServer = 0; eachServer < this.ServerList.Size(); eachServer++)
            {
                GHub.client.server.Server serv = (GHub.client.server.Server) this.ServerList.Get(eachServer);

                for (int eachUser = 0; eachUser < serv.usersToServer.Size(); eachUser++)
                {
                    if (serv.usersToServer.Get(nick) != null)
                    {
                        serv.SendMessage(msg.stringFormat);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void kick(string Msg, Message msg)
        {        // !kick nick reasong for kicking
            string nickBeingKicked = string.Empty;
            string kickMessage     = string.Empty;
            int    position;

            GHub.client.Client        kickedClnt;
            GHub.client.user.User     clntKicking;
            GHub.client.server.Server serv;

            if (Msg.Length < 7)
            {
                return;
            }

            //if (  !((GHub.client.userInfo)msg.client).isOP  )
            //	return;

            // find out where the space is after the nick of the person being kicked
            switch (position = Msg.IndexOf(' ', 6))
            {
            // if no space was found after the name then there probs was no reason given
            case -1:
                nickBeingKicked = Msg.Substring(6);
                kickMessage     = "$To: " + nickBeingKicked + " From: " + msg.sender + " $<" + msg.sender + "> You have been kicked from the hub" + "|";
                break;

            // found a space after the nick being kicked so work out the nick being kicked.
            default:
                nickBeingKicked = Msg.Substring(6, position - 6);
                kickMessage     = "$To: " + nickBeingKicked + " From: " + msg.sender + " $<" + msg.sender + ">" + Msg.Substring(position) + "|";
                break;
            }

            // check to see if we can find the user on this hub.
            if ((kickedClnt = msg.client.ClientList.Get(nickBeingKicked)) == null)
            {
                // we have not found the user on this hub so now look for the user on
                // the rest of the hubs.
                for (int i = 0; i < msg.client.ServerList.Size(); msg.client.ServerList.Get(i))
                {
                    serv = (GHub.client.server.Server)msg.client.ServerList.Get(i);
                    if (serv.usersToServer.Get(nickBeingKicked) != null)
                    {
                        serv.SendMessage(msg.stringFormat + "|");
                        return;
                    }
                }
                return;
            }

            // the person we are trying to kick is on this server

            GHub.client.user.User clntKicked = (GHub.client.user.User)msg.allLocalUsers.Get(nickBeingKicked);

            clntKicking = (GHub.client.user.User)msg.client;

            switch (clntKicking.Profile.kickLevel)
            {
            // user is not allowed to use the kick command
            case 0:
                return;

            // user can kick any one below his profile
            case 1:

                if (clntKicking.Profile.profileLevel > ((GHub.client.user.User)kickedClnt).Profile.profileLevel)
                {
                }
                else
                {
                    return;
                }
                break;

            // user can kick any one below and at the same level as his profile
            case 2:

                if (clntKicking.Profile.profileLevel >= ((GHub.client.user.User)kickedClnt).Profile.profileLevel)
                {
                }
                else
                {
                    return;
                }
                break;

            // user can kick any one below at and above his profile (i.e. any one)
            case 3:

                break;
            }

            if (clntKicking.Profile.profileLevel < clntKicked.Profile.profileLevel)
            {
                msg.client.SendMessage("$To: " + msg.sender + " From: " + GHub.Settings.Hub.hubSettings.BotName + " $<" + GHub.Settings.Hub.hubSettings.BotName + "> You do not have access to kick this user|");
                return;
            }

            // send message to the user being kicked.
            kickedClnt.SendMessage(kickMessage);
            // Disconnect the user from the hub.
            sendMessage.DisconnectUser(msg);

            System.DateTime ban = System.DateTime.Now;
            ban = ban.AddMinutes(5);
            // add a temp ban to the user
            GHub.Settings.BANS.tempBans.Add(((GHub.client.userInfo)kickedClnt).ipAddress, ban);
        }