|
@ -39,10 +39,10 @@ public final class Resources { |
|
|
@Getter |
|
|
@Getter |
|
|
private static String patPath; |
|
|
private static String patPath; |
|
|
@Getter |
|
|
@Getter |
|
|
|
|
|
private static String patPngPath; |
|
|
|
|
|
@Getter |
|
|
private static String imagePath; |
|
|
private static String imagePath; |
|
|
|
|
|
|
|
|
private static Properties propertiesFile; |
|
|
|
|
|
|
|
|
|
|
|
@Getter |
|
|
@Getter |
|
|
private static String jda_builder_string; |
|
|
private static String jda_builder_string; |
|
|
|
|
|
|
|
@ -62,6 +62,8 @@ public final class Resources { |
|
|
@Getter |
|
|
@Getter |
|
|
private static final Map<String, List<String>> feedDetails = new HashMap<>(); |
|
|
private static final Map<String, List<String>> feedDetails = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
private static Properties propertiesFile; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public synchronized static boolean init(String resourcePathArg) { |
|
|
public synchronized static boolean init(String resourcePathArg) { |
|
|
boolean isOk = initResources(resourcePathArg); |
|
|
boolean isOk = initResources(resourcePathArg); |
|
@ -77,6 +79,7 @@ public final class Resources { |
|
|
if (isOk) isOk = initChannelRestrict(); |
|
|
if (isOk) isOk = initChannelRestrict(); |
|
|
if (isOk) isOk = initTagFilter(); |
|
|
if (isOk) isOk = initTagFilter(); |
|
|
if (isOk) isOk = initPat(); |
|
|
if (isOk) isOk = initPat(); |
|
|
|
|
|
if (isOk) isOk = initPatPngPath(); |
|
|
if (isOk) isOk = initImages(); |
|
|
if (isOk) isOk = initImages(); |
|
|
|
|
|
|
|
|
if (isOk) Logger.log("Die Konfigurationen wurden erfolgreich geladen.", Type.INFO); |
|
|
if (isOk) Logger.log("Die Konfigurationen wurden erfolgreich geladen.", Type.INFO); |
|
@ -120,12 +123,13 @@ public final class Resources { |
|
|
private static boolean initTemp() { |
|
|
private static boolean initTemp() { |
|
|
Logger.log("Versuche Temp-Verzeichnis zu finden.", Type.INFO); |
|
|
Logger.log("Versuche Temp-Verzeichnis zu finden.", Type.INFO); |
|
|
|
|
|
|
|
|
File tempDir = new File(System.getProperty("java.io.tmpdir").replace('\\', '/') + "/yoshibot/"); |
|
|
|
|
|
|
|
|
String theoreticalTempPath = System.getProperty("java.io.tmpdir").replace('\\', '/') + "/yoshibot/"; |
|
|
|
|
|
|
|
|
tempPath = verifyExists(tempDir.getAbsolutePath(), File::isDirectory); |
|
|
|
|
|
|
|
|
tempPath = verifyExists(theoreticalTempPath, File::isDirectory); |
|
|
if (tempPath != null) { |
|
|
if (tempPath != null) { |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
File tempDir = new File(theoreticalTempPath); |
|
|
|
|
|
|
|
|
if (tempDir.mkdir()) { |
|
|
if (tempDir.mkdir()) { |
|
|
return verifyExists(tempDir.getAbsolutePath(), File::isDirectory) != null; |
|
|
return verifyExists(tempDir.getAbsolutePath(), File::isDirectory) != null; |
|
@ -164,6 +168,11 @@ public final class Resources { |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static boolean initPatPngPath(){ |
|
|
|
|
|
patPngPath = verifyExists(resourcePath + "pats/", File::isDirectory); |
|
|
|
|
|
return patPngPath != null; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private static boolean initGuildId() { |
|
|
private static boolean initGuildId() { |
|
|
if (!propertiesFile.containsKey("guild_id")) { |
|
|
if (!propertiesFile.containsKey("guild_id")) { |
|
|
Logger.log("Die Config.properties benötigt das Attribut guild_id.", Type.ERROR); |
|
|
Logger.log("Die Config.properties benötigt das Attribut guild_id.", Type.ERROR); |
|
@ -248,15 +257,25 @@ public final class Resources { |
|
|
Logger.log("tags_general_filter erfolgreich geladen", Type.INFO); |
|
|
Logger.log("tags_general_filter erfolgreich geladen", Type.INFO); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private static boolean initPat(){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static boolean initPat() { |
|
|
patPath = verifyExists(resourcePath + "pat.py", File::isFile); |
|
|
patPath = verifyExists(resourcePath + "pat.py", File::isFile); |
|
|
return patPath != null; |
|
|
return patPath != null; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private static boolean initImages(){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static boolean initImages() { |
|
|
imagePath = verifyExists(resourcePath + "image/", File::isDirectory); |
|
|
imagePath = verifyExists(resourcePath + "image/", File::isDirectory); |
|
|
return imagePath != null; |
|
|
|
|
|
|
|
|
if (imagePath != null) { |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
if (new File(resourcePath + "image/").mkdir()) { |
|
|
|
|
|
imagePath = verifyExists(resourcePath + "image/", File::isDirectory); |
|
|
|
|
|
Logger.log("Bildordner erzeugt", Type.INFO); |
|
|
|
|
|
return true; |
|
|
|
|
|
} else { |
|
|
|
|
|
Logger.log("Konnte Bildordner nicht erzeugen!", Type.ERROR); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private static String verifyExists(String filename, Function<File, Boolean> checkIsValidFile) { |
|
|
private static String verifyExists(String filename, Function<File, Boolean> checkIsValidFile) { |
|
|