hara: add morning heartbeat systemd service + timer
Daily 08:07 CEST oneshot: runs claude -p with Gmail MCP to check email, sends a morning Telegram ping via Bot API. Persistent timer survives reboots.
This commit is contained in:
parent
3604c08650
commit
69d982d0fa
1 changed files with 42 additions and 0 deletions
|
|
@ -387,6 +387,48 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Hara morning heartbeat — daily email check + Telegram good-morning ping.
|
||||||
|
# Runs claude in print mode with the Gmail MCP, then sends output via Bot API.
|
||||||
|
# Token lives in ~/.claude/channels/telegram/.env (managed by the telegram plugin).
|
||||||
|
systemd.services.hara-heartbeat = {
|
||||||
|
description = "Hara morning heartbeat (email check + Telegram ping)";
|
||||||
|
after = [ "network-online.target" ];
|
||||||
|
wants = [ "network-online.target" ];
|
||||||
|
path = [ pkgs.claude-code pkgs.curl pkgs.jq ];
|
||||||
|
environment = {
|
||||||
|
HOME = "/home/danny";
|
||||||
|
};
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
User = "danny";
|
||||||
|
Group = "users";
|
||||||
|
WorkingDirectory = "/home/danny";
|
||||||
|
EnvironmentFile = "/etc/claude-channels/env";
|
||||||
|
};
|
||||||
|
script = ''
|
||||||
|
set -euo pipefail
|
||||||
|
CHAT_ID="66070351"
|
||||||
|
BOT_TOKEN=$(grep '^TELEGRAM_BOT_TOKEN=' /home/danny/.claude/channels/telegram/.env | cut -d= -f2-)
|
||||||
|
MSG=$(${pkgs.claude-code}/bin/claude -p \
|
||||||
|
"You are Hara, a concise cat-energy AI assistant. Read ~/.hara/HEARTBEAT.md. Check Gmail for both accounts (danielth95 and powerhouseplayer) for urgent unread emails — security alerts, invoices, anything requiring a decision; skip newsletters and marketing. Compose a short morning message for Danny: flag urgent emails if any, otherwise just say good morning. One message, very short, cat energy." \
|
||||||
|
--mcp-config /etc/hara/mcp-servers.json \
|
||||||
|
2>/dev/null)
|
||||||
|
${pkgs.curl}/bin/curl -sf -X POST \
|
||||||
|
"https://api.telegram.org/bot$BOT_TOKEN/sendMessage" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{\"chat_id\": $CHAT_ID, \"text\": $(echo "$MSG" | ${pkgs.jq}/bin/jq -Rs .)}" \
|
||||||
|
> /dev/null
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.timers.hara-heartbeat = {
|
||||||
|
wantedBy = [ "timers.target" ];
|
||||||
|
timerConfig = {
|
||||||
|
OnCalendar = "Europe/Copenhagen *-*-* 08:07:00";
|
||||||
|
Persistent = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
# Auto-rebuild service/timer + safe.directory provided by the
|
# Auto-rebuild service/timer + safe.directory provided by the
|
||||||
# shared dotfiles-rebuild NixOS module (see nixos/modules/dotfiles-rebuild.nix).
|
# shared dotfiles-rebuild NixOS module (see nixos/modules/dotfiles-rebuild.nix).
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue