Compare commits
2 Commits
e451ea04ff
...
c9ee99fd8b
Author | SHA1 | Date |
---|---|---|
![]() |
c9ee99fd8b | |
![]() |
f6778e6ee1 |
|
@ -2,13 +2,24 @@ package linux.general.hackyquizbot;
|
|||
|
||||
import org.javacord.api.DiscordApi;
|
||||
import org.javacord.api.DiscordApiBuilder;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Main {
|
||||
public class Main{
|
||||
|
||||
public static void main(String[] args) {
|
||||
// Insert your bot's token here
|
||||
String token = args[0];
|
||||
|
||||
//String token = args[0];
|
||||
|
||||
CheckDeploy check = new CheckDeploy(3000, "/home/milan/test.txt");
|
||||
check.start();
|
||||
|
||||
while(true) {
|
||||
System.out.println("Woo!");
|
||||
}
|
||||
|
||||
/*
|
||||
DiscordApi api = new DiscordApiBuilder().setToken(token).login().join();
|
||||
|
||||
// Add a listener which answers with "Pong!" if someone writes "!ping"
|
||||
|
@ -20,6 +31,52 @@ public class Main {
|
|||
|
||||
// Print the invite url of your bot
|
||||
System.out.println("You can invite the bot by using the following url: " + api.createBotInvite());
|
||||
*/
|
||||
}
|
||||
|
||||
public static class CheckDeploy extends Thread{
|
||||
private int interval;
|
||||
private String id;
|
||||
private String filename;
|
||||
|
||||
public CheckDeploy(int interval, String filename) {
|
||||
this.interval = interval;
|
||||
this.filename = filename;
|
||||
}
|
||||
|
||||
public String grabId() {
|
||||
File file = new File(this.filename);
|
||||
Scanner reader;
|
||||
String id = new String();
|
||||
|
||||
try {
|
||||
reader = new Scanner(file);
|
||||
while(reader.hasNextLine()) {
|
||||
id = reader.nextLine();
|
||||
}
|
||||
reader.close();
|
||||
}catch (FileNotFoundException e) {
|
||||
System.err.println("File not found");
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
this.id = this.grabId(); //replace with correct filename
|
||||
while(true) {
|
||||
String new_id = this.grabId();
|
||||
|
||||
if(!new_id.equals(this.id)) {
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
try {
|
||||
sleep(this.interval);
|
||||
}catch (Exception e) {
|
||||
System.err.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue