修复未预见 --report-to 设置为 -1 的问题

This commit is contained in:
A.C.Sukazyo Eyre 2022-11-12 17:40:51 +08:00
parent a863570be2
commit a83930efd0
Signed by: Eyre_S
GPG Key ID: C17CE40291207874
2 changed files with 9 additions and 5 deletions

View File

@ -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 =

View File

@ -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 <T extends BaseRequest<T, R>, 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)