-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathembeds.py
61 lines (49 loc) · 2.23 KB
/
embeds.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import discord
import requests
import VERY_SECRET_LAUNCH_CODES
async def outage_alert(client):
embed = discord.Embed(
color=discord.Color.red(),
title="Outage Notice",
description="I'm putting my computer in a box. Stonksbot will be down. Suck my nuts."
)
embed.set_footer(text="StonksBotDos", icon_url=client.user.avatar_url)
return embed
async def stonk_syntax_error(client):
embed = discord.Embed(
color=discord.Color.red(),
title="Invalid Syntax",
description="**Usage:** gib stonk [TICKER] (TIMEFRAME) (MULTIPLIER) (START: YYYY-MM-DD) (END: YYYY-MM-DD)"
)
embed.set_footer(text="StonksBotDos", icon_url=client.user.avatar_url)
embed.add_field(name="\u200B", value="*querying outside of market hours can throw this exception as well*")
return embed
async def stonk_data_error(client):
embed = discord.Embed(
color=discord.Color.red(),
title="Data Error",
description="This error is maybe really bad. See if API is giving realtime data."
)
embed.set_footer(text="StonksBotDos", icon_url=client.user.avatar_url)
embed.add_field(name="\u200B", value="*ben might have to pay for api lol*")
return embed
async def stonk_view(client, ticker):
r = requests.get(f'https://api.polygon.io/v1/meta/symbols/{ticker}/company?&apiKey={VERY_SECRET_LAUNCH_CODES.HYDROGEN_LAUNCH_CODE()}')
data = r.json()
embed = discord.Embed(
color=discord.Color.blue(),
title=data['name'],
description=data['description']
)
embed.set_author(name=ticker, icon_url=data['logo'])
embed.add_field(name="\u200B", value=f"Location: {data['hq_state']}, {data['hq_country']}")
embed.set_image(url="attachment://plot.png")
embed.set_footer(text="StonksBotDos", icon_url=client.user.avatar_url)
try:
r = requests.get(
f'https://api.polygon.io/v1/meta/symbols/{ticker}/news?perpage=50&page=1&apiKey={VERY_SECRET_LAUNCH_CODES.HYDROGEN_LAUNCH_CODE()}')
news = r.json()[0]
embed.add_field(name="News:", value=f"**{news['title']}**\n{news['summary']}\n*{news['url']}*", inline=False)
except IndexError:
embed.add_field(name="News:", value="*No articles found*")
return embed