Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Split Bot

A Telegram bot that tracks shared expenses in group chats. Record who paid for what, see who owes whom, and settle debts — all within your Telegram group.

What the bot does

@split_bot keeps a running tab for your group:

  1. Someone pays for something and records it with /split.
  2. The bot tracks who owes whom across all splits.
  3. /tab shows net balances — mutual debts cancel automatically.
  4. /settle records payments to clear debts.

It runs in Telegram groups only. If you PM the bot, it will explain that it needs to be added to a group.

Quick start

1. Add the bot to your Telegram group

Add @split_bot to a group chat.

2. Register

Each participant sends once:

/register

3. Record an expense

When you pay for something, record who owes what:

/split dinner
- @ernest $14
- @kenneth $14

You (the sender) are the payer by default. To specify someone else:

/split dinner paid by @justin
- @ernest $14
- @kenneth $14

4. Check balances

/tab

Example output:

💰 Group Tab
━━━━━━━━━━━━
Kenneth owes Justin — $14
Kenneth owes Ernest — $14

Total outstanding: $28

5. Settle up

Clear your full debt with someone:

/settle @ernest

Or record a partial payment:

/settle @ernest $10

Commands

Command What it does
/register Join the group
/split Record a shared expense
/tab Show who owes whom (net balances)
/tab history Show recent split/settle transactions
/settle @name Clear your full debt with someone
/settle @name $10 Record a partial payment
/remove @name Remove a participant
/help Show commands and examples

How balances work

Balances are cumulative and net. Every /split and /settle adds to the ledger, and /tab always shows the current net across all transactions.

Example:

  1. Justin pays for lunch: Ernest owes Justin $14, Kenneth owes Justin $14
  2. Ernest pays for dinner: Justin owes Ernest $14, Kenneth owes Ernest $14
  3. /tab now shows: Justin and Ernest are even. Kenneth owes Justin $14, Kenneth owes Ernest $14.

Mutual debts cancel automatically — no manual netting needed.

Self-hosting

Prerequisites

  • Python 3.11+
  • A Telegram bot token from @BotFather
  • A publicly reachable URL for the webhook

Run locally

pip install -e ".[dev]"
cp .env.example .env    # fill in TELEGRAM_BOT_TOKEN, WEBHOOK_SECRET, PUBLIC_BASE_URL
uvicorn app.main:app --host 0.0.0.0 --port 8080

Run with Docker

cp .env.example .env    # fill in secrets
docker compose up --build

The bot serves on host port 8789.

Run tests

pytest              # all tests
pytest -k split     # split-specific
pytest -k settle    # settle-specific

Environment variables

Variable Description Default
TELEGRAM_BOT_TOKEN Bot token from BotFather (required)
WEBHOOK_SECRET Secret for webhook verification (required)
PUBLIC_BASE_URL Public URL where the bot is reachable https://split.yourdomain.com
DATABASE_PATH SQLite database file path /data/split.sqlite3
TIMEZONE Timezone for timestamps Asia/Singapore

The bot auto-registers its webhook with Telegram on startup using PUBLIC_BASE_URL.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages