Add support for unlisted posts
This commit is contained in:
parent
dfe485d2c6
commit
8d7393e344
@ -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))
|
||||
|
4
bot.own
4
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
|
||||
|
Loading…
Reference in New Issue
Block a user