Compare commits
	
		
			8 Commits 
		
	
	
		
			0d9de0c289
			...
			ce026ac1d3
		
	
	| Author | SHA1 | Date | 
|---|---|---|
|  BodgeMaster | ce026ac1d3 | |
|  BodgeMaster | 7ed5d26a75 | |
|  Shwoomple | 97f8b2bc7a | |
|  Shwoomple | 66d7594744 | |
|  Shwoomple | c9ee99fd8b | |
|  Shwoomple | f6778e6ee1 | |
|  Shwoomple | e451ea04ff | |
|  Shwoomple | 7c610972fd | 
|  | @ -6,6 +6,7 @@ $(date "+%Y-%m-%d %I:%M:%S%p UTC%:z") | ||||||
| 
 | 
 | ||||||
| # build the thing into a big jar with all the dependencies | # build the thing into a big jar with all the dependencies | ||||||
| mvn clean compile assembly:single | mvn clean compile assembly:single | ||||||
|  | dd if=/dev/urandom bs=1 count=20 | base64 > id.txt | ||||||
| # TODO: Somehow tell a service that manages the bot to shut it down and replace it with the updated version? | # TODO: Somehow tell a service that manages the bot to shut it down and replace it with the updated version? | ||||||
| 
 | 
 | ||||||
| echo "================================================================================ | echo "================================================================================ | ||||||
|  |  | ||||||
|  | @ -2,6 +2,9 @@ package linux.general.hackyquizbot; | ||||||
| 
 | 
 | ||||||
| import org.javacord.api.DiscordApi; | import org.javacord.api.DiscordApi; | ||||||
| import org.javacord.api.DiscordApiBuilder; | import org.javacord.api.DiscordApiBuilder; | ||||||
|  | import java.io.File; | ||||||
|  | import java.io.FileNotFoundException; | ||||||
|  | import java.util.Scanner; | ||||||
| 
 | 
 | ||||||
| public class Main{ | public class Main{ | ||||||
| 
 | 
 | ||||||
|  | @ -9,6 +12,10 @@ public class Main { | ||||||
|         // Insert your bot's token here
 |         // Insert your bot's token here
 | ||||||
|         String token = args[0]; |         String token = args[0]; | ||||||
|          |          | ||||||
|  |         CheckDeploy check = new CheckDeploy(3000, "/var/www/deployment/Hacky-Quizbot/id.txt"); | ||||||
|  |         check.start(); | ||||||
|  |          | ||||||
|  |          | ||||||
|         DiscordApi api = new DiscordApiBuilder().setToken(token).login().join(); |         DiscordApi api = new DiscordApiBuilder().setToken(token).login().join(); | ||||||
| 
 | 
 | ||||||
|         // Add a listener which answers with "Pong!" if someone writes "!ping"
 |         // Add a listener which answers with "Pong!" if someone writes "!ping"
 | ||||||
|  | @ -20,6 +27,52 @@ public class Main { | ||||||
| 
 | 
 | ||||||
|         // Print the invite url of your bot
 |         // Print the invite url of your bot
 | ||||||
|         System.out.println("You can invite the bot by using the following url: " + api.createBotInvite()); |         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