示例#1
0
        void Listener_OnPublic(UserInfo user, string channel, string message)
        {
            message = CP437Reader.ConvertToRaw(message);
            //string allowedchars = "1234567890-=qwertyuiop[]\\asdfghjkl;'zxcvbnm,./!@#$%^*()_+QWERTYUIOPASDFGHJKL:\"ZXCVBNM<>? ";
            //string msg = message;
            RemoveVariables(ref message);
            RemoveWhitespace(ref message);

            //if (message.Contains("^UGCS"))
            //{
            //    Server.UpdateGlobalSettings();
            //    return;
            //}
            if (message.Contains("^IPGET "))
            {
                Player[] players = PlayerInfo.Online.Items;
                foreach (Player p in players)
                {
                    if (p.name == message.Split(' ')[1])
                    {
                        if (Server.UseGlobalChat && IsConnected())
                        {
                            if (Player.IsLocalIpAddress(p.ip))
                            {
                                connection.Sender.PublicMessage(channel, "^IP " + p.name + ": " + Server.IP);
                                connection.Sender.PublicMessage(channel, "^PLAYER IS CONNECTING THROUGH A LOCAL IP.");
                            }
                            else
                            {
                                connection.Sender.PublicMessage(channel, "^IP " + p.name + ": " + p.ip);
                            }
                        }
                    }
                }
            }
            if (message.Contains("^SENDRULES "))
            {
                Player who = PlayerInfo.Find(message.Split(' ')[1]);
                if (who != null)
                {
                    Command.all.Find("gcrules").Use(who, "");
                }
            }
            if (message.Contains("^GETINFO "))
            {
                if (message.Split(' ')[1] == Server.GlobalChatNick())
                {
                    if (Server.UseGlobalChat && IsConnected())
                    {
                        connection.Sender.PublicMessage(channel, "^NAME: " + Server.name);
                        connection.Sender.PublicMessage(channel, "^MOTD: " + Server.motd);
                        connection.Sender.PublicMessage(channel, "^VERSION: " + Server.VersionString);
                        connection.Sender.PublicMessage(channel, "^URL: " + Server.URL);
                        connection.Sender.PublicMessage(channel, "^PLAYERS: " + PlayerInfo.Online.Count + "/" + Server.players);
                    }
                }
            }

            //for RoboDash's anti advertise/swear in #globalchat
            if (message.Contains("^ISASERVER "))
            {
                if (Server.GlobalChatNick() == message.Split(' ')[1])
                {
                    connection.Sender.PublicMessage(channel, "^IMASERVER");
                }
            }

            if (message.StartsWith("^"))
            {
                return;
            }

            message = message.MCCharFilter();

            if (String.IsNullOrEmpty(message))
            {
                return;
            }

            if (OnNewRecieveGlobalMessage != null)
            {
                OnNewRecieveGlobalMessage(user.Nick, message);
            }

            if (Server.Devs.CaselessContains(message.Split(':')[0]) && !message.StartsWith("[Dev]") && !message.StartsWith("[Developer]"))
            {
                message = "[Dev]" + message;
            }
            else if (Server.Mods.CaselessContains(message.Split(':')[0]) && !message.StartsWith("[Mod]") && !message.StartsWith("[Moderator]"))
            {
                message = "[Mod]" + message;
            }

            /*try {
             *  if(GUI.GuiEvent != null)
             *  GUI.GuiEvents.GlobalChatEvent(this, "> " + user.Nick + ": " + message); }
             * catch { Server.s.Log(">[Global] " + user.Nick + ": " + message); }*/
            Player.GlobalMessage(String.Format("%G>[Global] {0}: &f{1}", user.Nick, Server.profanityFilter ? ProfanityFilter.Parse(message) : message), true);
        }