Browse Source

added a sfw option to the danbooru clone function to filter out nsfw content just in case the url doesn't do this.

tags/v2.1.0
Roxie Gibson 5 years ago
parent
commit
6e91474072
1 changed files with 4 additions and 1 deletions
  1. +4
    -1
      roxbot/utils.py

+ 4
- 1
roxbot/utils.py View File

@@ -173,7 +173,7 @@ async def log(guild, command_name, **kwargs):
return await channel.send(embed=embed)


async def danbooru_clone_api_req(channel, base_url, endpoint_url, cache=None, tags="", banned_tags=""):
async def danbooru_clone_api_req(channel, base_url, endpoint_url, cache=None, tags="", banned_tags="", sfw=False):
"""Utility function that deals with danbooru clone api interaction.
It also deals with cache management for these interactions.

@@ -216,6 +216,9 @@ async def danbooru_clone_api_req(channel, base_url, endpoint_url, cache=None, ta
counter = 0
while counter < 20:
post = random.choice(posts)
if sfw:
if post["rating"] == "e" or post["rating"] == "q":
continue
md5 = post.get("md5") or post.get("hash")
if md5 not in cache[cache_id]:
cache[cache_id].append(md5)

Loading…
Cancel
Save