Something went wrong. Try again.
a reminder bot on atproto: mention it with a time, it replies when the time comes
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071import jsonimport subprocessfrom pathlib import Path
from remind.config import BOT_DID, PDS, account_password, typesafe_key
ROOT = Path(__file__).resolve().parents[1]HOST = "heavypad"SOURCE = "https://knot1.tangled.sh/did:plc:xx5y2tpzhpdlbcmixqyddfnd"SSH = ["ssh", "-o", "BatchMode=yes", "-o", "ConnectTimeout=5", HOST]
def run(args, **kwargs): return subprocess.run(args, check=True, cwd=ROOT, **kwargs)
def output(args) -> str: return run(args, capture_output=True, text=True).stdout.strip()
def main(): if output(["git", "status", "--porcelain"]): raise RuntimeError("Commit and push the working tree before deployment") sha = output(["git", "rev-parse", "HEAD"]) if sha != output(["git", "ls-remote", "origin", "refs/heads/main"]).split()[0]: raise RuntimeError("Push this exact commit to main before deployment") values = { "REMIND_DID": BOT_DID, "REMIND_PDS": PDS, "REMIND_PASSWORD": account_password(), "TYPESAFE_API_KEY": typesafe_key(), } run( [ *SSH, "umask 077; mkdir -p ~/.config/remind; " "cat > ~/.config/remind/env.new && mv ~/.config/remind/env.new ~/.config/remind/env", ], input="".join(f"{key}={json.dumps(value)}\n" for key, value in values.items()), text=True, capture_output=True, ) run( [ *SSH, f"""set -eumkdir -p ~/tangled.org/waow.tech ~/.config/systemd/user ~/.local/state/remindchmod 700 ~/.local/state/remindif test ! -d ~/tangled.org/waow.tech/remind/.git; then git clone {SOURCE} ~/tangled.org/waow.tech/remindficd ~/tangled.org/waow.tech/remindtest -z "$(git status --porcelain)"git fetch origin maingit checkout --detach {sha}~/.local/bin/uv sync --frozen --no-devinstall -m 644 deploy/remind.service ~/.config/systemd/user/remind.servicesystemctl --user daemon-reloadsystemctl --user enable remind.servicesystemctl --user restart remind.servicesystemctl --user is-active remind.servicegit rev-parse HEAD""", ] )
if __name__ == "__main__": main()