changed to long polling

This commit is contained in:
mrbesen 2019-05-20 19:36:37 +02:00
parent 7713dcf56f
commit 080b14a4a0
Signed by untrusted user: MrBesen
GPG Key ID: 596B2350DCD67504
1 changed files with 6 additions and 5 deletions

View File

@ -28,7 +28,7 @@ public class Main implements JSONCommandHandler {
private static Main main; private static Main main;
private boolean startcrawler = true; private boolean startcrawler = true;
private Crawler cra; private Crawler cra;
private Thread crawlerthread; private Thread maincrawlerthread;
public static Main getMain() { public static Main getMain() {
return main; return main;
@ -62,9 +62,9 @@ public class Main implements JSONCommandHandler {
//starting crawler //starting crawler
cra = new Crawler(); cra = new Crawler();
crawlerthread = new Thread(cra, "Crawler"); maincrawlerthread = new Thread(cra, "Crawler");
if(startcrawler) { if(startcrawler) {
crawlerthread.start(); maincrawlerthread.start();
} }
//starting BOT API //starting BOT API
@ -72,7 +72,8 @@ public class Main implements JSONCommandHandler {
tapi.getCommandManager().registerCommand( this); tapi.getCommandManager().registerCommand( this);
tapi.getEventManager().registerEvent(UserSendMessageEvent.class, this::onAdmin); tapi.getEventManager().registerEvent(UserSendMessageEvent.class, this::onAdmin);
tapi.setHelpText("Send the command /random to get a random video."); tapi.setHelpText("Send the command /random to get a random video.");
tapi.setUpdateInterval(2000); tapi.setUpdateInterval(60);
tapi.setLongpolling(true);
tapi.setLog(new Log4JLog()); tapi.setLog(new Log4JLog());
tapi.start(); tapi.start();
@ -97,7 +98,7 @@ public class Main implements JSONCommandHandler {
//CLI //CLI
Scanner s = new Scanner(System.in); Scanner s = new Scanner(System.in);
String in; String in;
while((in= s.nextLine()) != null && crawlerthread.isAlive()) { while((in = s.nextLine()) != null && maincrawlerthread.isAlive()) {
if(in.equalsIgnoreCase("stop")) { if(in.equalsIgnoreCase("stop")) {
stop(); stop();
} else if(in.equalsIgnoreCase("add")) { } else if(in.equalsIgnoreCase("add")) {