From a83930efd0fb4cacb9bb965a58d48a11643a4e15 Mon Sep 17 00:00:00 2001 From: Eyre_S Date: Sat, 12 Nov 2022 17:40:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9C=AA=E9=A2=84=E8=A7=81?= =?UTF-8?q?=20--report-to=20=E8=AE=BE=E7=BD=AE=E4=B8=BA=20-1=20=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle.properties | 2 +- .../cc/sukazyo/cono/morny/daemon/MornyReport.java | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/gradle.properties b/gradle.properties index 22b2091..798df0e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ MORNY_ARCHIVE_NAME = morny-coeur MORNY_CODE_STORE = https://github.com/Eyre-S/Coeur-Morny-Cono MORNY_COMMIT_PATH = https://github.com/Eyre-S/Coeur-Morny-Cono/commit/%s -VERSION = 1.0.0-RC1 +VERSION = 1.0.0-RC1.1 USE_DELTA = false VERSION_DELTA = diff --git a/src/main/java/cc/sukazyo/cono/morny/daemon/MornyReport.java b/src/main/java/cc/sukazyo/cono/morny/daemon/MornyReport.java index b4f7ae5..0aa990e 100644 --- a/src/main/java/cc/sukazyo/cono/morny/daemon/MornyReport.java +++ b/src/main/java/cc/sukazyo/cono/morny/daemon/MornyReport.java @@ -21,8 +21,12 @@ import static cc.sukazyo.cono.morny.util.tgapi.formatting.MsgEscape.escapeHtml; public class MornyReport { + private static boolean unsupported () { + return !MornyCoeur.available() || MornyCoeur.config().reportToChat == -1; + } + private static , R extends BaseResponse> void executeReport (@Nonnull T report) { - if (!MornyCoeur.available()) return; + if (unsupported()) return; try { MornyCoeur.extra().exec(report); } catch (EventRuntimeException.ActionFailed e) { @@ -34,7 +38,7 @@ public class MornyReport { } public static void exception (@Nonnull Exception e, @Nullable String description) { - if (!MornyCoeur.available()) return; + if (unsupported()) return; executeReport(new SendMessage( MornyCoeur.config().reportToChat, String.format(""" @@ -55,7 +59,7 @@ public class MornyReport { public static void exception (@Nonnull Exception e) { exception(e, null); } public static void unauthenticatedAction (@Nonnull String action, @Nonnull User user) { - if (!MornyCoeur.available()) return; + if (unsupported()) return; executeReport(new SendMessage( MornyCoeur.config().reportToChat, String.format(""" @@ -131,7 +135,7 @@ public class MornyReport { * 传入 {@link null} 则表示不表明原因。 */ static void onMornyExit (@Nullable Object causedBy) { - if (!MornyCoeur.available()) return; + if (unsupported()) return; String causedTag = null; if (causedBy != null) { if (causedBy instanceof User)