updated README about fonts, added more app configurations and added the app.config file itself
This commit is contained in:
		
							parent
							
								
									d5b9191521
								
							
						
					
					
						commit
						dba5ebc3d1
					
				
							
								
								
									
										12
									
								
								ArtificialAutism/app.config
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								ArtificialAutism/app.config
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,12 @@
 | 
			
		||||
app.url=jdbc:mysql://localhost:3306/ArtificialAutism?useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC&allowPublicKeyRetrieval=True
 | 
			
		||||
app.username=
 | 
			
		||||
app.password=
 | 
			
		||||
app.hostip=
 | 
			
		||||
app.hostip2=
 | 
			
		||||
app.hostport=
 | 
			
		||||
app.hostport2=
 | 
			
		||||
app.discordtoken=
 | 
			
		||||
app.interval_days=4
 | 
			
		||||
app.string_count=14000
 | 
			
		||||
app.thread_count=4
 | 
			
		||||
app.interval_days_minus=4
 | 
			
		||||
@ -7,6 +7,9 @@ package DataLayer;
 | 
			
		||||
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
import java.io.FileInputStream;
 | 
			
		||||
import java.io.FileNotFoundException;
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import java.sql.Connection;
 | 
			
		||||
import java.sql.PreparedStatement;
 | 
			
		||||
import java.sql.ResultSet;
 | 
			
		||||
@ -25,10 +28,20 @@ public class DataMapper {
 | 
			
		||||
        PreparedStatement l_pStatement = null;
 | 
			
		||||
        ResultSet l_rsSearch = null;
 | 
			
		||||
        ArrayList<String> arrayListStr = new ArrayList();
 | 
			
		||||
        Properties prop = new Properties();
 | 
			
		||||
        String fileName = "app.config";
 | 
			
		||||
        try (FileInputStream fis = new FileInputStream(fileName)) {
 | 
			
		||||
            prop.load(fis);
 | 
			
		||||
        } catch (FileNotFoundException ex) {
 | 
			
		||||
        } catch (IOException ex) {
 | 
			
		||||
        }
 | 
			
		||||
        try {
 | 
			
		||||
            l_cCon = DBCPDataSource.getConnection();
 | 
			
		||||
            //not better, just forces the responds to variate a lot more
 | 
			
		||||
            String l_sSQL = "SELECT * FROM Sentences where last_used < CURRENT_DATE() - INTERVAL 5 DAY order by LENGTH(Strings) desc";
 | 
			
		||||
            String l_sSQL = "SELECT * FROM `Sentences` where last_used < CURRENT_DATE() - INTERVAL "
 | 
			
		||||
                    + String.valueOf(prop.getProperty("app.interval_days"))
 | 
			
		||||
                    + " DAY order by LENGTH(Strings) desc";
 | 
			
		||||
            //System.out.println("l_sSQL: " + l_sSQL);
 | 
			
		||||
            l_pStatement = l_cCon.prepareStatement(l_sSQL);
 | 
			
		||||
            l_rsSearch = l_pStatement.executeQuery();
 | 
			
		||||
            while (l_rsSearch.next()) {
 | 
			
		||||
@ -46,11 +59,20 @@ public class DataMapper {
 | 
			
		||||
        Connection l_cCon = null;
 | 
			
		||||
        PreparedStatement l_pStatement = null;
 | 
			
		||||
        ResultSet l_rsSearch = null;
 | 
			
		||||
        String l_sSQL = "INSERT IGNORE `Sentences` (`Strings`) VALUES (?)";
 | 
			
		||||
        Properties prop = new Properties();
 | 
			
		||||
        String fileName = "app.config";
 | 
			
		||||
        try (FileInputStream fis = new FileInputStream(fileName)) {
 | 
			
		||||
            prop.load(fis);
 | 
			
		||||
        } catch (FileNotFoundException ex) {
 | 
			
		||||
        } catch (IOException ex) {
 | 
			
		||||
        }
 | 
			
		||||
        String l_sSQL = "INSERT IGNORE `Sentences` (`Strings`, `last_used`) VALUES (?, DATE(NOW()) - interval " +
 | 
			
		||||
                String.valueOf(prop.getProperty("app.interval_days_minus")) + " DAY)";
 | 
			
		||||
        try {
 | 
			
		||||
            l_cCon = DBCPDataSource.getConnection();
 | 
			
		||||
            l_pStatement = l_cCon.prepareStatement(l_sSQL);
 | 
			
		||||
            l_pStatement.setString(1, str);
 | 
			
		||||
 | 
			
		||||
            l_pStatement.execute();
 | 
			
		||||
        } catch (SQLException throwables) {
 | 
			
		||||
            throwables.printStackTrace();
 | 
			
		||||
@ -85,6 +107,13 @@ public class DataMapper {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void checkStringsToDelete() {
 | 
			
		||||
        Properties prop = new Properties();
 | 
			
		||||
        String fileName = "app.config";
 | 
			
		||||
        try (FileInputStream fis = new FileInputStream(fileName)) {
 | 
			
		||||
            prop.load(fis);
 | 
			
		||||
        } catch (FileNotFoundException ex) {
 | 
			
		||||
        } catch (IOException ex) {
 | 
			
		||||
        }
 | 
			
		||||
        PreparedStatement l_pStatement = null;
 | 
			
		||||
        ResultSet l_rsSearch = null;
 | 
			
		||||
        String CountSQL = "select count(*) from Sentences";
 | 
			
		||||
@ -94,7 +123,7 @@ public class DataMapper {
 | 
			
		||||
            ResultSet resultSet = l_pStatement.executeQuery();
 | 
			
		||||
            if (resultSet.next()) {
 | 
			
		||||
                int count = resultSet.getInt(1);
 | 
			
		||||
                if (count > 8000) {
 | 
			
		||||
                if (count > Integer.valueOf(prop.getProperty("app.string_count"))) {
 | 
			
		||||
                    //System.out.println("cleaning strings: " + l_sSQL);
 | 
			
		||||
                    l_pStatement = l_cCon.prepareStatement(l_sSQL);
 | 
			
		||||
                    l_pStatement.executeUpdate();
 | 
			
		||||
 | 
			
		||||
@ -19,6 +19,9 @@ import edu.stanford.nlp.trees.*;
 | 
			
		||||
import edu.stanford.nlp.util.CoreMap;
 | 
			
		||||
import org.ejml.simple.SimpleMatrix;
 | 
			
		||||
 | 
			
		||||
import java.io.FileInputStream;
 | 
			
		||||
import java.io.FileNotFoundException;
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import java.util.*;
 | 
			
		||||
import java.util.concurrent.*;
 | 
			
		||||
import java.util.regex.Matcher;
 | 
			
		||||
@ -27,6 +30,8 @@ import java.util.regex.Pattern;
 | 
			
		||||
 | 
			
		||||
public class Datahandler {
 | 
			
		||||
 | 
			
		||||
    //wanted to put this in config too but welp cant be arsed to set this up differently.
 | 
			
		||||
    //4 threads for the rest of eternity it is.
 | 
			
		||||
    private ExecutorService pool = Executors.newFixedThreadPool(4);
 | 
			
		||||
    private CompletionService completionService = new ExecutorCompletionService(pool);
 | 
			
		||||
    private HashMap<String, Annotation> pipelineAnnotationCache;
 | 
			
		||||
@ -720,16 +725,30 @@ public class Datahandler {
 | 
			
		||||
            } catch (InterruptedException e) {
 | 
			
		||||
                //throw new RuntimeException(e);
 | 
			
		||||
                pending = 0;
 | 
			
		||||
                Properties prop = new Properties();
 | 
			
		||||
                String fileName = "app.config";
 | 
			
		||||
                try (FileInputStream fis = new FileInputStream(fileName)) {
 | 
			
		||||
                    prop.load(fis);
 | 
			
		||||
                } catch (FileNotFoundException ex) {
 | 
			
		||||
                } catch (IOException ex) {
 | 
			
		||||
                }
 | 
			
		||||
                System.out.printf(Arrays.toString(e.getStackTrace()));
 | 
			
		||||
                pool.shutdown();
 | 
			
		||||
                pool = Executors.newFixedThreadPool(4);
 | 
			
		||||
                pool = Executors.newFixedThreadPool(Integer.valueOf(prop.getProperty("app.thread_count")));
 | 
			
		||||
                completionService = new ExecutorCompletionService(pool);
 | 
			
		||||
            } catch (ExecutionException e) {
 | 
			
		||||
                //throw new RuntimeException(e);
 | 
			
		||||
                pending = 0;
 | 
			
		||||
                Properties prop = new Properties();
 | 
			
		||||
                String fileName = "app.config";
 | 
			
		||||
                try (FileInputStream fis = new FileInputStream(fileName)) {
 | 
			
		||||
                    prop.load(fis);
 | 
			
		||||
                } catch (FileNotFoundException ex) {
 | 
			
		||||
                } catch (IOException ex) {
 | 
			
		||||
                }
 | 
			
		||||
                System.out.printf(Arrays.toString(e.getStackTrace()));
 | 
			
		||||
                pool.shutdown();
 | 
			
		||||
                pool = Executors.newFixedThreadPool(4);
 | 
			
		||||
                pool = Executors.newFixedThreadPool(Integer.valueOf(prop.getProperty("app.thread_count")));
 | 
			
		||||
                completionService = new ExecutorCompletionService(pool);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -115,7 +115,6 @@ public class DiscordHandler extends ListenerAdapter {
 | 
			
		||||
                } catch (Exception e) {
 | 
			
		||||
                    e.printStackTrace();
 | 
			
		||||
                    System.exit(1);
 | 
			
		||||
                        //the JDA library wants to keep the program alive even when an error is happening. hopefully this just makes the program crash when an error happens.
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -15,9 +15,6 @@
 | 
			
		||||
 | 
			
		||||
	pip3 install pyvirtualdisplay pillow EasyProcess #needed for virtual display, create it inside a venv
 | 
			
		||||
 | 
			
		||||
    2023, instead of steam using flatpak steam
 | 
			
		||||
    https://flatpak.org/setup/Debian
 | 
			
		||||
    https://flathub.org/apps/details/com.valvesoftware.Steam
 | 
			
		||||
 | 
			
		||||
    #NOTICE: steam might not be able to launch in case of the tmpfs /dev/shm filesystem being full. it seems safe to just delete u1001-Shm_* files and u1002-Shm_ files. It should be fine because the files exists as long as at least one process has them open. So until steam is killed i assume. You dont need to be root for killing them, the user running the bot has permissions to rm the files
 | 
			
		||||
 | 
			
		||||
@ -26,6 +23,13 @@
 | 
			
		||||
	apt-get remove xserver-xorg-video-intel
 | 
			
		||||
 | 
			
		||||
	#fonts
 | 
			
		||||
    #remember to check locally if font is available.
 | 
			
		||||
    #on arch based distributions: xorg-fonts-misc
 | 
			
		||||
 | 
			
		||||
    #probably good idea to symlink the download folder
 | 
			
		||||
    ln -s /home/autismbot1/.steam/debian-installation/steamapps/common/Counter-Strike\ Source/cstrike/download /home/autismbot2/.steam/debian-installation/steamapps/common/Counter-Strike\ Source/cstrike/download
 | 
			
		||||
    chmod g+x /home/user1
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	dpkg-reconfigure locales
 | 
			
		||||
 | 
			
		||||
@ -52,9 +56,7 @@
 | 
			
		||||
        echo 'SDL_VIDEO_X11_VISUALID: ' $SDL_VIDEO_X11_VISUALID
 | 
			
		||||
        export SDL_VIDEO_X11_VISUALID=0x205
 | 
			
		||||
        echo 'SDL_VIDEO_X11_VISUALID: ' $SDL_VIDEO_X11_VISUALID
 | 
			
		||||
        #use this one to launch steam minimized once
 | 
			
		||||
        #flatpak run com.valvesoftware.Steam -no-browser +open steam://open/minigameslist
 | 
			
		||||
        /home/$USER/.var/app/com.valvesoftware.Steam/data/Steam/steam.sh -applaunch 240 -textmode -novid -nosound -noipx -nojoy -noshaderapi
 | 
			
		||||
        /home/$USER/.steam/debian-installation/steam.sh -applaunch 240 -textmode -novid -nosound -noipx -nojoy -noshaderapi
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user