Browse Source

Bissel debug

pull/2/head
Paul Glaß 4 years ago
parent
commit
6506550d89
2 changed files with 8 additions and 8 deletions
  1. +1
    -1
      app/src/main/java/de/yannicpunktdee/yoshibot/main/YoshiBot.java
  2. +7
    -7
      app/src/main/java/de/yannicpunktdee/yoshibot/utils/SauceProvider.java

+ 1
- 1
app/src/main/java/de/yannicpunktdee/yoshibot/main/YoshiBot.java View File

@ -197,7 +197,7 @@ public final class YoshiBot {
}
public boolean sayTTS(String text, VoiceChannel vc) {
String path = Resources.getTempPath() + UUID.randomUUID().toString() + ".opus";
String path = Resources.getTempPath() + UUID.randomUUID() + ".opus";
try {
ProcessBuilder pb = new ProcessBuilder(


+ 7
- 7
app/src/main/java/de/yannicpunktdee/yoshibot/utils/SauceProvider.java View File

@ -7,7 +7,6 @@ import net.dv8tion.jda.api.entities.TextChannel;
import org.json.JSONArray;
import org.json.JSONObject;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
@ -26,16 +25,15 @@ public class SauceProvider {
private static MessageEmbed notFoundEmbed = null;
public SauceProvider(int timer) {
this();
lastKnownSauce = this.getNewestIndex();
ScheduledExecutorService sauceScheduler = Executors.newScheduledThreadPool(1);
sauceScheduler.scheduleAtFixedRate(this::provideSauce, 0, timer, TimeUnit.SECONDS);
new Thread(this::initSauceProviding).start();
}
public SauceProvider() {
if (lastKnownSauce == -1) {
this.lastKnownSauce = this.getNewestIndex();
}
public SauceProvider(int timer, int lastKnownSauce) {
this(timer);
this.lastKnownSauce = lastKnownSauce;
}
public static MessageEmbed getSauce(int index) {
@ -131,7 +129,9 @@ public class SauceProvider {
private int getNewestIndex() {
JSONObject result = getParsedSauceData("https://r34-json.herokuapp.com/posts?limit=1&q=index");
return result.getJSONArray("posts").getJSONObject(0).getInt("id");
int id = result.getJSONArray("posts").getJSONObject(0).getInt("id");
Logger.logDebug("Neuste Soßen-ID: " + id);
return id;
}
private static JSONObject getParsedSauceData(String url) {


Loading…
Cancel
Save