From f9a47e8891a3bf836ce9efa8442cbdb13c81792f Mon Sep 17 00:00:00 2001 From: KenwoodFox Date: Mon, 21 Jun 2021 21:02:11 -0400 Subject: [PATCH] Add basic bot, this should get changed --- companion_software/BasicBot.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 companion_software/BasicBot.py diff --git a/companion_software/BasicBot.py b/companion_software/BasicBot.py new file mode 100644 index 0000000..d06675a --- /dev/null +++ b/companion_software/BasicBot.py @@ -0,0 +1,23 @@ +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 +