diff --git a/DanbooruApi.own b/DanbooruApi.own index fee2373..0d0cd9b 100644 --- a/DanbooruApi.own +++ b/DanbooruApi.own @@ -1,6 +1,7 @@ use okhttp, types, json, functional URL = "https://danbooru.donmai.us/posts" +NO_IMAGE = "https://upload.wikimedia.org/wikipedia/commons/1/14/No_Image_Available.jpg" class DanbooruApi { @@ -68,12 +69,12 @@ class Post { def getImageUrl() { fileSize = this.post.file_size ?? 0 if (fileSize >= 9500000) { - return this.post.large_file_url + return this.post.large_file_url ?? NO_IMAGE } - return this.post.file_url + return this.post.file_url ?? NO_IMAGE } - def getSampleImageUrl() = this.post.large_file_url + def getSampleImageUrl() = this.post.large_file_url ?? NO_IMAGE def containsTags(tags) = stream(tags) .anyMatch(def(t) = arrayKeyExists(t, this.tags)) diff --git a/bot.own b/bot.own index cfb085e..a290439 100644 --- a/bot.own +++ b/bot.own @@ -56,7 +56,7 @@ def processPost(id, chatId, msgId, from) { ]}) bot.invoke("sendPhoto", { "chat_id": chatId, - "photo": post.getImageUrl(), + "photo": post.getImageUrl() "parse_mode": "html", "caption": caption, "reply_markup": markup @@ -68,7 +68,7 @@ def processPost(id, chatId, msgId, from) { if !r.contains("wrong file identifier") return 1 bot.invoke("sendPhoto", { "chat_id": chatId, - "photo": post.getSampleImageUrl(), + "photo": post.getSampleImageUrl() "parse_mode": "html", "caption": "small " + caption, "reply_markup": markup