Remove bad words from the danbooru search. Fixes #24

This commit is contained in:
Luke Robles 2017-08-23 20:31:45 -07:00
parent 534301ebec
commit 895dbb345d
5 changed files with 9 additions and 59 deletions

View File

@ -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

View File

@ -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

View File

@ -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" && \

View File

@ -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:

View File

@ -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)