--daemon long-polls getUpdates, runs one turn per message and replies. The token comes from ~/.splinter/telegram.token (0600) or SPLINTER_TELEGRAM_TOKEN, never from an argument: arguments end up in ps and in shell history. telegram_allow lists who is answered, comma separated, nobody by default - an empty list is a refusal, not an open door. Unknown senders are logged without their text. The loop survives a failed request instead of dying on it, and keeps no state beyond the session: a restart re-delivers the last update, which costs one duplicated answer and never a lost message. test_telegram covers the token paths (file wins, environment as fallback, empty file is not a token). Verified against api.telegram.org: the token works and getMe answers hbx_splinter_bot. Sending needs the user to write first - a bot cannot start a chat, the API says 'chat not found'.
23 lines
650 B
Desktop File
23 lines
650 B
Desktop File
# systemd --user unit for splinter's gateway mode.
|
|
#
|
|
# cp docs/splinter-gateway.service ~/.config/systemd/user/
|
|
# systemctl --user daemon-reload
|
|
# systemctl --user enable --now splinter-gateway
|
|
#
|
|
# The token lives in ~/.splinter/telegram.token (0600) and is never passed as an
|
|
# argument: arguments show up in ps.
|
|
[Unit]
|
|
Description=splinter gateway (Telegram)
|
|
After=network-online.target
|
|
|
|
[Service]
|
|
Type=simple
|
|
ExecStart=%h/src/splinter/splinter --daemon
|
|
Restart=on-failure
|
|
RestartSec=5
|
|
# a gateway that answers the world is not a gateway, it is a leak
|
|
Environment=SPLINTER_CONFIG=%h/.splinter/splinter.conf
|
|
|
|
[Install]
|
|
WantedBy=default.target
|