Skill: trae1oung/dead-or-not (version 1.0.2)

--- name: dead-or-not description: | A "life check" skill that periodically checks if the user is still responsive. If the user hasn't messaged for a set time, it asks if they're okay, and if no reply, sends an email to emergency contacts. User can customize email content, SMTP settings, and check time. Use when: (1) Creating a "DeadOrNot" app (2) Daily health check (3) Auto-notify on unresponsive users (4) Setting up check-in reminders --- # DeadOrNot Daily check to see if user is still responsive - asks if okay, sends email if no reply. ## How It Works 1. User messages → updates last_seen timestamp 2. Cron runs daily → sets check_flag if timeout exceeded 3. Agent reads check_flag → asks user if they're okay 4. No reply → calls send_mail.py to notify emergency contact ## Quick Start ### 1. Initialize ```bash mkdir -p ~/.openclaw/apps/deadornot ``` ### 2. Configure Create config file `~/.openclaw/apps/deadornot/config`: ```bash NOTIFY_EMAIL=[REDACTED_SECRET] MESSAGE=User is unresponsive, please check on them! TIMEOUT_HOURS=24 ASK_HOUR=10 SMTP_SERVER=smtp.qq.com SMTP_PORT=465 SMTP_EMAIL=[REDACTED_SECRET] SMTP_PASSWORD=your_auth_code ``` ### 3. Set up Cron ```bash crontab -l | { cat; echo "0 0 * * * /path/to/check.sh >> /path/to/log.txt 2>&1"; } | crontab - ``` ## Configuration | Variable | Default | Description | |----------|---------|-------------| | TIMEOUT_HOURS | 24 | Hours without message before check | | NOTIFY_EMAIL | - | Emergency contact (required) | | MESSAGE | "User is unresponsive!" | Email content | | ASK_HOUR | 10 | When to ask (0-23) | | SMTP_SERVER | smtp.qq.com | SMTP server | | SMTP_PORT | 465 | SMTP port | | SMTP_EMAIL | - | Sender email | | SMTP_PASSWORD | - | SMTP auth code |

path: scripts/check.sh
content: #!/bin/bash

# DeadOrNot - Check if user is still alive
# Runs once per day via cron

CONFIG_DIR="$HOME/.openclaw/apps/deadornot"
LAST_SEEN_FILE="$CONFIG_DIR/last_seen"
LAST_ASKED_FILE="$CONFIG_DIR/last_asked"
CONFIG_FILE="$CONFIG_DIR/config"
SCRIPT_DIR="$(dirname "$0")"

# Load config
if [ ! -f "$CONFIG_FILE" ]; then
    mkdir -p "$CONFIG_DIR"
    echo "# DeadOrNot Configuration" > "$CONFIG_FILE"
    echo "TIMEOUT_HOURS=24" >> "$CONFIG_FILE"
    echo "NOTIFY_EMAIL=" >> "$CONFIG_FILE"
    echo "MESSAGE=User is unresponsive!" >> "$CONFIG_FILE"
    echo "ASK_HOUR=10" >> "$CONFIG_FILE"
    echo "SMTP_SERVER=smtp.qq.com" >> "$CONFIG_FILE"
    echo "SMTP_PORT=465" >> "$CONFIG_FILE"
    echo "SMTP_EMAIL=" >> "$CONFIG_FILE"
    echo "SMTP_PASSWORD=" >> "$CONFIG_FILE"
fi

source "$CONFIG_FILE"

NOW=$(date +%s)
CURRENT_HOUR=$(date +%H)

if [ -f "$LAST_SEEN_FILE" ]; then
    LAST_SEEN=$(cat "$LAST_SEEN_FILE")
else
    LAST_SEEN=$NOW
fi

DIFF=$((NOW - LAST_SEEN))
TIMEOUT_SECONDS=$((TIMEOUT_HOURS * 3600))

echo "[$(date)] Diff: ${DIFF}s, Timeout: ${TIMEOUT_SECONDS}s"

if [ $DIFF -ge $TIMEOUT_SECONDS ]; then
    if [ -f "$LAST_ASKED_FILE" ]; then
        LAST_ASKED=$(cat "$LAST_ASKED_FILE")
        ASKED_DIFF=$((NOW - LAST_ASKED))
        if [ $ASKED_DIFF -lt 7200 ]; then
            echo "Already asked within 2 hours, waiting..."
            exit 0
        fi
    fi
    
    if [ "$CURRENT_HOUR" -ge "$ASK_HOUR" ] && [ "$CURRENT_HOUR" -lt "$((ASK_HOUR + 2))" ]; then
        echo "TIME_TO_ASK=true" > "$CONFIG_DIR/check_flag"
        echo "Setting ask flag - agent will check on user"
        echo "$NOW" > "$LAST_ASKED_FILE"
    else
        echo "Outside ask hours ($ASK_HOUR-$((ASK_HOUR+2))), skipping"
    fi
else
    rm -f "$CONFIG_DIR/check_flag"
    echo "All good! User is still alive."
fi


path: scripts/send_mail.py
content: #!/usr/bin/env python3
"""
DeadOrNot - Email sending script
Configure via config file before use
"""
import smtplib
import os
from email.mime.text import MIMEText
from email.header import Header

# Read config from environment
SMTP_SERVER = os.getenv("SMTP_SERVER", "smtp.qq.com")
SMTP_PORT = int(os.getenv("SMTP_PORT", "465"))
SMTP_EMAIL = os.getenv("SMTP_EMAIL", "")
SMTP_PASSWORD = os.getenv("SMTP_PASSWORD", "")

TO_EMAIL = os.getenv("NOTIFY_EMAIL", "")
SUBJECT = "⚠️ DeadOrNot Alert"
MESSAGE = os.getenv("MESSAGE", "User is unresponsive, please check on them!")

def send_alert():
    if not SMTP_EMAIL or not SMTP_PASSWORD or not TO_EMAIL:
        print("❌ Config incomplete. Set environment variables.")
        return False
    
    msg = MIMEText(MESSAGE, 'plain', 'utf-8')
    msg['Subject'] = Header(SUBJECT, 'utf-8')
    msg['From'] = SMTP_EMAIL
    msg['To'] = TO_EMAIL
    
    try:
        server = smtplib.SMTP_SSL(SMTP_SERVER, SMTP_PORT)
        server.login(SMTP_EMAIL, SMTP_PASSWORD)
        server.sendmail(SMTP_EMAIL, [TO_EMAIL], msg.as_string())
        server.quit()
        print(f"✅ Email sent to {TO_EMAIL}")
        return True
    except Exception as e:
        print(f"❌ Failed to send email: {e}")
        return False

if __name__ == "__main__":
    send_alert()


Security scan verdicts — ClawScan: suspicious | static analysis: clean | VirusTotal: clean | SkillSpector: suspicious (CRITICAL)