24 lines
716 B
Python
24 lines
716 B
Python
from discord_webhook import DiscordWebhook
|
|
from picamera import PiCamera
|
|
from time import sleep
|
|
|
|
|
|
def get_uptime():
|
|
with open('/proc/uptime', 'r') as f:
|
|
uptime_seconds = float(f.readline().split()[0])
|
|
|
|
return uptime_seconds
|
|
|
|
webhookURL = "https://discord.com/api/webhooks/856609966404534272/TR9tnLq2sIGZoOeADNswmGRNlzBcqM5aKihfU6snVTP9WhSSoVVvi7nT6i-ZfZS7Hcqm"
|
|
|
|
webhook = DiscordWebhook(url=webhookURL, content="Uptime: " + str( round( ((get_uptime() / 60) / 60 ), 2 )) + " hours")
|
|
|
|
camera = PiCamera()
|
|
sleep(3) # let iso settle out
|
|
camera.capture('still.jpg')
|
|
|
|
with open("still.jpg", "rb") as f:
|
|
webhook.add_file(file=f.read(), filename='still.jpg')
|
|
response = webhook.execute() # Hit send
|
|
|