Created
June 28, 2019 07:18
-
-
Save pbuckley4192/3a0a583f7cb71a4b000315962a26a32a to your computer and use it in GitHub Desktop.
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
import requests | |
import json | |
import subprocess | |
r = requests.get('https://thepihut.com/products/raspberry-pi-4-model-b.js').json() | |
count = r["variants"][2]["inventory_quantity"] | |
available = r["variants"][2]["available"] | |
print("RPI Available:\t"+ str(count)) | |
def sendmessage(message): | |
subprocess.Popen(['notify-send', message]) | |
return | |
sendmessage("RPI Available:\t"+ str(count)) | |
if count > 0 or available == True: | |
# Notify Discord | |
url = '<DISCORD WEBHOOK URL>' | |
payload = {'content': "RPI 4 Available, Num Units:\t" + str(count)} | |
headers = {'content-type': 'application/json'} | |
response = requests.post(url, data=json.dumps(payload), headers=headers) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment