dragon-bot/app/animals.py

65 lines
1.4 KiB
Python

import random
import requests
import get_from_reddit
def get_red_panda():
red_panda = None
while not red_panda:
red_panda = requests.get('https://some-random-api.ml/img/red_panda').json()['link']
# if 'mp4' in red_panda[-3:]:
# red_panda = None
return red_panda
def get_dog():
return random.choice([random_sheeb, random_dog, random_dog_reddit])()
def get_birb():
return random.choice([random_bird, random_bird_reddit])()
def random_sheeb():
return requests.get(
'http://shibe.online/api/shibes?count=1&urls=true'
).text.split('"')[1]
def random_dog():
dog_url = None
while not dog_url:
dog_url = requests.get('https://dog.ceo/api/breeds/image/random').json()['message']
return dog_url
def random_bird():
bird = None
while not bird:
bird = requests.get('https://some-random-api.ml/img/birb').json()['link']
if 'mp4' in bird[-3:]:
bird = None
return bird
def random_dog_reddit():
return get_from_reddit.get_image(
[
'AustralianCattleDog',
'GSP',
'corgi',
'dogpictures',
'rarepuppers',
'tippytaps',
'vizsla',
'zoomies',
]
)
def random_bird_reddit():
return get_from_reddit.get_image(
[
'birbs',
]
)
def get_rat():
return get_from_reddit.get_image('rats')