Merge branch 'embeds_everywhere' into 'master'
Creating a helper method for generating embed objects See merge request ldooks/dragon-bot!62
This commit is contained in:
commit
ac7e9b82d4
@ -75,12 +75,34 @@ async def on_message(message):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def generate_embed(embed_url, embed_title=None, embed_description=None):
|
||||||
|
"""
|
||||||
|
generate_embed(embed_url, embed_title=None, embed_description=None)
|
||||||
|
|
||||||
|
Generates a discord embed object based on the URL passed in
|
||||||
|
Optionally, you can set the title and description text for the embed object.
|
||||||
|
"""
|
||||||
|
image = embed_url
|
||||||
|
|
||||||
|
if not embed_description:
|
||||||
|
embed_description="[Direct Link]({})".format(image)
|
||||||
|
|
||||||
|
embed = discord.Embed(
|
||||||
|
title=embed_title,
|
||||||
|
description=embed_description,
|
||||||
|
type='rich'
|
||||||
|
)
|
||||||
|
embed.set_image(url=image)
|
||||||
|
return embed
|
||||||
|
|
||||||
if message.content.startswith('!8ball'):
|
if message.content.startswith('!8ball'):
|
||||||
await client.send_message(
|
await client.send_message(
|
||||||
message.channel,
|
message.channel,
|
||||||
eight_ball.check_8ball(message.content)
|
eight_ball.check_8ball(message.content)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
if message.content.startswith('!avatar'):
|
if message.content.startswith('!avatar'):
|
||||||
profile = [message.author]
|
profile = [message.author]
|
||||||
if len(message.mentions):
|
if len(message.mentions):
|
||||||
@ -91,10 +113,10 @@ async def on_message(message):
|
|||||||
for user in profile:
|
for user in profile:
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
title="{}#{}".format(user.name, user.discriminator),
|
title="{}#{}".format(user.name, user.discriminator),
|
||||||
description="[Direct Link]({})".format(user.avatar_url),
|
description="[Direct Link]({})".format(user.avatar_url.replace('.webp', '.png')),
|
||||||
type='rich'
|
type='rich'
|
||||||
)
|
)
|
||||||
embed.set_image(url=user.avatar_url)
|
embed.set_image(url=user.avatar_url.replace('.webp', '.png'))
|
||||||
await client.send_message(message.channel, embed=embed)
|
await client.send_message(message.channel, embed=embed)
|
||||||
|
|
||||||
if message.content.startswith('!cleanup'):
|
if message.content.startswith('!cleanup'):
|
||||||
@ -124,7 +146,7 @@ async def on_message(message):
|
|||||||
if message.content.startswith('!dog'):
|
if message.content.startswith('!dog'):
|
||||||
await client.send_message(
|
await client.send_message(
|
||||||
message.channel,
|
message.channel,
|
||||||
doggos.get_dog()
|
embed=generate_embed(embed_url=doggos.get_dog())
|
||||||
)
|
)
|
||||||
|
|
||||||
if message.content.startswith('!excuse'):
|
if message.content.startswith('!excuse'):
|
||||||
@ -179,7 +201,10 @@ async def on_message(message):
|
|||||||
if message.content.startswith('!lewd'):
|
if message.content.startswith('!lewd'):
|
||||||
await client.send_message(
|
await client.send_message(
|
||||||
message.channel,
|
message.channel,
|
||||||
lewds.get_lewd(channel_name=message.channel.name)
|
embed=generate_embed(
|
||||||
|
embed_url=lewds.get_lewd(channel_name=message.channel.name),
|
||||||
|
embed_title="{} is being lewd".format(message.author.name)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
if message.content.startswith('!weather'):
|
if message.content.startswith('!weather'):
|
||||||
@ -197,13 +222,13 @@ async def on_message(message):
|
|||||||
if message.content.startswith('!pout'):
|
if message.content.startswith('!pout'):
|
||||||
await client.send_message(
|
await client.send_message(
|
||||||
message.channel,
|
message.channel,
|
||||||
get_from_reddit.get_image('pouts')
|
embed=generate_embed(embed_url=get_from_reddit.get_image('pout'))
|
||||||
)
|
)
|
||||||
|
|
||||||
if message.content.startswith('!smug'):
|
if message.content.startswith('!smug'):
|
||||||
await client.send_message(
|
await client.send_message(
|
||||||
message.channel,
|
message.channel,
|
||||||
get_from_reddit.get_image('smuganimegirls')
|
embed=generate_embed(embed_url=get_from_reddit.get_image('smuganimegirls'))
|
||||||
)
|
)
|
||||||
|
|
||||||
if message.content.startswith('!purge'):
|
if message.content.startswith('!purge'):
|
||||||
@ -234,12 +259,13 @@ async def on_message(message):
|
|||||||
if message.content.startswith('!wallpaper'):
|
if message.content.startswith('!wallpaper'):
|
||||||
await client.send_message(
|
await client.send_message(
|
||||||
message.channel,
|
message.channel,
|
||||||
wallpaper.get_wall(message.content)
|
embed=generate_embed(embed_url=wallpaper.get_wall(message.content))
|
||||||
)
|
)
|
||||||
|
|
||||||
if message.content.startswith('!homepage'):
|
if message.content.startswith('!homepage'):
|
||||||
await client.send_message(
|
await client.send_message(
|
||||||
message.channel,
|
message.channel,
|
||||||
wallpaper.get_picture()
|
embed=generate_embed(embed_url=wallpaper.fcking_homepage())
|
||||||
)
|
)
|
||||||
|
|
||||||
if message.content.startswith('!docker'):
|
if message.content.startswith('!docker'):
|
||||||
|
@ -1,10 +1,16 @@
|
|||||||
import requests
|
|
||||||
import requests
|
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
import urllib
|
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
import requests
|
||||||
|
import urllib
|
||||||
|
|
||||||
def get_wall(message):
|
def get_wall(message):
|
||||||
|
"""
|
||||||
|
get_wall(message)
|
||||||
|
|
||||||
|
Grabs a random wallpaper from unsplash.com's random function
|
||||||
|
If any tags are passed in as the message, it will search for images
|
||||||
|
matching those tags
|
||||||
|
"""
|
||||||
unsplash_url = "https://source.unsplash.com/3840x2160/?"
|
unsplash_url = "https://source.unsplash.com/3840x2160/?"
|
||||||
|
|
||||||
if len(message.split()) > 2:
|
if len(message.split()) > 2:
|
||||||
@ -30,9 +36,15 @@ def get_wall(message):
|
|||||||
else:
|
else:
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def get_picture():
|
def fcking_homepage():
|
||||||
|
"""
|
||||||
|
fcking_homepage()
|
||||||
|
|
||||||
|
Retrives the picture of the day from fuckinghomepage.com
|
||||||
|
"""
|
||||||
url = requests.get("http://fuckinghomepage.com")
|
url = requests.get("http://fuckinghomepage.com")
|
||||||
soup = BeautifulSoup(url.content)
|
soup = BeautifulSoup(url.content)
|
||||||
|
|
||||||
for pic in soup.find_all("p"):
|
for pic in soup.find_all("p"):
|
||||||
if 'SWEET-ASS PICTURE' in ''.join(pic.findAll(text=True)):
|
if 'SWEET-ASS PICTURE' in ''.join(pic.findAll(text=True)):
|
||||||
link = pic.find_next_sibling('p')
|
link = pic.find_next_sibling('p')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user