Adding info, youtube, and source. Fixes #16 #30 #24

This commit is contained in:
Luke Robles 2020-08-12 16:38:57 -07:00
parent efe6bc4187
commit a1909bdadf
3 changed files with 40 additions and 1 deletions

View File

@ -12,6 +12,6 @@ RUN printf "\n\nTesting your python code for errors\n\n" && \
# COPY --from=builder /usr/local/lib/python3.8/site-packages /usr/local/lib/python3.8/ # COPY --from=builder /usr/local/lib/python3.8/site-packages /usr/local/lib/python3.8/
# ADD app /app # ADD app /app
WORKDIR /app WORKDIR /app
RUN printf "\n#########################\n Run dragon bot by typing \n python dragon-bot.py\n#########################\n\n" RUN printf "\n#########################\n Run dragon bot by typing \n python bot.py\n#########################\n\n"
CMD python /app/bot.py CMD python /app/bot.py

View File

@ -118,6 +118,18 @@ async def stock(ctx):
await ctx.send(embed=result) await ctx.send(embed=result)
@bot.command(name='source')
async def source(ctx):
await ctx.send("https://git.luker.gq/ldooks/dragon-bot")
@bot.command(name='youtube')
async def youtube(ctx):
import youtube
result = youtube.parse_message(ctx.message.content)
await ctx.send(result)
@bot.command(name='flows') @bot.command(name='flows')
async def flows(ctx): async def flows(ctx):
@ -143,6 +155,24 @@ async def ffxiv(ctx):
except Exception: except Exception:
await ctx.send("I encountered an error while searching for that player.\nPlease check that your player name and server are spelled correctly") await ctx.send("I encountered an error while searching for that player.\nPlease check that your player name and server are spelled correctly")
@bot.command(name='info')
async def info(ctx):
import datetime
server = ctx.message.guild
embed = discord.Embed(
title=f"{server.name}",
description="Info about this discord server",
timestamp=datetime.datetime.utcnow(),
color=discord.Color.blue()
)
embed.add_field(name="Server created at", value=f"{server.created_at}")
embed.add_field(name="Server Owner", value=f"{server.owner}")
embed.add_field(name="Server Region", value=f"{server.region}")
embed.add_field(name="Server ID", value=f"{server.id}")
embed.set_thumbnail(url=server.icon_url)
await ctx.send(embed=embed)
@bot.command(name='purge') @bot.command(name='purge')
async def purge(ctx): async def purge(ctx):

9
app/youtube.py Normal file
View File

@ -0,0 +1,9 @@
import re
from urllib import parse, request
def parse_message(message):
query_string = parse.urlencode({'search_query': message.split()[1:]})
html_content = request.urlopen('http://www.youtube.com/results?' + query_string)
search_results = re.findall('\/watch\?v=(.{11})', html_content.read().decode())
return 'https://www.youtube.com/watch?v=' + search_results[0]