Skip to content

Latest commit

 

History

History
44 lines (38 loc) · 1.44 KB

File metadata and controls

44 lines (38 loc) · 1.44 KB

SplitLLM Telegram Bot

A standalone Telegram bot for the SplitLLM application, enforcing Service-to-Service authentication.

Features

  • Personal Expenses: Send text like "Lunch 20" to add personal expenses.
  • Group Expenses:
    • Use /g_expense <group_name> <amount> <description>
    • Or upload a receipt and select a group.
  • View Data: Check /dues, /stats, /groups, and /friends.

Setup

  1. Create Virtual Environment:

    python3 -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  2. Install Dependencies:

    pip install -r requirements.txt
  3. Environment Variables: Copy .env.example to .env and fill in:

    • TELEGRAM_BOT_TOKEN: From @BotFather.
    • BOT_SERVICE_SECRET: A secure random string shared with the Backend.
    • BACKEND_URL: URL of your running backend.

Authentication Flow

This bot does not handle user login directly.

  1. User Linking:
    • User logs into the SplitLLM Web/App.
    • User requests to "Link Telegram".
    • Backend generates a unique linking code.
    • User enters this code in the Web/App.
    • Backend validates and stores the telegram_id against the user's account.
  2. Bot Requests:
    • The Bot sends X-Telegram-User-ID and X-Bot-Secret on every request.
    • The Backend verifies the Secret and uses the ID to identify the user.

Running

python bot.py