Created
March 17, 2021 17:51
-
-
Save Anon-Exploiter/0b27e01d72b53a11e46141b926a3c6d5 to your computer and use it in GitHub Desktop.
Get BTC (USD) price/minute in discord server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get USD price of BTC (changing) per minute in your discord server! | |
# Just replace the webhook_url variable and create a cron as you see fit. | |
#!/usr/bin/python3 | |
import requests | |
import json | |
# BTCPRICE=`curl -s https://api.coindesk.com/v1/bpi/currentprice/USD.json | jp bpi.USD.rate | cut -d '"' -f2` | |
# JSON="{\"content\": \"Current price of BTC is: **$BTCPRICE** USD\"}" | |
# curl -d "$JSON" -H "Content-Type: application/json" | |
WEBHOOK_URL = "https://discord.com/api/webhooks/..." | |
if __name__ == '__main__': | |
response = requests.get('https://api.coindesk.com/v1/bpi/currentprice/USD.json').text | |
data = json.loads(response)['bpi']['USD']['rate'] | |
print(data) | |
requests.post(WEBHOOK_URL, | |
json = { | |
"content": f"Current price of BTC is: **{data}** USD" | |
} | |
) | |
print("[#] Posted to server") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also, be sure to mute the channel afterwards! 😛
Output: