diff --git a/README.md b/README.md index 013ba1f..c8e233f 100644 --- a/README.md +++ b/README.md @@ -23,31 +23,32 @@ Before using the script, you need to have the following prerequisites in place: ## Configuration -You need to configure the script with your SMTP server settings and email details. Open the script and modify the following variables in the "Configuration" section: +You need to configure the config.json file with your SMTP server settings and email details. Open the config file and modify the following variables: -- `smtp_host`: SMTP server hostname. -- `smtp_port`: SMTP server port. -- `smtp_user`: Your SMTP server username. -- `smtp_password`: Your SMTP server password. -- `from_email`: Your email address (the sender). -- `to_email`: Recipient's email address. -- `checkin_file`: Path to the check-in timestamp file. -- `counter_file`: Path to the email counter file. -- `DAYS_REMINDER`: Number of days for the reminder period. -- `DAYS_DEADMAN`: Number of days for the Dead Man's Switch activation. -- `SECONDS_IN_A_DAY`: Number of seconds in a day. -- `count_sent_mail`: Number of dead man mails to send after activation. -- `family_members`: List of family members' email addresses. -- `files_to_attach`: List of files to attach to the emails. +- `config.json`: JSON configuration file containing the following settings: + - `smtp_host`: SMTP server hostname. + - `smtp_port`: SMTP server port. + - `smtp_user`: Your SMTP server username. + - `smtp_password`: Your SMTP server password. + - `from_email`: Your email address (the sender). + - `to_email`: Recipient's email address. + - `checkin_file`: Path to the check-in timestamp file. + - `counter_file`: Path to the email counter file. + - `DAYS_REMINDER`: Number of days for the reminder period. + - `DAYS_DEADMAN`: Number of days for the Dead Man's Switch activation. + - `SECONDS_IN_A_DAY`: Number of seconds in a day. + - `count_sent_mail`: Number of dead man mails to send after activation. + - `family_members`: List of family members' email addresses. + - `files_to_attach`: List of files to attach to the emails. ## Customization -You can customize the email content by modifying the following variables in the script: +You can customize the email content by modifying the following variables in the config: - `reminder_subject`: Subject for the reminder email. - `reminder_message`: Message for the reminder email. -- `dead_man_subject`: Subject for the Dead Man's Switch activation email. -- `dead_man_message`: Message for the Dead Man's Switch activation email. +- `dead_man_activation_subject`: Subject for the Dead Man's Switch activation email. +- `dead_man_activation_message`: Message for the Dead Man's Switch activation email. ## Usage @@ -65,6 +66,7 @@ You can customize the email content by modifying the following variables in the - [Yusuf İpek](https://github.com/yusufipk) - [Koray Üstündağ](https://github.com/korayustundag) +- [Mugo Squero](https://github.com/MugoSquero) ## License This script is provided under the GPL-3.0 License. You are free to use, modify, and distribute it as needed. See the [LICENSE](https://github.com/yusufipk/dead-man-message/blob/master/LICENSE) file for details. diff --git a/checkin.sh b/checkin.sh index 1f6a1a4..83f6934 100755 --- a/checkin.sh +++ b/checkin.sh @@ -1,4 +1,4 @@ #!/bin/bash # Save the current timestamp to your checkin file -date +%s > ./checkin_file.txt +date +%s > "$(jq -r .checkin_file config.json)" echo "Checked in" diff --git a/checking.py b/checking.py index c870100..408d4bc 100644 --- a/checking.py +++ b/checking.py @@ -4,33 +4,38 @@ from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText from email.mime.base import MIMEBase from email import encoders +import json + +# Load configuration from JSON file +with open('config.json', 'r') as config_file: + config = json.load(config_file) # Configuration -smtp_host = 'your_smpt_server' # SMTP server hostname -smtp_port = 587 # SMTP server port -smtp_user = 'username' # SMTP server username -smtp_password = 'password' # SMTP server password -from_email = 'coming_from' # Sender's email address -to_email = 'going_to' # Recipient's email address -checkin_file = "./checkin_file.txt" # File path for check-in timestamp -counter_file = "./counter_file.txt" # File path for email counter -DAYS_REMINDER = 25 # Days for the reminder period -DAYS_DEADMAN = 30 # Days for the dead man's switch -SECONDS_IN_A_DAY = 86400 # Number of seconds in a day -count_sent_mail = 7 # Number of dead man mails to send after activation. +smtp_host = config['smtp_host'] # SMTP server hostname +smtp_port = config['smtp_port'] # SMTP server port +smtp_user = config['smtp_user'] # SMTP server username +smtp_password = config['smtp_password'] # SMTP server password +from_email = config['from_email'] # Sender's email address +to_email = config['to_email'] # Recipient's email address +checkin_file = config['checkin_file'] # File path for check-in timestamp +counter_file = config['counter_file'] # File path for email counter +DAYS_REMINDER = config['DAYS_REMINDER'] # Days for the reminder period +DAYS_DEADMAN = config['DAYS_DEADMAN'] # Days for the dead man's switch +SECONDS_IN_A_DAY = config['SECONDS_IN_A_DAY'] # Number of seconds in a day +count_sent_mail = config['count_sent_mail'] # Number of dead man mails to send after activation. -family_members = ['mail@example.com'] # List of family members' email addresses +family_members = config['family_members'] # List of family members' email addresses # Email content -reminder_subject = "REMINDER" # Subject for the reminder email -reminder_message = "Please check-in" # Message for the reminder email +reminder_subject = config['reminder_subject'] # Subject for the reminder email +reminder_message = config['reminder_message'] # Message for the reminder email -dead_man_activation_subject = "Dead Man's Switch Activated" # Subject for the activation email -dead_man_activation_message = "You forgot to check-in" # Message for the activation email +dead_man_activation_subject = config['dead_man_activation_subject'] # Subject for the activation email +dead_man_activation_message = config['dead_man_activation_message'] # Message for the activation email -dead_man_subject = "I Am Gone" # Subject for the dead man's switch email -dead_man_message = "I'm dead" # Message for the dead man's switch email -files_to_attach = ['file.gpg'] # List of files to attach +dead_man_subject = config['dead_man_subject'] # Subject for the dead man's switch email +dead_man_message = config['dead_man_message'] # Message for the dead man's switch email +files_to_attach = config['files_to_attach'] # List of files to attach # Function to send an email def send_email(subject, message, to, attachments=[]): diff --git a/config.json b/config.json new file mode 100644 index 0000000..2612d7e --- /dev/null +++ b/config.json @@ -0,0 +1,22 @@ +{ + "smtp_host": "your_smpt_server", + "smtp_port": 587, + "smtp_user": "username", + "smtp_password": "password", + "from_email": "coming_from", + "to_email": "going_to", + "checkin_file": "./checkin_file.txt", + "counter_file": "./counter_file.txt", + "DAYS_REMINDER": 25, + "DAYS_DEADMAN": 30, + "SECONDS_IN_A_DAY": 86400, + "count_sent_mail": 7, + "family_members": ["mail@example.com"], + "reminder_subject": "REMINDER", + "reminder_message": "Please check-in", + "dead_man_activation_subject": "Dead Man's Switch Activated", + "dead_man_activation_message": "You forgot to check-in", + "dead_man_subject": "I Am Gone", + "dead_man_message": "I'm dead", + "files_to_attach": ["file.gpg"] +}