When a posted video is too long (>1h, probed up front) or a normal download fails as too-big/timeout, the bot offers /force. Replying /force downloads the full video off-loop (separate slot, no size cap, --max-filesize 10G), uploads it via rsync/SSH to a web docroot, and posts a tokenized link auto-deleted after 24h by an hourly sweep (also evicts oldest past 10 GB; remote-clock TTL; only ever removes its own token dirs). Hosting target is env-configured (FORCE_REMOTE/FORCE_REMOTE_DIR/FORCE_BASE_URL/ FORCE_SSH_PORT/FORCE_SSH_KEY) so published code carries no infra details; the feature self-disables when unset (probe is skipped too, so normal posting is unchanged). Staged on disk (not tmpfs), self-heals orphaned staging dirs, and re-arms the offer on transient failure. See signal-bot.service.example. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
32 lines
1.5 KiB
Plaintext
32 lines
1.5 KiB
Plaintext
[Unit]
|
|
Description=Signal Twitter Video Bot
|
|
After=network.target docker.service
|
|
Requires=docker.service
|
|
|
|
[Service]
|
|
Type=simple
|
|
User=YOUR_USER
|
|
WorkingDirectory=/home/YOUR_USER/signal-bot
|
|
# The bot's own Signal number (the account it's linked to as a device).
|
|
Environment=SIGNAL_PHONE_NUMBER=+15551234567
|
|
Environment=SIGNAL_SERVICE=127.0.0.1:8080
|
|
# Optional: comma-separated numbers allowed to run /cookies (admin command).
|
|
# Environment=BOT_ADMINS=+15551234567
|
|
# Optional: enable /force, which hosts oversized videos as temporary links.
|
|
# The bot rsyncs the file (over SSH) into a web-served directory and posts the URL;
|
|
# an hourly job deletes anything older than 24h and evicts oldest past 10 GB.
|
|
# Leave unset to disable /force. All three of REMOTE/REMOTE_DIR/BASE_URL are required.
|
|
# Environment=FORCE_REMOTE=user@webhost # ssh target that can write the docroot
|
|
# Environment=FORCE_REMOTE_DIR=/var/www/site/media # docroot on that host
|
|
# Environment=FORCE_BASE_URL=https://site/media # public URL serving that docroot
|
|
# Environment=FORCE_SSH_PORT=22 # ssh port (default 22)
|
|
# Environment=FORCE_SSH_KEY=/home/YOUR_USER/.ssh/id_ed25519 # ssh identity (optional)
|
|
ExecStart=/home/YOUR_USER/signal-bot/venv/bin/python bot.py
|
|
# always (not on-failure): the bot's library swallows exceptions in its own run
|
|
# loop and never exits non-zero even when wedged, so on-failure would never bounce it.
|
|
Restart=always
|
|
RestartSec=10
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|