Skip to content

Commit

Permalink
提示 BTN 模块需要重启
Browse files Browse the repository at this point in the history
  • Loading branch information
Ghost-chu committed Nov 5, 2024
1 parent 18846f9 commit 64dc987
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,12 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;

import static com.ghostchu.peerbanhelper.text.TextManager.tl;
import static com.ghostchu.peerbanhelper.text.TextManager.tlUI;
Expand Down Expand Up @@ -91,11 +87,17 @@ public void onEnable() {
}

private void status(Context context) {
Map<String, Object> info = new HashMap<>();
if (btnNetwork == null) {
info.put("configSuccess", false);
info.put("appId", "N/A");
info.put("appSecret", "N/A");
info.put("abilities", Collections.emptyList());
info.put("configUrl", tl(locale(context), Lang.BTN_SERVICES_NEED_RESTART));
context.json(new StdResp(false, tl(locale(context), Lang.BTN_NOT_ENABLE_AND_REQUIRE_RESTART), null));
return;
}
Map<String, Object> info = new HashMap<>();

info.put("configSuccess", btnNetwork.getConfigSuccess());
var abilities = new ArrayList<>();
for (Map.Entry<Class<? extends BtnAbility>, BtnAbility> entry : btnNetwork.getAbilities().entrySet()) {
Expand Down
16 changes: 14 additions & 2 deletions src/main/java/com/ghostchu/peerbanhelper/text/Lang.java
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,20 @@ public enum Lang {
MODULE_AMM_TRAFFIC_MONITORING_TRAFFIC_ALERT_TITLE,
MODULE_AMM_TRAFFIC_MONITORING_TRAFFIC_ALERT_DESCRIPTION,
DOWNLOADER_ALERT_TOO_MANY_FAILED_ATTEMPT_TITLE,
DOWNLOADER_ALERT_TOO_MANY_FAILED_ATTEMPT_DESCRIPTION, DOWNLOADER_ALERT_TOO_MANY_FAILED_ATTEMPT_DESCRIPTION_FALLBACK, PROGRAM_OUT_OF_MEMORY_TITLE, PROGRAM_OUT_OF_MEMORY_DESCRIPTION, BAN_PEER_EXCEPTION,
PUSH_PROVIDER_TEST_TITLE, PUSH_PROVIDER_TEST_DESCRIPTION, PUSH_PROVIDER_TEST_SUCCESS, PUSH_PROVIDER_TEST_FAILED, PUSH_PROVIDER_TEST_ERROR, EXPRESS_RULE_ENGINE_DISALLOW_UNSAFE_SOURCE_ACCESS, BTN_RULES_SCRIPT_COMPILING, BTN_RULES_SCRIPT_COMPILED;
DOWNLOADER_ALERT_TOO_MANY_FAILED_ATTEMPT_DESCRIPTION,
DOWNLOADER_ALERT_TOO_MANY_FAILED_ATTEMPT_DESCRIPTION_FALLBACK,
PROGRAM_OUT_OF_MEMORY_TITLE,
PROGRAM_OUT_OF_MEMORY_DESCRIPTION,
BAN_PEER_EXCEPTION,
PUSH_PROVIDER_TEST_TITLE,
PUSH_PROVIDER_TEST_DESCRIPTION,
PUSH_PROVIDER_TEST_SUCCESS,
PUSH_PROVIDER_TEST_FAILED,
PUSH_PROVIDER_TEST_ERROR,
EXPRESS_RULE_ENGINE_DISALLOW_UNSAFE_SOURCE_ACCESS,
BTN_RULES_SCRIPT_COMPILING,
BTN_RULES_SCRIPT_COMPILED,
BTN_SERVICES_NEED_RESTART;

public String getKey() {
return name();
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/lang/en_us/messages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -483,3 +483,4 @@ EXPRESS_RULE_ENGINE_DISALLOW_UNSAFE_SOURCE_ACCESS: "For security reason, create
EXPRESS_RULE_ENGINE_SAVED: "Script saved"
BTN_RULES_SCRIPT_COMPILING: "Compiling the scripts from BTN server, this may take a while..."
BTN_RULES_SCRIPT_COMPILED: "Compiled {} scripts, took {}ms"
BTN_SERVICES_NEED_RESTART: "BTN Service Unavailable: Restart PeerBanHelper is required for loading BTN module and apply changes."
1 change: 1 addition & 0 deletions src/main/resources/lang/messages_fallback.yml
Original file line number Diff line number Diff line change
Expand Up @@ -481,3 +481,4 @@ EXPRESS_RULE_ENGINE_DISALLOW_UNSAFE_SOURCE_ACCESS: "因安全原因,不允许
EXPRESS_RULE_ENGINE_SAVED: "脚本已保存"
BTN_RULES_SCRIPT_COMPILING: "正在编译来自 BTN 服务器的可编程脚本,请稍等,这可能需要一点时间……"
BTN_RULES_SCRIPT_COMPILED: "已成功编译 {} 个脚本,用时 {}ms"
BTN_SERVICES_NEED_RESTART: "BTN 服务不可用:需要重启 PeerBanHelper 以加载 BTN 模块并应用更改"
1 change: 1 addition & 0 deletions src/main/resources/lang/zh_cn/messages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -481,3 +481,4 @@ EXPRESS_RULE_ENGINE_DISALLOW_UNSAFE_SOURCE_ACCESS: "因安全原因,不允许
EXPRESS_RULE_ENGINE_SAVED: "脚本已保存"
BTN_RULES_SCRIPT_COMPILING: "正在编译来自 BTN 服务器的可编程脚本,请稍等,这可能需要一点时间……"
BTN_RULES_SCRIPT_COMPILED: "已成功编译 {} 个脚本,用时 {}ms"
BTN_SERVICES_NEED_RESTART: "BTN 服务不可用:需要重启 PeerBanHelper 以加载 BTN 模块并应用更改"

0 comments on commit 64dc987

Please sign in to comment.