Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mensa → Mattermost poster

Posts the daily menu from one OpenMensa canteen to a Mattermost channel via Incoming Webhook.

  • Canteen: defaults to ID 1779 (the mensa you linked: https://openmensa.org/c/1779)
  • Schedule: every weekday (Mon–Fri) at 10:00 local time (configurable)
  • Runtime: simple Python worker, Railway-ready

What it does

At the scheduled time, the script fetches the menu for the configured canteen from the OpenMensa API and posts a formatted message to your Mattermost channel using an Incoming Webhook.

Environment variables

Required

  • MATTERMOST_WEBHOOK: Mattermost Incoming Webhook URL

Optional (with defaults)

  • MENSA_ID: OpenMensa canteen ID. Default: 1779
  • TIMEZONE: IANA time zone name. Default: Europe/Berlin
  • POST_HOUR: Hour (0–23) to post. Default: 10
  • POST_MIN: Minute (0–59) to post. Default: 0
  • WEEKDAYS: APScheduler cron day_of_week string. Default: mon-fri

Tip: to find a canteen’s ID, open its page on OpenMensa (e.g. https://openmensa.org/c/1779 – the number is the ID).

Local run (Windows, cmd.exe)

  1. Install dependencies
pip install -r requirements.txt
  1. Set environment variables (example)
set MATTERMOST_WEBHOOK=https://mattermost.example/hooks/XXXX
set MENSA_ID=1779
set TIMEZONE=Europe/Berlin
  1. Start the worker
python mensa_spy.py

It will run continuously and post automatically according to the schedule. To test quickly, you can change POST_HOUR/POST_MIN to a minute or two in the future.

Deploy on Railway

This repo includes a Procfile with:

worker: python mensa_spy.py

Steps

  • Create a new Railway project from this repository
  • In Railway → Variables, add:
    • MATTERMOST_WEBHOOK (required)
    • Optionally MENSA_ID, TIMEZONE, POST_HOUR, POST_MIN, WEEKDAYS
  • Deploy. The worker process will stay running and post at the scheduled time.

Message format

The post includes the canteen name, city, date, and each meal line with category and (if available) student price.

Troubleshooting

  • No menu today: Some days return 404/empty menus; the script posts an empty/none message accordingly.
  • Time zone on Windows: The project includes tzdata so IANA time zones (like Europe/Berlin) work reliably.
  • Webhook errors: Ensure MATTERMOST_WEBHOOK is correct and accessible from Railway.

License

See LICENSE.

About

Code required to get the info of mensa meals and trasnfer it to --> railway -->mattermost bot @mensaspy

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages