Voeg GB-data toe aan WhatsApp notificatie
This commit is contained in:
parent
e0b36a5b9c
commit
c57363fe24
1 changed files with 4 additions and 3 deletions
|
|
@ -109,14 +109,15 @@ WHATSAPP_API = "http://100.97.199.84:3000/client/sendMessage/EdGpt"
|
||||||
WHATSAPP_CHAT = "31620248011@c.us"
|
WHATSAPP_CHAT = "31620248011@c.us"
|
||||||
|
|
||||||
|
|
||||||
def send_whatsapp_notification(ok, errors):
|
def send_whatsapp_notification(ok, errors, total_bytes):
|
||||||
if errors == 0:
|
if errors == 0:
|
||||||
prefix = "✅"
|
prefix = "✅"
|
||||||
status = "geen fouten"
|
status = "geen fouten"
|
||||||
else:
|
else:
|
||||||
prefix = "❌"
|
prefix = "❌"
|
||||||
status = f"{errors} fout(en)"
|
status = f"{errors} fout(en)"
|
||||||
body = f"{prefix} Dashcam transfer voltooid: {ok} bestanden overgezet, {status}"
|
gb = total_bytes / (1024 ** 3)
|
||||||
|
body = f"{prefix} Dashcam transfer voltooid: {ok} bestanden ({gb:.1f} GB) overgezet, {status}"
|
||||||
payload = {"chatId": WHATSAPP_CHAT, "content": body, "contentType": "string"}
|
payload = {"chatId": WHATSAPP_CHAT, "content": body, "contentType": "string"}
|
||||||
try:
|
try:
|
||||||
data = json.dumps(payload).encode()
|
data = json.dumps(payload).encode()
|
||||||
|
|
@ -213,7 +214,7 @@ def main():
|
||||||
ok += 1
|
ok += 1
|
||||||
|
|
||||||
logging.info("Transfer voltooid: %d ok, %d fouten", ok, errors)
|
logging.info("Transfer voltooid: %d ok, %d fouten", ok, errors)
|
||||||
send_whatsapp_notification(ok, errors)
|
send_whatsapp_notification(ok, errors, total_size)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue