Industry observers note that I started my master's a couple of months late, which meant catching up on everything at once: deadlines in five courses, announcements I'd missed, and a timetable I didn't know yet. And every time I wanted to check any of it, I had to go through this:.

So I did what any reasonable person does to avoid a 30-second chore: I spent a day automating it.

The result is moodle-watch, a small Python bot that runs free on GitHub Actions and posts this to my Slack:.

Here are the interesting bits, including the parts I got wrong first.

Recent findings suggest that my first thought was "keep the login session alive on a server, or generate the authenticator code automatically". Both are bad ideas:.

The actual answer was hiding in plain sight: the official Moodle mobile app.

It has been revealed that first check that your Moodle allows it. This public endpoint needs no login:.

Look for "enablemobilewebservice": 1. Then the app opens:.

You sign in as usual, and Moodle redirects the browser to moodlemobile://token=. Your browser can't open that link, but DevTools shows it in the location response header. The base64 decodes to:.

That first part is a signature, so the helper script checks it to make sure the token came from the link it just generated:.

Recent findings suggest that get_token.py wraps all of this. It checks your Moodle is compatible, prints the link, takes the pasted value at a hidden prompt, tests the token, and stores it straight into your repo's GitHub secrets with gh secret set, so it never appears on screen. You do the authenticator step once a term, in your own browser.

That token can act as you: submit work, post in forums, send messages. So the watcher refuses to call anything that isn't on a read-only allowlist:.

Every 30 minutes, a GitHub Actions cron job reads deadlines, assignments, forums, notifications, grades, course contents and calendar events. It compares them with the previous run's state and posts only what changed. The first run just records what already exists, so you don't get a flood of old items.

Industry observers note that classes turned out to be in Moodle too: my lecturer uses the Attendance plugin, and every session is a calendar event with a start time and duration. Those become the morning class list and the 30-minute reminders.

It has been revealed that gitHub's scheduler routinely starts jobs 5–15 minutes late, which is fine for "new grade" but useless for "class in 30 minutes". Two fixes:.

I wanted classmates to fork it with one click. But forks are public, and so are their GitHub Actions logs. That changed the design:.

Then I found a subtler leak. Pull-request workflows from forks can read the default branch's Actions cache, which is where the state lives. And the state held SHA-256 hashes of grades. A grade like 8,00 has maybe a few hundred possible values, so you can reverse its hash by trying them all in under a second.

The fix is to key the hash with a secret that pull requests never get:.

When the token is renewed the key changes, so the watcher quietly re-baselines grades instead of reporting every grade as "changed". It still alerts for grade items it has never seen. On top of that, the repo requires approval before any outside contributor's pull request runs workflows.

GitHub disables scheduled workflows in public repos after 60 days without activity. A fork that just quietly runs would go silent around week nine. The usual fix is a bot that makes empty commits, but that makes forks drift from upstream, so every "Sync fork" turns into a merge.

Instead, the job re-enables its own workflow through the API once a day:.

A bot that fails silently is worse than no bot. So:.

In a recent development, it defaults to my university's Moodle, but --url points it at yours, and the setup script tells you right away if your Moodle has the mobile app turned off. Check your university's IT rules if you're unsure. It uses the same API and token as the official Moodle app.

Complications and pull requests are welcome, especially from people whose Moodle is set up differently from mine.

It has been revealed that built with Claude Code as my AI pair programmer. I steered the design and tested it against my own Moodle.

πŸ“Œ Read also:

β†’ Read original article