dragon-bot/app/lewds.py

33 lines
870 B
Python

import random
import requests
import get_from_reddit
def get_from_danbooru(boards):
"""
get_from_danbooru(boards)
returns a URL to an image on danbooru
"""
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:
boards = [
'2Booty',
'bakunyuu_hentai',
'ecchi',
'hentai',
'rule34',
'WesternHentai',
]
# This is really bad practice but pass boards to get_from_reddit AND danbooru so it doesnt error
return random.choice([get_from_reddit.get_image, get_from_danbooru])(boards=boards)
return 'You can only use this command in NSFW channels'