예제 #1
0
 void ChatLoop(string line)
 {
     var chat = new ChatMessageClient(line);
     FromClient(chat);
 }
예제 #2
0
        public static void ParseClient(Client player, ChatMessageClient chat)
        {
            string message = chat.Text;
            
            if (message.Contains("§"))
            {
                Log.WritePlayer(player, "Illegal chat: " + message);
                return;
            }

            //Flood detection
            if (player.ChatFloodNextReset < DateTime.Now)
            {
                player.ChatFloodCount = 1;
                player.ChatFloodNextReset = DateTime.Now.AddSeconds(5);
            } else
            {
                player.ChatFloodCount += 1;
                if (player.ChatFloodCount > 10)
                {
                    player.ChatFloodCount = 0;
                    player.BanByServer(DateTime.Now.AddMinutes(5), "Chat Flood");
                    return;
                }
            }

            if (chat.Text.StartsWith("/"))
                MainCommands.ParseClientCommand(player, message);
            else
                ParseClientChat(player, message);
        }