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

return await channel.send(embed=embed) 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. """Utility function that deals with danbooru clone api interaction.
It also deals with cache management for these interactions. It also deals with cache management for these interactions.


counter = 0 counter = 0
while counter < 20: while counter < 20:
post = random.choice(posts) post = random.choice(posts)
if sfw:
if post["rating"] == "e" or post["rating"] == "q":
continue
md5 = post.get("md5") or post.get("hash") md5 = post.get("md5") or post.get("hash")
if md5 not in cache[cache_id]: if md5 not in cache[cache_id]:
cache[cache_id].append(md5) cache[cache_id].append(md5)

Loading…
Cancel
Save