A tiny Telegram bot that acts as a two-person Splitwise for Aaa and Bbb. Runs on your Mac (or a Raspberry Pi) whenever you start it, stores everything in one SQLite file.
Default split is 50/50. Amounts accept 24.50 or 24,50.
| Command | What it does |
|---|---|
/iam aaa or /iam bbb |
One-time registration. Each name can be claimed once; afterwards the bot ignores everyone else. |
/add 24.50 groceries |
You paid 24.50, split 50/50. |
/add 60 internet bbb 2/3 |
You paid 60. Bbb's share is 2/3, Aaa's the rest. |
/add 30 pizza aaa 70% |
Aaa's share is 70%, Bbb's 30%. |
/add 15 gift aaa 100% |
Aaa's share is everything (you paid fully for her). |
/add 12 taxi by bbb |
Log an expense that Bbb paid. |
/edit 3 |
Show entry 3 and the ways to change it. |
/edit 3 +5 |
Add 5 to the amount of entry 3. |
/edit 3 -10 |
Take 10 off the amount. |
/edit 3 30 |
Set the amount to exactly 30. |
/edit 3 bbb 2/3 |
Change the split (percent works too: aaa 70%). |
/edit 3 by aaa |
Change who paid. |
/edit 3 pizza night |
Change the description. |
/edit -10 |
Leave out the number to change the last entry. |
/balance |
Who owes whom. |
/history |
Last 10 entries with their numbers. |
/undo |
Delete the most recent entry. |
/delete 12 |
Delete entry number 12. |
/settle |
Record a payment from the debtor to the creditor that brings the balance to zero. |
/help |
Show the command list. |
Split rule: <name> <share> sets that person's share, the other gets the remainder.
Share can be a percentage (70%) or fraction (2/3). Everything else in the line is the description.
Editing:
- The entry number is shown when you add something, and in
/history. - Changes can be combined in one command:
/edit 3 +5 bbb 70%. - If you only change the amount, the existing split ratio is kept (a 2/3 - 1/3 entry stays 2/3 - 1/3).
- A change shows the entry before and after, plus the new balance, and the other person is notified as with
/add. - Settlements cannot be edited.
/deleteit and run/settleagain. - An amount that would drop to 0 or below is refused; use
/deleteinstead.
Details:
- Money is stored in integer cents, shares are rounded so both always add up to the total.
- The balance is calculated from all entries, so deleting a wrong entry corrects it.
- After an add, delete or settle, the other person gets a message if they use a different chat (for example two private chats with the bot). In a shared group it just replies once.
- Works in a private chat or in a group with both of you and the bot.
The bot does not need to be online all the time. Telegram holds on to messages sent to the bot while it is offline and delivers them in order as soon as you start it again.
- Everything you both typed while it was off is processed on start: expenses are
saved,
/undoand/deleteapply in the order they were sent. - Each entry is stamped with the time the message was sent, not the time of processing.
- Replies for late messages end with a note like
(sent 03 Dec 14:05, processed after restart). Balances in those replies are the running balance at processing time. - Limit: Telegram keeps undelivered messages for 24 hours only. If the bot stays off longer than that, older messages are lost, so start it at least once a day if you want nothing to go missing, or re-enter anything that got no reply.
- Messages that get no reply simply have not been processed yet.
- Create the bot: in Telegram talk to @BotFather, send
/newbot, copy the token. - Install uv once:
brew install uv(orcurl -LsSf https://astral.sh/uv/install.sh | sh). - In this folder:
uv creates the environment on first run. Leave the terminal open; Ctrl+C stops the bot.
cp .env.example .env open -e .env # paste the token, set CURRENCY if you like uv run --no-dev bot.py - First time only: send
/iam aaa//iam bbbfrom each of your accounts straight away, so nobody else can claim a name.
Next time just run uv run --no-dev bot.py again. Your data stays in flat.db.
Use the same folder every time, otherwise you start with an empty database.
Only one copy of the bot may run per token. If you also run it on a Pi, stop that one first.
curl -LsSf https://astral.sh/uv/install.sh | sh
cd /home/pi/splitbot
uv sync --no-dev
cp .env.example .env && nano .env
sudo cp splitbot.service /etc/systemd/system/
sudo systemctl enable --now splitbot
journalctl -u splitbot -f # logs
Edit the paths in splitbot.service if your user is not pi or the folder differs.
uv sync # includes ruff and ty
uv run ruff check --fix .
uv run ruff format .
uv run ty check
- Data lives in
flat.dbnext tobot.py. Back it up by copying the file. - To reset registrations:
sqlite3 flat.db "DELETE FROM users;" - To wipe all expenses:
sqlite3 flat.db "DELETE FROM expenses;" - Update: replace
bot.py(andpyproject.toml/uv.lockif changed), runuv sync --no-dev, thensudo systemctl restart splitbot.
- Be quick to claim both Aaa and Bbb, until then anyone can claim their spot and execute the available commands
- This project's scope is quite small, it has been vibe coded, but I have reviewed the result.