Skip to content

Commit

Permalink
Xujiayao#52: provide option to configure update messages
Browse files Browse the repository at this point in the history
  • Loading branch information
secondfry committed Jul 1, 2022
1 parent 07835da commit d8907a6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/main/java/top/xujiayao/mcdiscordchat/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ public static class Generic {
public List<String> excludedCommands = List.of("/tell");

public List<String> adminsIds = new ArrayList<>();

// NOTE(secondfry): possible values "full", "short" and "disabled".
// Empty considered to be "disabled".
public String updateMessage = "short";
}

public static class MultiServer {
Expand Down
15 changes: 13 additions & 2 deletions src/main/java/top/xujiayao/mcdiscordchat/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,11 @@ public static String checkUpdate(boolean isManualCheck) {
message.append("\n\n");
message.append(CONFIG.generic.useEngInsteadOfChin ? "Download link: https://github.com/Xujiayao/MCDiscordChat/blob/master/README.md#Download" : "下载链接:https://github.com/Xujiayao/MCDiscordChat/blob/master/README_CN.md#%E4%B8%8B%E8%BD%BD");
message.append("\n\n");
message.append(latestJson.get("changelog").getAsString());
message.append("\n\n");

if (CONFIG.generic.updateMessage.equals("full")) {
message.append(latestJson.get("changelog").getAsString());
message.append("\n\n");
}

if (CONFIG.generic.mentionAdmins) {
message.append(adminsMentionString());
Expand Down Expand Up @@ -257,6 +260,14 @@ public void run() {
}

public static void initCheckUpdateTimer() {
if (CONFIG.generic.updateMessage.isEmpty()) {
return;
}

if (CONFIG.generic.updateMessage.equals("disabled")) {
return;
}

CHECK_UPDATE_TIMER.schedule(new TimerTask() {
@Override
public void run() {
Expand Down

0 comments on commit d8907a6

Please sign in to comment.