dragon-bot/app/lewds.py

102 lines
2.3 KiB
Python

import random
import requests
from pybooru import Danbooru
def get_from_danbooru():
"""
get_from_danbooru()
returns a URL to an image on danbooru that matches a random tag
defined in the tag_list list
"""
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'])
def get_from_reddit():
"""
get_from_reddit()
returns a URL to an image on reddit from a random board in the boards list
as long as it is hosted on one of the domains in the domains list
"""
boards = [
'2Booty',
'bakunyuu_hentai',
'ecchi',
'hentai',
'rule34',
'WesternHentai',
]
domains = [
'my.mixtape.moe',
'i.imgur.com',
'imgur.com',
'i.redd.it',
]
response = requests.get(
"https://reddit.com/r/{}.json?limit=500".format(random.choice(boards)),
headers = {'User-agent':'discord dragon-bot'}
).json()['data']['children']
image_urls = list(filter(lambda x: x['data']['domain'] in domains, response))
return random.choice(image_urls)['data']['url'].replace('http://', 'https://')
def get_lewd(channel_name):
if 'nsfw' in channel_name:
return random.choice([get_from_reddit, get_from_danbooru])()
return 'You can only use this command in NSFW channels'