Skip to content
This repository has been archived by the owner on Aug 12, 2021. It is now read-only.

Commit

Permalink
Added backup systems and final tweaks for code
Browse files Browse the repository at this point in the history
  • Loading branch information
doomsdayrs committed May 12, 2019
1 parent e1334e3 commit 9c6a8f9
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 7 deletions.
25 changes: 25 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<groupId>com.github.doomsdayrs</groupId>
<artifactId>TodayInSocialismBot</artifactId>
<version>1.0.0</version>

<build>
<plugins>
<plugin>
Expand All @@ -17,8 +18,32 @@
<target>8</target>
</configuration>
</plugin>

<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.github.doomsdayrs.TodayInSocialism.core.Core</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

<repositories>
<repository>
<id>jitpack.io</id>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.doomsdayrs.TodayInSocialism.command;

import com.github.doomsdayrs.TodayInSocialism.core.Core;
import com.github.doomsdayrs.TodayInSocialism.core.Version;
import com.github.doomsdayrs.TodayInSocialism.support.Embeds;
import com.github.doomsdayrs.TodayInSocialism.support.EventLoader;
Expand Down Expand Up @@ -126,6 +127,7 @@ public void onDLCommand(TextChannel channel, User user) {
try {
EventLoader.downloadLatest();
System.out.println("Downloaded latest");
channel.sendMessage(Embeds.message("Downloaded latest"));
} catch (IOException | ParseException e) {
e.printStackTrace();
}
Expand All @@ -135,6 +137,18 @@ public void onDLCommand(TextChannel channel, User user) {
}
}

@Command(aliases = {"restartThread", "rt"}, showInHelpPage = false)
public void onRestartThreadCommand(TextChannel channel, User user) {
Logs.logCommand(channel, user, "restartThread");
String ID = user.getIdAsString();
if (ID.equals("244481558831038464")) {
Core.resetEvent();
} else {
channel.sendMessage(Embeds.message("You aren't my creator silly!"));
}
}


@Command(aliases = {"tA"}, showInHelpPage = false)
public void onTAommand(TextChannel channel, User user) {
Logs.logCommand(channel, user, "tA");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.io.IOException;
import java.sql.SQLException;
import java.util.concurrent.TimeUnit;

/**
* This file is part of TodayInSocialismBot.
Expand All @@ -41,7 +42,7 @@
public class Core {
private static DiscordApi API;
private static boolean debug = false;

private static Thread eventNotify;
public static void main(String[] args) {
for (String string : args) if (string.equalsIgnoreCase("-debug")) debug = true;

Expand Down Expand Up @@ -94,8 +95,55 @@ public static void main(String[] args) {
}
});
System.out.println(API.createBotInvite(new PermissionsBuilder().setAllowed(PermissionType.SEND_MESSAGES, PermissionType.READ_MESSAGES, PermissionType.ATTACH_FILE, PermissionType.EMBED_LINKS).build()));
while (true) {

}
Thread SQLStoring = new Thread(() -> {
while (true) {
try {
TimeUnit.HOURS.sleep(1);
} catch (InterruptedException e) {
e.printStackTrace();
}
try {
SQL.toHard();
} catch (IOException e) {
e.printStackTrace();
}
}
});
SQLStoring.start();
Thread SQLBackup = new Thread(() -> {
while (true) {
try {
TimeUnit.HOURS.sleep(6);
} catch (InterruptedException e) {
e.printStackTrace();
}
try {
SQL.backup();
} catch (IOException e) {
e.printStackTrace();
}
}
});
SQLBackup.start();
resetEvent();
}

public static void resetEvent() {
eventNotify = null;
eventNotify = new Thread(() -> {
while (true) {
System.out.println("Checking");
try {
SQLControl.announce(API);
} catch (SQLException | ParseException e) {
}
try {
TimeUnit.HOURS.sleep(1);
} catch (InterruptedException e) {
}
}
});
eventNotify.start();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
* @author github.com/doomsdayrs
*/
public class Version {
public static String VersionNum = "0.1.1-beta";
public static String changeLog = "*Created other supporting classes" +
"\n*TODO list is still there" +
"\n*2 new commands";
public static String VersionNum = "1.0.0";
public static String changeLog = "*Completed and rolled out";
}
3 changes: 3 additions & 0 deletions src/main/resources/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: com.github.doomsdayrs.TodayInSocialism.core.Core

0 comments on commit 9c6a8f9

Please sign in to comment.