This project polls a private Telegram bot and appends messages to a OneDrive journal file in jrnl-style timestamp format.
- Journal output:
OneDrive\\telegram-jrnl.txt(append-only) - Media output:
OneDrive\\jrnl-media\\... - Attachment reference in journal: Markdown link to the saved media file path
- Timestamp format:
[YYYY-MM-DD HH:MM]from Telegram message metadata (message.date)
- Text message only:
- Appends:
[2026-03-02 19:00] your message
- Appends:
- Text + attachment:
- Saves file under
jrnl-media - Appends message with markdown link to media
- Saves file under
- Attachment/voice note without text:
- Saves file under
jrnl-media - Appends:
[timestamp] sent file [filename](path)
- Saves file under
- Open Telegram and chat with BotFather.
- Use
/newbotand copy the token. - Start a chat with your new bot and send it one message.
- Optional but recommended: find your chat ID and set
TELEGRAM_ALLOWED_CHAT_ID.
Edit .env:
TELEGRAM_BOT_TOKEN: bot token from BotFatherONEDRIVE_DIR: your OneDrive root folder- (optional)
TELEGRAM_ALLOWED_CHAT_ID: only accept messages from your chat - (optional)
TIMEZONE: force timezone likeAmerica/New_York
Use PowerShell in this folder and run:
./start_bot.ps1
Then message your bot from iPhone and verify:
OneDrive\\telegram-jrnl.txtupdatedOneDrive\\jrnl-mediahas attachments
4) Start with Windows (hidden background)
In PowerShell (Run as your user):
./install_startup.ps1
This creates a scheduled task named TelegramJrnlBot that starts at logon and runs hidden.
Useful commands:
- Start now:
Start-ScheduledTask -TaskName 'TelegramJrnlBot' - Stop now:
Stop-ScheduledTask -TaskName 'TelegramJrnlBot' - Remove startup:
./uninstall_startup.ps1
-
The bot uses long polling (no public webhook endpoint required).
-
State is tracked in
bot_state.jsonso old messages are not re-imported after restarts. -
Logs:
logs/telegram_jrnl_bot.loglogs/startup-wrapper.log
This repository is cross-platform. On a Linux droplet the easiest ways to have the bot write into OneDrive are:
A) Mount your OneDrive with rclone and point
ONEDRIVE_DIRat the mountpoint (recommended).- Install rclone:
curl https://rclone.org/install.sh | sudo bash(or use your package manager). - Run
rclone configand create a remote called e.g.onedrivefollowing the interactive prompts. - Mount the remote (temporary):
rclone mount onedrive: /mnt/onedrive --daemon
- Set
ONEDRIVE_DIR=/mnt/onedrivein.envand run the bot (see systemd below).
B) Or keep a local folder and let the bot push files using rclone after every write.
- Set
ONEDRIVE_REMOTEin.envto the rclone remote prefix you created, e.g.onedrive:my-jrnl. - The bot will call
rclone copytoto upload attachments and the journal file after each change. - Optionally set
RCLONE_REMOVE_LOCAL=trueto delete local media files after a successful upload (saves disk space on the server).
Example minimal
.env(see.env.examplein the repo):TELEGRAM_BOT_TOKEN="<your-token>" ONEDRIVE_DIR="/home/youruser/sandroidJrnlTelegramBot/onedrive" # Optional rclone upload instead of a mount # ONEDRIVE_REMOTE="onedrive:telegram-jrnl" # RCLONE_REMOVE_LOCAL=false # Optional: TELEGRAM_ALLOWED_CHAT_ID=123456789 # Optional: TIMEZONE=Europe/BerlinSystemd unit example (copy to
/etc/systemd/system/telegram-jrnl.serviceand editUserandWorkingDirectory):[Unit] Description=Telegram Jrnl Bot After=network-online.target [Service] Type=simple User=youruser WorkingDirectory=/home/youruser/sandroidJrnlTelegramBot EnvironmentFile=/home/youruser/sandroidJrnlTelegramBot/.env ExecStart=/usr/bin/env python3 telegram_jrnl_bot.py Restart=on-failure RestartSec=5 [Install] WantedBy=multi-user.targetAfter adding the unit run:
sudo systemctl daemon-reload sudo systemctl enable --now telegram-jrnl.service sudo journalctl -u telegram-jrnl -fNotes:
- If you use an rclone mount, ensure the mount unit starts before this service (use
After=/Wants=in the unit file). - The bot uses only the Python standard library; no extra pip packages are required unless you add them.