From 858ccb6b2adf1566ceac301a380f2322cb65bfd5 Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Tue, 1 Sep 2020 17:51:50 -0700 Subject: [PATCH] adding more methods to the new bot. fixes #4 #10 #20 #21 #22 #23 #29 --- Dockerfile-test-env | 13 ++++++------ app/bot.py | 52 +++++++++++++++++++++++++++++++++++++++++++++ test-dragon-bot.sh | 2 +- 3 files changed, 59 insertions(+), 8 deletions(-) mode change 100644 => 100755 app/bot.py diff --git a/Dockerfile-test-env b/Dockerfile-test-env index fb927dad..b3496ec9 100644 --- a/Dockerfile-test-env +++ b/Dockerfile-test-env @@ -3,12 +3,11 @@ 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 +# RUN pip install pylint +# ADD app /app +# RUN printf "\n\nTesting your python code for errors\n\n" && \ +# pylint -E /app/*.py WORKDIR /app -RUN printf "\n#########################\n Run dragon bot by typing \n python bot.py\n#########################\n\n" -RUN chmod +x /app/bot.py -CMD python /app/bot.py +# RUN printf "\n#########################\n Run dragon bot by typing \n python bot.py\n#########################\n\n" +# CMD python /app/bot.py diff --git a/app/bot.py b/app/bot.py old mode 100644 new mode 100755 index 304d42ff..0fb87352 --- a/app/bot.py +++ b/app/bot.py @@ -1,6 +1,7 @@ #!/usr/local/bin/python import os import random +import requests import discord from discord.ext import commands @@ -85,6 +86,57 @@ async def help(ctx): embed=help_methods.get_help_embed(bot) ) +@bot.command(name='wink') +async def wink(ctx): + await ctx.send( + embed=generate_embed( + embed_url=requests.get('https://some-random-api.ml/animu/wink').json()['link'] + ) + ) + +@bot.command(name='smug') +async def smug(ctx): + import get_from_reddit + await ctx.send(embed=generate_embed(embed_url=get_from_reddit.get_image('smuganimegirls'))) + +@bot.command(name='pout') +async def pout(ctx): + import get_from_reddit + await ctx.send(embed=generate_embed(embed_url=get_from_reddit.get_image('pouts'))) + + +@bot.command(name='roll') +async def roll(ctx): + import dice + await ctx.send(embed=dice.parse_message(ctx.message.content)) + +@bot.command(name='quake') +async def quake(ctx): + import quake + await ctx.send(embed=quake.parse_message(ctx.message)) + +@bot.command(name='excuse') +async def excuse(ctx): + import excuse + await ctx.send(excuse.get_excuse()) + +@bot.command(name='avatar') +async def avatar(ctx): + profile = [ctx.message.author] + if len(ctx.message.mentions): + profile = ctx.message.mentions + + # Code stolen from this reddit post + # https://www.reddit.com/r/discordapp/comments/74bb4z/retrieve_a_mentioned_users_avatar_using_discordpy + for user in profile: + await ctx.send( + embed=generate_embed( + embed_title="{}#{}".format(user.name, user.discriminator), + embed_url=str(user.avatar_url).replace('.webp', '.png'), + embed_description="[Direct Link]({})".format(str(user.avatar_url).replace('.webp', '.png')) + ) + ) + @bot.command(name='redpanda') async def redpanda(ctx): diff --git a/test-dragon-bot.sh b/test-dragon-bot.sh index 244ba8e0..44547dfa 100755 --- a/test-dragon-bot.sh +++ b/test-dragon-bot.sh @@ -6,4 +6,4 @@ printf "[+] Done\n" printf "\n[-] Running dragon bot in test mode\n" docker build -f ./Dockerfile-test-env -t dragon-bot-test . || exit -docker run -ti --rm --name dragon-bot-test -e DRAGON_ENV=test -e token="MzQ1MjkwMTI5OTQ4Mjc4Nzg0.DG5IBw._9umb82PrL22bPe7GjmHClU-NtU" dragon-bot-test sh +docker run -ti -v $(pwd)/app:/app --rm --name dragon-bot-test -e DRAGON_ENV=test -e token="MzQ1MjkwMTI5OTQ4Mjc4Nzg0.DG5IBw._9umb82PrL22bPe7GjmHClU-NtU" dragon-bot-test sh