Telegram bot for logging diabetes diary data into CSV files.
This bot stores all diary data as plain text files (.csv, .txt) on disk.
- Data is saved as is.
- Data is not encrypted at rest by this bot.
- You should use this bot only if you are comfortable with local plain-text storage, or protect storage separately (disk encryption, access controls, backups policy).
- Create
pdd-bot/config.toml:
tg_bot_token = "<YOUR_TELEGRAM_BOT_TOKEN>"
tg_chat_id = ["<YOUR_CHAT_ID>"]
data_dir = "data"
input_timezone = "Europe/Kyiv"
glucose_after_meal_reminder_minutes = 150
glucose_after_meal_reminder_count = 3
glucose_after_meal_reminder_interval_minutes = 15- Build and run:
cd pdd-bot
cargo run- In Telegram, open your bot and send:
/start(show menu)/addgb 5.8 @fasting(example glucose before meal)
- Glucose logging with tags:
- before meal
- after meal
- Weight logging
- Medication list with dynamic Telegram buttons
- Medication usage logging
- Optional glucose note starting with
@ - Optional glucose date/time in flexible formats
- Configurable after-meal glucose reminders
pdd-bot/— Rust Telegram bot
All records are stored in configured data_dir (default: data) and grouped per Telegram user/chat id.
Structure:
data/<user_id>/glucose.csv— glucose measurementsdata/<user_id>/weight.csv— weight measurementsdata/<user_id>/medications.txt— medication names (one per line)data/<user_id>/medication_log.csv— medication usage events
- Rust toolchain (stable)
- Telegram bot token from BotFather
- Your Telegram chat id
Create pdd-bot/config.toml:
tg_bot_token = "<YOUR_TELEGRAM_BOT_TOKEN>"
tg_chat_id = ["<YOUR_CHAT_ID>"]
data_dir = "data"
input_timezone = "Europe/Kyiv"
glucose_after_meal_reminder_minutes = 150
glucose_after_meal_reminder_count = 3
glucose_after_meal_reminder_interval_minutes = 15Fields:
tg_bot_tokenis required. Use the Telegram bot token from BotFather.tg_chat_idis required. It is a list of allowed Telegram chat IDs.data_diris optional. It defaults todata.input_timezoneis optional. It defaults toUTCand is used to interpret manually entered date/time without timezone.glucose_after_meal_reminder_minutesis optional. It defaults to150; set it to0to disable after-meal reminders.glucose_after_meal_reminder_countis optional. It defaults to3; set it to0to disable after-meal reminders.glucose_after_meal_reminder_interval_minutesis optional. It defaults to15and controls the delay between repeated reminders.
Reminder behavior:
- Adding glucose before meal schedules after-meal reminders for that chat.
- Adding glucose after meal cancels pending after-meal reminders for that chat.
- The first reminder is sent after
glucose_after_meal_reminder_minutes. - Additional reminders are sent every
glucose_after_meal_reminder_interval_minutesuntilglucose_after_meal_reminder_countreminders have been sent.
Notes:
- Timestamps are stored in UTC in CSV files.
- Replace token/id values with your own.
From repository root:
cd pdd-bot
cargo buildRelease build:
cd pdd-bot
cargo build --releaseWith default config (config.toml):
cd pdd-bot
cargo runWith custom config path:
cd pdd-bot
cargo run -- --config path/to/config.tomlConfig check command:
cd pdd-bot
cargo run -- check-config --config config.toml- Send
/startor/menu. - Use buttons:
🩸 Glucose: Before meal🩸 Glucose: After meal⚖️ Weight- medication buttons (
💊 ...)
For glucose button flow, send:
<value> [date time] [@note]
Examples:
5.87.2 2/1 11:006.4 2024/2/1 09:05 @after oatmeal + tea
For weight button flow, send value only:
78.4
/help— show help/menu— show buttons/addmed <name>— add medication button/addgb <value> [date time] [@note]— add glucose before meal/addga <value> [date time] [@note]— add glucose after meal
Aliases:
/add_glucose_before/add_glucose_after
Examples:
/addmed Metformin
/addgb 5.6 @fasting
/addga 7.8 2/1 10:30 @after breakfast
/addgb 6.1 2024/2/1 9:05 @before gym
Accepted date/time part:
MM/DD hh:mmYY/MM/DD hh:mmYYYY/MM/DD hh:mm
Rules:
- month/day/hour/minute can be 1 or 2 digits
- year can be 2 or 4 digits
- if year is omitted, current year is used
-and.are also accepted as date separators
Examples:
2/1 9:0502/01 09:0524/2/1 9:052024/2/1 9:05
Use @ to start note text:
... @your note text with spaces and symbols !?+#
Everything after @ is saved as note.
- Bot does not reply:
- verify
tg_bot_token - verify your chat id is included in
tg_chat_id - send
/startto bot in Telegram first
- verify
cargo runexits with error:- verify
config.tomlexists - verify token/chat id format
- verify