예제 #1
0
        /// <summary>
        /// Filters a message and hides profanities behind asterisk characters.
        /// Supports words that have been separated by special characters.
        /// </summary>
        /// <param name="message">The message to filter.</param>
        /// <param name="userSocket">The player's connection socket.</param>
        /// <returns>True if the message contained bad words, false otherwise.</returns>
        public static bool FilterMessage(ref string message, IUserSocket userSocket)
        {
            bool hasBadWords = false;

            if (enableFilter)
            {
                // Tokenise the sentence into words
                string[] words = message.Split(SPLITTER);

                // Clean up the message
                RemoveSpecialCharacters(words);
                ReplaceDigitsWithLetters(words);

                // Check each word against our profanity list
                hasBadWords = ReplaceBadWords(words);

                if (hasBadWords)
                {
                    HandleBadWords(userSocket);

                    // Reconstruct the message
                    message = ReconstructMessage(message, words);
                }
            }

            return(hasBadWords);
        }
예제 #2
0
 /// <summary>
 /// React to the player speaking profanities.
 /// </summary>
 /// <param name="userSocket">The player's connection socket.</param>
 private static void HandleBadWords(IUserSocket userSocket)
 {
     // Do we send the player a message?
     if (sendMessageToPlayer)
     {
         userSocket.SendLine(playerMessage);
     }
 }
예제 #3
0
 public ClientListener(IUserSocket userSocket,
                       ClientDisconnectedEventHandler clientDisconnectedEventHandler)
 {
     this.userSocket = userSocket;
     this.clientDisconnectedEventHandler = clientDisconnectedEventHandler;
     this.listenerThread = new Thread(new ThreadStart(Listen));
     active  = false;
     enabled = false;
 }
예제 #4
0
        public void Add(IUserSocket socket, string username, string logmessage)
        {
            try
            {
                string endPointId = "unknown";

                if (socket != null)
                {
                    endPointId = socket.ClientEndpointId;
                }
                Lib.dbService.MudLog.Log(logmessage,
                                         endPointId,
                                         username);
                Lib.PrintLine(DateTime.Now.ToString() + " - " + logmessage);
            }
            catch (Exception ex)
            {
                Lib.log.Add("mudlog.add", "Exception. " + ex.Message + ex.StackTrace);
            }
        }
예제 #5
0
 public EmailUserActivation(IUserSocket userSocket, string Username)
 {
     this.userSocket = userSocket;
     this.s_Username = Username;
 }
예제 #6
0
        public bool processcommand(IUserSocket userSocket, string messagefrom, string playercommand, bool login)
        {
            Actor     user       = new Actor();   // Current user
            Actor     chkuser    = new Actor();   // Temp array of users for search loops
            object    chkobject  = new object();
            ArrayList chkobjects = new ArrayList();
            Actor     chkmob     = new Actor();
            Actor     room       = new Actor();   // Current room during item search loops
            Actor     item       = new Actor();   // Current item during item search loops
            Actor     item2      = new Actor();   // Temp variable for trading
            Actor     chkitem    = new Actor();   // Temp variable for scanning item arraylist
            //int maxmapx=75; // Game map is limited to a width of this number
            //int maxmapy=19; // Game map is limited to a height of this number
            //string[,] mapgrid=new string[maxmapx,maxmapy];
            string message  = null;
            string clientip = null;


            // Here's where we get the first command from a newly logged in user
            // When login bit is set, this is a user login event
            if (login)
            {
                // Get instance of this user from the name
                user              = Lib.GetByName(playercommand.ToLower());
                user.UserSocket   = userSocket;
                user["connected"] = true;
                // clear combat
                user["target"] = "";

                if (Lib.ConvertToBoolean(user["lockedout"]))
                {
                    user.SendAnnouncement("You have been locked out. Please contact the MUD administrator.");
                    return(false);
                }

                Lib.log.Add(user.UserSocket, user["shortname"].ToString(), "LOGIN (" + user["shortname"].ToString() + ") (" + userSocket.ClientEndpointId + ") Online:" + Lib.connections);
                user.Send(Lib.Ansifboldred + "\r\nWelcome " + user.GetNameUpper() + "!\r\n");

                // Set login time for calculating total played time
                user["loginticks"] = Lib.GetTime();
                // Display room
                user.Showroom();
                // Set idle disconnect timer
                user["lastmessageticks"] = Lib.GetTime();
                // Send 'he arrived' messages if someone is in the room where the user appears
                user.Sayinroom(user.GetNameUpper() + " appears from nowhere.");

                // Notify his friends that he has arrived
                ShowWelcomeMessages(user);

                user.Showprompt();
                return(true);
            }



            // Most importantly, set the context of user to the user who sent this message
            for (int i = Lib.actors.Count - 1; i >= 0; i--)
            {
                Actor tmpuser = (Actor)Lib.actors[i];
                if (tmpuser["shortname"].ToString() == messagefrom)
                {
                    user = tmpuser;
                    break;
                }
            }

            // Log player commands
            message += DateTime.Now;
            if (user["name"] != null)
            {
                message += " " + user["name"].ToString();
            }
            if (user.UserSocket != null)
            {
                clientip = user.UserSocket.ClientEndpointId;
                message += " from " + clientip;
            }
            if (playercommand != null)
            {
                message += " command: " + playercommand;
            }
            Lib.commandlogwriter.WriteLine(message);

            // This counts as activity, so update timer for idle disconnect
            user["lastmessageticks"] = Lib.GetTime();

            // If no text at all, then try to run the more command.
            if (playercommand == "")
            {
                user.RunCommand("more", null);
                user.Showprompt();
                return(true);
            }

            // Store current message for the "again" command to repeat it
            // But don't store the "again" command itself AS the last command
            // and don't store anything if the user just logged in
            if (!playercommand.StartsWith(".") && playercommand != "again" && !login)
            {
                user["lastmessagefrom"] = messagefrom;
                user["lastmessage"]     = playercommand;
            }

            //Parse command word from arguments
            string[] splitcommand = Lib.SplitCommand(playercommand);
            string   playerword   = splitcommand[0];
            string   arguments    = splitcommand[1];

            playerword = playerword.ToLower();
            Command command = (Command)user.GetCommandByWord(playerword);

            if (command != null)
            {
                try
                {
                    command.DoCommand(user, playerword, arguments.Trim());
                }
                catch (Exception ex)
                {
                    if (command != null)
                    {
                        Lib.PrintLine(DateTime.Now + " EXCEPTION running command: " + command.Name + ": " + ex.Message + ex.StackTrace);
                    }
                    else
                    {
                        Lib.PrintLine(DateTime.Now + " EXCEPTION running a command: " + ex.Message + ex.StackTrace);
                    }
                    return(false);
                }
            }
            else
            {
                // if we got here, the command was not found.
                user.SendError("Unknown command, type 'help' for a list of commands.\r\n");
                user.Showprompt();
                return(true);
            }
            if (command.Name != "command_again")
            {
                // Prevent double command prompts when using the 'again' command
                user.Showprompt();
            }
            return(true);
        }
예제 #7
0
 public EmailPassword(IUserSocket userSocket, string Username)
 {
     this.userSocket = userSocket;
     this.userName   = Username;
 }