From 54a35805b8263477256044ab4a61024387b1b93b Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Sat, 8 Aug 2020 20:56:31 -0700 Subject: [PATCH] Addding back animal functions, fixes #9 #5 #25 --- Dockerfile-test-env | 9 +++++++-- app/animals.py | 17 ++++++++--------- app/dragon-bot-updated.py | 17 +++++++++++++++++ 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/Dockerfile-test-env b/Dockerfile-test-env index f05524ab..5cb4155b 100644 --- a/Dockerfile-test-env +++ b/Dockerfile-test-env @@ -1,11 +1,16 @@ -FROM python:3.8 as builder -RUN apt-get update && apt-get install -y gcc python-pip +FROM python as builder +RUN apt-get update && apt-get install -y gcc make automake +# RUN apk update && apk add --no-cache make python3-dev automake gcc libxml2-dev libxslt-dev g++ ADD app/requirements.txt /requirements.txt RUN pip install -r requirements.txt RUN pip install pylint ADD app /app RUN printf "\n\nTesting your python code for errors\n\n" && \ pylint -E /app/*.py + +# FROM python:rc-slim-buster +# COPY --from=builder /usr/local/lib/python3.8/site-packages /usr/local/lib/python3.8/ +# ADD app /app WORKDIR /app RUN printf "\n#########################\n Run dragon bot by typing \n python dragon-bot.py\n#########################\n\n" diff --git a/app/animals.py b/app/animals.py index 0b0eefbf..3fc98819 100644 --- a/app/animals.py +++ b/app/animals.py @@ -4,6 +4,14 @@ 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])() @@ -33,15 +41,6 @@ def random_bird(): bird = None return bird -def random_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 random_dog_reddit(): return get_from_reddit.get_image( [ diff --git a/app/dragon-bot-updated.py b/app/dragon-bot-updated.py index f77c19bc..7ae09912 100644 --- a/app/dragon-bot-updated.py +++ b/app/dragon-bot-updated.py @@ -35,6 +35,23 @@ async def invite(ctx): ) await ctx.send(invite) +@bot.command(name='redpanda') +async def redpanda(ctx): + + import animals + await ctx.send(animals.get_red_panda()) + +@bot.command(name='dog') +async def dog(ctx): + + import animals + await ctx.send(animals.get_dog()) + +@bot.command(name='birb') +async def birb(ctx): + import animals + await ctx.send(animals.get_birb()) + @bot.command(name='corona') async def corona(ctx):