Adding more collections to NFT and formatting
This commit is contained in:
parent
47bedb485b
commit
37c7c75015
@ -544,9 +544,11 @@ async def stock(ctx):
|
||||
msg = ctx.message.content
|
||||
if len(msg.split()) < 2:
|
||||
import help_methods
|
||||
|
||||
await ctx.send(help_methods.get_help_message("stock"))
|
||||
|
||||
import stock
|
||||
|
||||
results = stock.parse_message(msg)
|
||||
for res in results:
|
||||
await ctx.send(embed=res)
|
||||
|
14
app/nft.py
14
app/nft.py
@ -3,7 +3,19 @@ import random
|
||||
|
||||
|
||||
def get_nft():
|
||||
url = "https://api.opensea.io/api/v1/bundles?limit=50&asset_contract_address=0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d"
|
||||
|
||||
# To find the collection's address, you have to do a curl against the API
|
||||
# curl -s --request GET --url https://api.opensea.io/api/v1/collection/<collection name here> | | jq -r .[].primary_asset_contracts[].address
|
||||
collections = [
|
||||
"0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d",
|
||||
"0xbd3531da5cf5857e7cfaa92426877b022e612cf8",
|
||||
"0x54a79ab6f5210fcb2c5fc914271a865003f15576",
|
||||
"0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb",
|
||||
]
|
||||
url = (
|
||||
"https://api.opensea.io/api/v1/bundles?limit=50&asset_contract_address=%s"
|
||||
% random.choice(collections)
|
||||
)
|
||||
x = requests.get(url).json()["bundles"]
|
||||
|
||||
return random.choice(x)["assets"][0]["image_url"]
|
||||
|
20
app/stock.py
20
app/stock.py
@ -8,11 +8,11 @@ def parse_message(msg):
|
||||
verbose = False
|
||||
embeds = []
|
||||
bad_tickers = []
|
||||
if set(['-v', '--verbose']) & set(split_msg):
|
||||
if set(["-v", "--verbose"]) & set(split_msg):
|
||||
verbose = True
|
||||
for s in split_msg[1:]:
|
||||
# Skip flags
|
||||
if s[0] != '-':
|
||||
if s[0] != "-":
|
||||
try:
|
||||
embeds.append(get_stock(s, verbose=verbose))
|
||||
except:
|
||||
@ -46,11 +46,12 @@ def _add_verbose_fields(embed, request):
|
||||
)
|
||||
embed.add_field(
|
||||
name="Change since prev. close (as %)",
|
||||
value="$%.2f (%s%%)" % (request["regularMarketChange"], request["regularMarketChangePercent"]),
|
||||
value="$%.2f (%s%%)"
|
||||
% (request["regularMarketChange"], request["regularMarketChangePercent"]),
|
||||
inline=False,
|
||||
)
|
||||
|
||||
if 'bid' in request and 'ask' in request:
|
||||
if "bid" in request and "ask" in request:
|
||||
embed.add_field(
|
||||
name="Current bid price", value="$%s" % request["bid"], inline=False
|
||||
)
|
||||
@ -67,12 +68,12 @@ def _add_verbose_fields(embed, request):
|
||||
name="Day's Range", value=request["regularMarketDayRange"], inline=False
|
||||
)
|
||||
|
||||
if 'marketCap' in request:
|
||||
if "marketCap" in request:
|
||||
embed.add_field(
|
||||
name="Market Cap", value="{:,}".format(request["marketCap"]), inline=False
|
||||
)
|
||||
)
|
||||
|
||||
if 'sharesOutstanding' in request:
|
||||
if "sharesOutstanding" in request:
|
||||
embed.add_field(
|
||||
name="Shares Outstanding",
|
||||
value="{:,}".format(request["sharesOutstanding"]),
|
||||
@ -97,7 +98,7 @@ def get_stock(share_name, verbose=False):
|
||||
]
|
||||
|
||||
if not response:
|
||||
raise ValueError('Invalid symbol %s: empty response from Yahoo' % share_name)
|
||||
raise ValueError("Invalid symbol %s: empty response from Yahoo" % share_name)
|
||||
|
||||
request = response[0]
|
||||
|
||||
@ -124,7 +125,8 @@ def get_stock(share_name, verbose=False):
|
||||
)
|
||||
embed.add_field(
|
||||
name="Change since day open (as %)",
|
||||
value="$%.2f (%.7f%%)" % (current_change, current_change * 100 / request["regularMarketOpen"]),
|
||||
value="$%.2f (%.7f%%)"
|
||||
% (current_change, current_change * 100 / request["regularMarketOpen"]),
|
||||
inline=False,
|
||||
)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user