SUEN

Seiue Notification

網頁的通知算通知嗎?當然 TM 不算。所以,推過來吧。

Seiue Notification → Telegram

Version: v1.0 — me/received-messages inbox, systemd, at‑most‑once delivery

This project installs a non‑intrusive sidecar that forwards your Seiue inbox messages to Telegram without touching or interfering with your existing attendance scripts. It authenticates to Seiue, polls your personal inbox endpoint, de‑duplicates messages, and delivers content (including attachments) to a Telegram chat.


1) What it does


2) Requirements


3) Quick install

The installer is idempotent. Re‑running upgrades the Python worker and restarts the service while keeping your .env.

bash
bash <(curl -Ls https://raw.githubusercontent.com/ieduer/bdfz/main/seiue-notify.sh)

The installer will:

  1. Create ~/.seiue-notify/ (or /root/.seiue-notify/ when run as root).
  2. Build a Python venv and install requests, pytz, urllib3.
  3. Prompt once for Seiue username/password, Telegram Bot Token, Telegram Chat ID, polling interval.
  4. Write .env (mode 600), generate seiue_notify.py, and a systemd unit seiue-notify.service.
  5. Send a one‑shot confirmation (the latest inbox message) to Telegram.
  6. Start the daemon.

4) Configuration

~/.seiue-notify/.env

Example:

ini
SEIUE_USERNAME=teacher@example.com
SEIUE_PASSWORD=***redacted***

X_SCHOOL_ID=3
X_ROLE=teacher

TELEGRAM_BOT_TOKEN=123456789:ABCDEF...
TELEGRAM_CHAT_ID=-1001234567890

# Polling & pagination
NOTIFY_POLL_SECONDS=90
MAX_LIST_PAGES=3

# Inbox scope
READ_FILTER=all        # all | unread
INCLUDE_CC=false       # include carbon-copied items?

# Telegram rate limiting
TELEGRAM_MIN_INTERVAL_SECS=1.5

# Startup behavior
SKIP_HISTORY_ON_FIRST_RUN=1

Notes


5) Service control

bash
# status / follow logs
sudo systemctl status seiue-notify --no-pager
journalctl -u seiue-notify -f

# start / stop / restart
sudo systemctl start seiue-notify
sudo systemctl stop seiue-notify
sudo systemctl restart seiue-notify

Log files (besides journalctl):

text
~/.seiue-notify/logs/notify.out.log
~/.seiue-notify/logs/notify.err.log

No systemd? The installer uses:

bash
nohup ~/.seiue-notify/run.sh >/dev/null 2>&1 &

Check with:

bash
pgrep -a -f '/\.seiue-notify/venv/bin/python .*/seiue_notify\.py'

6) How it works (under the hood)


7) First‑run confirmation

Right after installation, the script runs:

bash
~/.seiue-notify/venv/bin/python ~/.seiue-notify/seiue_notify.py --confirm-once

If you didn’t receive the confirmation:


8) Resetting the watermark (start “from now”)

bash
rm -f ~/.seiue-notify/notify_state.json
sudo systemctl restart seiue-notify

With SKIP_HISTORY_ON_FIRST_RUN=1, the service will skip history and resume from the latest item after restart.


9) Update / Upgrade

Simply re‑run the installer:

bash
bash <(curl -Ls https://raw.githubusercontent.com/ieduer/bdfz/main/seiue-notify.sh)
bash
sudo bash seiue-notify.sh --reconfigure

10) Uninstall

bash
sudo systemctl stop seiue-notify
sudo systemctl disable seiue-notify
sudo rm -f /etc/systemd/system/seiue-notify.service
sudo systemctl daemon-reload
rm -rf ~/.seiue-notify

11) Security notes


12) Defaults & Paths


Quick reference

bash
# inspect
systemctl status seiue-notify --no-pager
journalctl -u seiue-notify -f

# restart clean
rm -f ~/.seiue-notify/.notify.lock
sudo systemctl restart seiue-notify

# reset watermark (start from now)
rm -f ~/.seiue-notify/notify_state.json
sudo systemctl restart seiue-notify

This sidecar is designed to be quiet, durable, and independent—so your attendance workflow remains untouched while your Seiue inbox arrives in Telegram in real time.