Kafeteria
Kafeteria is a Python package to asynchronously access the menu of the cafeterias at KAIST.
KAIST 학식 메뉴를 asyncio를 사용하여 불러올 수 있는 Python 패키지입니다.
Installation
Kafeteria requires Python 3.12 or newer.
Install the package using pip:
pip install kafeteria
If you want optional Slack integration, install with the slack extra:
pip install kafeteria[slack]
Usage
Use the get_menu function to get the menu for a specific cafeteria, or the get_menus function to get the menus for multiple cafeterias at once.
Valid cafeteria codes are:
fclt: 카이마루west: 서측식당east1: 동측 학생식당east2: 동측 교직원식당emp: 교수회관icc: 문지캠퍼스hawam: 화암 기숙사식당seoul: 서울캠퍼스 구내식당
Here's an example:
import asyncio
import datetime
import kafeteria
async def main():
# Get the menu for a specific cafeteria
menu = await kafeteria.get_menu("fclt")
print(menu)
# Get the menu for a specific date
menu = await kafeteria.get_menu("fclt", datetime.date(2025, 1, 3))
print(menu)
# Get the menus for multiple cafeterias at once
menus = await kafeteria.get_menus(["fclt", "east1", "east2"])
print(menus)
asyncio.run(main())
Slack Integration
You can also publish today's menu to a Slack channel using the kafeteria.slack.publish function.
First, you need to set up a Slack app with the chat:write permission. Once you have a bot set up with the necessary permissions, set the following environment variables:
-
KAFETERIA_SLACK_BOT_TOKEN(required): The bot token for the Slack app. -
KAFETERIA_SLACK_CHANNEL(required): The channel ID to post the message to.This can be found by right-clicking on the channel in the Slack app and selecting "Copy link". The channel ID is the last part of the URL.
For more information, see the slack api documentation.
-
KAFETERIA_MENU_TIME(optional): The menu to send.This can be one of 0, 1, 2, or 3. The behavior is as follows:
-
1: breakfast
-
2: lunch
-
3: dinner
-
0: default, automatically selects the menu based on the current time:
- breakfast: 19:30 - 09:00
- lunch: 09:00 - 14:00
- dinner: 14:00 - 19:30
-
-
KAFETERIA_LIST(optional): The list of cafeterias to send the menu for.This should be a comma-separated list of cafeteria codes. By default,
fclt,west,east1,east2is used. -
KAFETERIA_IGNORE_PROFONLY(optional): Whether to ignore the "professor only" menu.This flag is used to filter out the "professor only" (교수전용) menu from the list of menus. If enabled, all lines below a line that contains
교수전용will be stripped from the menu. This can be set to0or1. By default, it is set to1(enabled).
Then, you can publish the menu to a channel using kafeteria.slack.publish():
import asyncio
import kafeteria.slack
asyncio.run(kafeteria.slack.publish())
A shortcut function kafeteria.slack.run_publish() is provided for running in non-async environments.
kafeteria.slack.publish() and kafeteria.slack.run_publish() takes an optional keyword-only parameter, skip_holiday, which, if set to True, skips publishing the menu when the current day is a holiday in Korea.
Automation
Slack integration can be automated to publish the menu at a specific time every weekday using a scheduler. An example using apscheduler is provided in the kafeteria.scheduler module, which can be started by running the following command:
python -m kafeteria.scheduler
If you want to handle the automation in CI/CD, here is an example GitHub Actions workflow. Note that scheduled workflows may be delayed depending on the GitHub Actions server load.
name: Publish Menu
on:
schedule:
# Every weekday at 11:30 AM GMT+9 (2:30 AM UTC)
- cron: "30 2 * * 1-5"
env:
KAFETERIA_SLACK_BOT_TOKEN: ${{ secrets.KAFETERIA_SLACK_BOT_TOKEN }} # Set in repository secrets
KAFETERIA_SLACK_CHANNEL: "C0123456789" # Replace with your channel ID
KAFETERIA_MENU_TIME: "0" # Automatically select the menu based on workflow run time
KAFETERIA_LIST: "fclt,west,east1,east2"
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install dependencies
run: pip install kafeteria[slack]
- name: Publish menu
run: python -c 'import kafeteria.slack; kafeteria.slack.run_publish(skip_holiday=True)'
Metadata
Release files for kafeteria 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kafeteria-0.5.0.tar.gz | 71.3 kB | Without provenance | Details for kafeteria-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kafeteria-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for kafeteria-0.5.0-py3-none-any.whl |
Total release size: 81.3 kB
Release files / kafeteria-0.5.0.tar.gz
| Download URL | kafeteria-0.5.0.tar.gz |
|---|---|
| Size | 71.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d8eb794810fc5e9468e7fa4624ee907ae6b1b4ae084e5766bb85d7838bb0e06d
|
|
BLAKE2b-256 checksum How to use checksums |
754da267511981c128e1b1e721778e516f3b847b29658332ec0f591f5bf82295
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / kafeteria-0.5.0-py3-none-any.whl
| Download URL | kafeteria-0.5.0-py3-none-any.whl |
|---|---|
| Size | 10.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1cb4e78f53c90b4a271c789d9ae4419890fd1a5577174887332e2b25a77e41d1
|
|
BLAKE2b-256 checksum How to use checksums |
e975ea9cbfe75af0276c373183e7452e5f635acf9277606691835f875e335b96
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for kafeteria 0.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.