From 895dbb345d59c7c8deb50a7f5eca83a02585dc3e Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Wed, 23 Aug 2017 20:31:45 -0700 Subject: [PATCH] Remove bad words from the danbooru search. Fixes #24 --- .gitlab-ci.yml | 2 +- Dockerfile | 2 +- Dockerfile-test-env | 2 +- app/lewds.py | 60 ++++----------------------------------------- app/role_check.py | 2 +- 5 files changed, 9 insertions(+), 59 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5f6d2130..f7bb5601 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,7 +4,7 @@ services: before_script: - apk add --no-cache python3 - - pip3 install pylint requests discord.py docker pybooru pylint wolframalpha + - pip3 install pylint requests discord.py docker pylint wolframalpha stages: - test diff --git a/Dockerfile b/Dockerfile index cf47f1c1..f3aeb963 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM python:3.6.2-alpine3.6 LABEL name="Dragon Bot" RUN apk update && apk add --no-cache docker -RUN pip install requests discord.py docker pybooru wolframalpha +RUN pip install requests discord.py docker wolframalpha ADD app /app CMD python app/dragon-bot.py \ No newline at end of file diff --git a/Dockerfile-test-env b/Dockerfile-test-env index 4b34c49a..0f629ee9 100644 --- a/Dockerfile-test-env +++ b/Dockerfile-test-env @@ -2,7 +2,7 @@ FROM python:3.6.2-alpine3.6 LABEL name="Dragon Bot Test environment" RUN apk update && apk add --no-cache vim docker -RUN pip install requests discord.py docker pybooru pylint wolframalpha +RUN pip install requests discord.py docker pylint wolframalpha ADD app /app RUN printf "\n\nTesting your python code for errors\n\n" && \ diff --git a/app/lewds.py b/app/lewds.py index 07bc057f..48347aa1 100644 --- a/app/lewds.py +++ b/app/lewds.py @@ -2,69 +2,19 @@ import random import requests import get_from_reddit -from pybooru import Danbooru def get_from_danbooru(boards): """ get_from_danbooru(boards) - returns a URL to an image on danbooru that matches a random tag - defined in the tag_list list + returns a URL to an image on danbooru """ - booru = Danbooru('danbooru') - tag_list = [ - '1girl', - '2girls', - 'ass_visible_through_thighs', - 'bare_legs' - 'bikini', - 'black_bikini', - 'black_panties', - 'blue_eyes', - 'bra_pull', - 'bra', - 'breasts', - 'cameltoe', - 'clevage', - 'condom_in_mouth', - 'condom', - 'from_below', - 'gloves', - 'highleg_bikini', - 'highleg', - 'highres', - 'horns', - 'large_breasts', - 'leash', - 'medium_breasts' - 'miniskirt', - 'nier_automata', - 'nier', - 'nipples', - 'partially_visible_vulva', - 'pencil_skirt', - 'pussy_juice', - 'pussy', - 'skirt', - 'small_breasts', - 'thong_bikini', - 'topless', - 'wet_clothes', - 'wet_panties', - 'wet', - ] - - tag = random.choice(tag_list) - return "https://danbooru.donmai.us{}".format( - random.choice( - booru.post_list( - limit=500, - tags=tag, - random=True, - ) - )['large_file_url']) + file_path = requests.get( + 'https://danbooru.donmai.us/posts/random.json?tags=rating%3Aexplicit' + ).json()['large_file_url'] + return "https://danbooru.donmai.us{}".format(file_path) def get_lewd(channel_name): if 'nsfw' in channel_name: diff --git a/app/role_check.py b/app/role_check.py index be3ecc6f..bbb40dee 100644 --- a/app/role_check.py +++ b/app/role_check.py @@ -53,4 +53,4 @@ def cleanup_permissions(user): Who has rights to make dragon-bot purge its messages """ - return is_admin(user) or user.id == '144986109804412928' + return is_admin(user) or is_mod(user)