Ed · Moodle · OnTrack · exams → your Telegram
A self-hosted, read-only study assistant bot for Monash students
English · 简体中文
A small, self-hosted Telegram bot for Monash students. It watches Ed, Moodle, OnTrack and the
student portal exam timetable, pushes what's new to your private Telegram chat, and answers a few
commands (/due, /grades, /exams, …).
It runs on any small Linux server as a few systemd units. Everything is read-only: it never posts, submits or changes anything on Ed, Moodle, OnTrack or the portal.
Language: every Telegram message comes in English or Simplified Chinese — set
"language"in the config.This is an independent personal project, not affiliated with Monash University. Before connecting your account, check that the access pattern complies with Monash, Moodle and Ed rules, and keep polling conservative (the included timer runs every 10 minutes).
- Ed — new threads and announcements in every active unit (with a body preview and attached images as
one album), new lessons and their due dates. Staff posts about exams, changed deadlines or cancelled
classes are flagged 🚨 and tagged (
#考试,#变更, …). - Moodle — new tasks and deadline reminders (default 72 h / 24 h / 3 h before, skipped once the
real submission status says it's submitted; drafts get a warning), announcements, newly released
grades, new course materials and lecture recordings. New files are archived on the server as
files/<UNIT>/<Week N>/and sent to Telegram as documents. - Grades and WAM estimate — per-unit mark from weighted Moodle items (weights read from names like
Assignment 1 (Weight: 12%), plus your owngrade_weights), what you still need on the rest to pass, and a first-year WAM estimate (MPU units excluded). - Attendance-code reminders — finds attendance codes that staff post on Ed and Moodle (in text, or in
table images read with OCR), pushes each new one, lists them with
/codeand in the briefings. It only reminds you: it never opens the attendance site and never submits a code. - OnTrack — task status changes, new tutor comments, target-date reminders, and a progress summary. The OnTrack login can renew itself from a saved Okta browser session.
- Exams — exam timetable from the student portal: new or changed exams, removed exams, a 7-day and 1-day reminder, and a countdown in the briefings.
- Briefings — a daily morning briefing (deadlines in the next 48 h, exams, unfinished Ed lessons) and a weekly preview (plus grades).
- Optional iCalendar feed of deadlines and exams, for subscribing in any calendar app.
- Server health — disk, memory, swap and TLS certificate expiry alerts.
- Optional automatic login renewal — a Chrome extension and a small Mac agent hand your browser's Moodle / Okta / portal logins to the server when its own have expired.
- Owner only — the bot only ever sends to, and only answers, one private chat.
| Command | What it does |
|---|---|
/today |
Today's briefing: deadlines in the next 48 h, exams, unfinished Ed lessons |
/week |
The next 7 days, plus grades |
/due |
Deadlines in the next two weeks, finished ones folded away |
/code |
Attendance codes found for the last 3 and next 7 days (reminder only, never submitted) |
/grades |
Marks per unit, WAM estimate, what you need to pass |
/exams |
Exam times, places and countdown |
/ontrack |
OnTrack task progress |
/remind 7 3 1 |
Remind N days before deadlines (12h = hours; /remind reset for the default) |
/okta <cookie> |
Save an Okta session so OnTrack can renew itself (the message is deleted right away) |
/status |
Login status and server health |
/help |
Command list |
src/ the Python code (monitor.py = checks, bot.py = commands, one module per source)
scripts/ shell entry points: run-once.sh, setup-telegram.sh, *-login.sh, renew-recv.sh, env.sh
bin/ secret-tool, a file-backed keyring stand-in for moodle-cli on headless servers
deploy/ systemd units and an optional nginx config for the calendar feed
examples/ config.example.json, telegram.env.example
renew/ optional Mac side of the login renewal: Chrome extension + launchd agent
tests/ unit tests (no network, no accounts)
docs/ images for this README
- Linux with systemd (tested on Ubuntu LTS), Python 3.11+ (standard library only).
- Node.js 22.13+ for the two CLIs below.
- edstem-cli —
npm install -g edstem-cli, thenedstem auth login. - moodle-cli —
npm install -g moodle-cli, thenmoodle auth login(ormoodle-login.shon a server without a browser, see below). - A Telegram bot from @BotFather.
OnTrack and the student portal are optional and talk to their web APIs directly — no extra tools.
For codes posted as images, install tesseract
(sudo apt install tesseract-ocr); Pillow (pip install pillow) is optional and improves small screenshots.
The code expects one directory, $MONASH_MONITOR_HOME (default ~/monash-monitor):
~/monash-monitor/
app/ this repository (see Repository layout)
config/ config.json
data/ state.sqlite3 (created on first run)
secrets/ telegram.env, ontrack.env, okta.cookie, portal.json, calendar.token, keyring/ (mode 0600)
files/ archived Moodle files
mkdir -p ~/monash-monitor/{config,data,secrets} && chmod 700 ~/monash-monitor/secrets
git clone https://github.com/byProCode/edmoodle-bot ~/monash-monitor/app
cp ~/monash-monitor/app/examples/config.example.json ~/monash-monitor/config/config.json- Ed —
edstem auth login. - Moodle —
moodle auth login. On a headless server use~/monash-monitor/app/scripts/moodle-login.shand paste theMoodleSessioncookie from your browser.bin/secret-toolis a small file-backed stand-in for libsecret so moodle-cli can cache its session on a server without a keyring (it is put on the PATH byenv.sh). - Telegram — run
~/monash-monitor/app/scripts/setup-telegram.sh: paste the bot token, send your bot any message in a private chat, confirm it's you, and it writessecrets/telegram.env(chat id and username lock) and sends a test message. (Or copyexamples/telegram.env.examplethere by hand.) - OnTrack (optional) —
scripts/ontrack-login.sh(paste therefresh_tokencookie), and/orscripts/okta-login.shor/oktawith yourmonashuni.okta.comcookie so the OnTrack login renews itself. - Exams (optional) —
scripts/portal-login.sh; the steps are in the comment at the top of the script. - First run —
~/monash-monitor/app/scripts/run-once.sh. The first run only records a baseline (and sends one "online" message), so you aren't flooded with old posts.scripts/run-once.sh --dry-runprints instead of sending.
| Variable | Where | Meaning |
|---|---|---|
TELEGRAM_BOT_TOKEN |
secrets/telegram.env |
Bot token from @BotFather |
TELEGRAM_CHAT_ID |
secrets/telegram.env |
Your private chat id with the bot; nothing is sent anywhere else |
TELEGRAM_ALLOWED_USERNAME |
secrets/telegram.env |
Optional: your Telegram username (no @) as an extra lock |
MONASH_MONITOR_HOME |
environment | Optional: base directory instead of ~/monash-monitor |
Ed and Moodle credentials stay inside the CLIs' own caches. Never commit any of these files.
config/config.json is merged over the defaults in src/monitor.py, so you only need the keys you change.
| Key | Default | Meaning |
|---|---|---|
language |
zh-CN |
Language of every Telegram message: en (English) or zh-CN (Simplified Chinese) |
timezone |
Asia/Kuala_Lumpur |
Time zone for all times shown |
error_alert_hours |
6 |
Repeat an error alert at most this often |
preview_chars |
700 |
Length of the quoted post body (announcements get twice this) |
ed |
||
ed.enabled |
true |
Watch Ed |
ed.region |
au |
Ed region used in links |
ed.units |
"auto" |
"auto" = every active unit, or a list of course ids / unit-code prefixes |
ed.threads_limit |
30 |
Newest threads read per unit per run |
ed.lessons |
true |
Watch lessons and their due dates |
ed.images |
true |
Send images in posts as an album |
moodle |
||
moodle.enabled |
true |
Watch Moodle |
moodle.base_url |
https://learning.monash.edu |
Your Moodle site (the session cookie is only sent to this host) |
moodle.due_days |
30 |
How far ahead to read deadlines |
moodle.reminder_hours |
[72, 24, 3] |
Reminders before a deadline (/remind overrides this) |
moodle.news |
true |
Announcements |
moodle.grades |
true |
Newly released grades |
moodle.grade_weights |
{} |
Extra weights by name fragment, e.g. {"ABC1001": {"pre-reading quiz": 10}} — a group of items that share 10% |
moodle.materials |
true |
New activities / resources / recordings on unit pages |
moodle.materials_minutes |
30 |
Check unit pages at most this often |
moodle.files |
true |
Download new files and send them as Telegram documents (≤ 45 MB) |
moodle.submission_hours |
72 |
Read the real submission status of tasks due within this window |
moodle.images |
true |
Send images in announcements as an album |
moodle.keepalive |
true |
Keep the Moodle session alive each run |
ontrack |
||
ontrack.enabled |
true |
Watch OnTrack (silent until you sign in) |
ontrack.reminder_hours |
[72, 24] |
Reminders before a task's target date |
ontrack.relogin_warn_hours |
24 |
Warn this long before the OnTrack login expires when nothing can renew it |
codes |
||
codes.enabled |
true |
Attendance-code reminders from Ed / Moodle posts |
codes.ocr |
true |
Read codes from images in posts (needs tesseract) |
codes.classes |
[] |
Only your classes, e.g. ["ABC1001 applied 5", "ABC1002 workshop 2"]; empty = every class |
exams |
||
exams.enabled |
true |
Watch the exam timetable (silent until you connect the portal) |
exams.minutes |
60 |
Check at most this often |
exams.exam_reminder_hours |
[168, 24] |
Reminders before each exam |
calendar |
||
calendar.enabled |
false |
Write an .ics feed of deadlines and exams |
calendar.dir |
/var/www/monash-cal |
Where to write it; the file name is a random secret (secrets/calendar.token). See deploy/nginx/monash-cal.conf |
health |
||
health.enabled |
true |
Server health alerts |
health.domains |
[] |
Domains whose TLS certificates to watch |
health.cert_days |
14 |
Alert when a certificate has fewer days left |
health.disk_pct |
85 |
Alert above this disk use |
health.mem_mb |
200 |
Alert below this much available memory |
health.swap_pct |
70 |
Alert above this swap use |
health.repeat_hours |
12 |
Repeat a health alert at most this often |
The units in deploy/systemd/ assume user ubuntu and /home/ubuntu/monash-monitor; edit User, Group,
HOME and the paths if yours differ, and the time zone in the two briefing timers.
| Unit | What it does |
|---|---|
monash-monitor.service + .timer |
One check every 10 minutes |
monash-bot.service |
The command bot (long-polling, always on) |
monash-briefing@.service + monash-briefing-daily.timer |
Daily briefing at 07:30 |
monash-briefing-weekly.timer |
Weekly preview on Sunday 20:00 |
sudo cp ~/monash-monitor/app/deploy/systemd/* /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now monash-monitor.timer monash-bot.service monash-briefing-daily.timer monash-briefing-weekly.timer
journalctl -u monash-monitor.service -n 50Other useful runs: scripts/run-once.sh --only moodle, scripts/run-once.sh --briefing daily --dry-run,
scripts/run-once.sh --sample (send the newest Ed thread and Moodle notice as a format sample),
scripts/run-once.sh --calendar.
Server-side logins expire: Moodle sessions, the Okta session that renews OnTrack, and the student-portal login. Instead of pasting cookies by hand, you can let the Chrome you already sign in with hand them over:
Chrome extension (renew/extension) ──HTTP, 127.0.0.1 only──▶ Mac agent (renew/renew_agent.py)
──SSH, key restricted to one command──▶ server: renew-recv.sh → renew_recv.py
- The extension watches the Okta (
monashuni.okta.com) and Moodle (learning.monash.edu) login cookies, and reads the student-portal login when you openhome.student.monash. It sends them only to the agent on127.0.0.1:47321, with a local token; a heartbeat runs every 30 minutes. The popup shows the last result and has a "check now" button. It follows Chrome's language: Simplified Chinese, otherwise English. - The agent (launchd, standard-library Python) needs the local token on every request and refuses any
request sent from a web page (any
Originother thanchrome-extension://); it throttles and forwards over SSH. It stores only a hash of each value, never the value. - On the server,
src/renew_recv.pyreplaces a login only when the server's own one has stopped working (or, for Okta, when the pushed session lasts clearly longer) and the pushed one works. Then it renews OnTrack and sends a Telegram notice. It logs todata/renew.logwithout login values.
Set up:
- On the Mac, from a clone of this repository:
It creates the SSH key
renew/install-mac.sh <server-host> [server-user] [ssh-port]
~/.ssh/monash_renew, records the server's host key (compare the fingerprint it prints with the server's), installs the launchd agent and prints a line for the server. - On the server, add that printed line to
~/.ssh/authorized_keys. It looks likerestrict,command="/home/ubuntu/monash-monitor/app/scripts/renew-recv.sh" ssh-ed25519 AAAA… monash-renew, so the key can run the receiver and nothing else. - In Chrome:
chrome://extensions→ Developer mode → Load unpacked →~/Library/Application Support/MonashRenew/extension.
Status on the Mac: python3 ~/Library/Application\ Support/MonashRenew/renew_agent.py status
(add --lang en or --lang zh-CN; by default it follows $LANG).
To turn it off: delete that line from the server's authorized_keys, and on the Mac run
launchctl bootout gui/$(id -u)/io.github.edmoodle-bot.renew and remove the extension.
The Ed token is not covered; if it stops working, run edstem auth login on the server. If your Moodle
is not learning.monash.edu, edit the host in renew/extension/manifest.json and background.js.
- Only
moodleandedstemcommands run, every one must ask for--json, and known mutation verbs (submit,post,reply,delete,--yes, …) are rejected before anything runs. - OnTrack is read through an allow-list of GET paths; the portal only reads the exam events.
- Attendance codes are only read from staff posts on Ed and Moodle and sent to you. Nothing in this project talks to the attendance site or submits a code.
- Before sending, the bot checks with Telegram that
TELEGRAM_CHAT_IDis a private chat (and, if set, owned byTELEGRAM_ALLOWED_USERNAME). Commands from anyone else are ignored silently. - Secrets are written with mode 0600 and never logged; Telegram errors never print the token URL.
- The optional renewal chain only ever sends logins from your own Chrome to your own server: the extension
talks to
127.0.0.1only, and the server key is limited toscripts/renew-recv.sh.
python3 -m unittest discover -s testsThe tests use fake CLI output and need no network or accounts.
Release notes are in the CHANGELOG. Issues and pull requests are welcome — see CONTRIBUTING. Please report security problems privately (SECURITY).
MIT — see LICENSE.