From be8bdf8c0d8e1e0aaac4f7b42fdb0d6334406207 Mon Sep 17 00:00:00 2001 From: DreamOneX Date: Mon, 1 Aug 2022 15:02:09 +0800 Subject: [PATCH] fix(handler): check http status code --- .../dreamonex/mirai/httpcat/handlers/MessageHandler.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/com/github/dreamonex/mirai/httpcat/handlers/MessageHandler.java b/src/main/java/com/github/dreamonex/mirai/httpcat/handlers/MessageHandler.java index dac4eb2..37c5a2f 100644 --- a/src/main/java/com/github/dreamonex/mirai/httpcat/handlers/MessageHandler.java +++ b/src/main/java/com/github/dreamonex/mirai/httpcat/handlers/MessageHandler.java @@ -54,6 +54,13 @@ public void run() { InputStream stream; try (Response response = client.newCall(request).execute()) { stream = response.body().byteStream(); + if (response.code() != 404) { + target.sendMessage("404 Not Found"); + return; + } else if (response.code() != 200) { + target.sendMessage("奇怪的错误,检查你的url"); + return; + } ExternalResource res = ExternalResource .create(stream); Image image = target.uploadImage(res);