admin-scripts/python/resend_notify.py

35 lines
655 B
Python
Executable File

# /// script
# dependencies = [
# "resend",
# ]
# ///
import subprocess
import sys
from pathlib import Path
import resend
def main():
resend.api_key = Path("/usr/local/etc/resend_api_key.txt").read_text().strip("\n")
if len(sys.argv) != 3:
exit("Usage: resend_notify.py SUBJECT MESSAGE")
subject = sys.argv[1]
message = sys.argv[2]
params: resend.Emails.SendParams = {
"from": "Admin <admin@hyperreal.coffee>",
"to": ["hyperreal@moonshadow.dev"],
"subject": subject,
"text": message,
}
email = resend.Emails.send(params)
print(email)
if __name__ == "__main__":
main()