This commit is contained in:
pancakes 2024-02-22 14:14:43 +10:00
parent 129bfcf8dc
commit 26f0411b66

14
bot.py
View file

@ -107,11 +107,17 @@ if post == None:
match config.type: match config.type:
case "danbooru": case "danbooru":
filename = f'{post["md5"]}.{post["file_ext"]}' characters = post.get("tag_string_character") or ""
filename = f'image.{post["file_ext"]}'
post_url = config.url + "/posts/" + str(post["id"])
case "gelbooru": case "gelbooru":
characters = ""
filename = post["image"] filename = post["image"]
post_url = "https://gelbooru.com/index.php?page=post&s=view&id=" + str(post["id"])
case _: case _:
characters = ""
filename = "img.png" filename = "img.png"
post_url = ""
print(post) print(post)
@ -148,9 +154,9 @@ post_content = [
random.choice(config.text_filler), random.choice(config.text_filler),
"\n\n", "\n\n",
"Artist: " + post["tag_string_artist"] + "\n" if config.type == "danbooru" and len(post["tag_string_artist"]) > 0 else "", "Artist: " + post["tag_string_artist"] + "\n" if config.type == "danbooru" and len(post["tag_string_artist"]) > 0 else "",
"Score: " + str(post["score"]) + "\n", "Characters: " + characters + "\n" if characters != "" else "",
"Source: " + post["source"] + "\n\n" if len(post["source"]) > 0 else "", "Source: " + post["source"] if len(post["source"]) > 0 else "",
"\n\n" + post["url"] if config.type == "danbooru" else "" "\n\n" + post_url if post_url != "" else ""
] ]
mastodon = Mastodon(access_token=f"auth/{argv[1]}.auth.secret") mastodon = Mastodon(access_token=f"auth/{argv[1]}.auth.secret")