A Telegram bot designed to manage household expenses, payments, and donations for roommates. The bot helps track financial transactions, debt calculations, and provides various utilities for house management.
- User Management: Register new users, confirm accounts, and manage roommate status
- Expense Tracking: Add and view household expenses with categorization
- Payment Management: Record payments made to the house account
- Donation System: Track charitable contributions with leaderboard functionality
- Debt Calculation: Calculate individual debts and view overall debt status
- Interactive Commands: Conversational command system with validation
- Media Responses: GIF and video responses for better user experience
- Runtime: Node.js (>=18.0.0)
- Package Manager: PNPM (>=8.0.0)
- Database: SQLite with Sequelize ORM
- Bot Framework: node-telegram-bot-api
- Template Engine: Handlebars
- Process Manager: PM2
- Clone the repository:
git clone <repository-url>
cd ceku- Install dependencies:
pnpm install-
Configure the bot:
- Update
configs.jsonwith your Telegram bot token - Set the door password and IBAN information
- Update
-
Start the bot:
# Development mode
pnpm run dev
# Production mode
pnpm run startRegisters a new roommate in the system.
- Input: Name (letters only), Roommate status (1=Yes, 2=No, 3=Emre)
- Access: Public
- Response: Welcome GIF
Confirms user account with door password.
- Input: Door password
- Access: Public
- Response: Correct GIF
Displays all registered users with their status.
- Access: Protected (confirmed users only)
- Response: Formatted user list
Shows the sender's registered name.
- Access: Public
- Response: Plain text or unrecognized video
Records a new household expense.
- Input: Amount (integer), Label (≤20 chars), Description (≤200 chars)
- Access: Protected, Roommates only
- Response: Invoice confirmation
Records a payment to the house account.
- Input: Amount (integer), Description (≤200 chars)
- Access: Protected
- Response: Receipt confirmation
Records a charitable donation.
- Input: Amount (integer), Message (≤200 chars)
- Access: Protected
- Response: Receipt confirmation
Shows the sender's current debt amount.
- Access: Protected
- Response: Debt amount
Lists all roommates' debts.
- Access: Protected
- Response: Formatted debt list
Shows sender's last 15 payments.
- Access: Protected
- Response: Formatted payment history
Shows sender's last 15 donations with total amount.
- Access: Protected
- Response: Formatted donation history
Shows top 3 donors and their contribution amounts.
- Access: Protected
- Response: Formatted leaderboard
Lists the last 15 household expenses.
- Access: Protected
- Response: Formatted expense list
Lists the last 20 payments made to the house account.
- Access: Protected
- Response: Formatted payment list
Displays the house account's IBAN number.
- Access: Protected
- Response: IBAN string
id(Primary): Telegram user IDname: User's display nameisRoommate: Boolean indicating if user shares expensesconfirmed: Boolean indicating if user is verifiedactive: Boolean for soft deletion
id(Primary): Auto-increment IDamount: Expense amountlabel: Category/label for the expensedesc: Additional descriptionaddedBy: User who added the expensecreatedAt: Timestamp
id(Primary): Auto-increment IDamount: Payment amountdesc: Payment descriptionuser: Foreign key to Users tablecreatedAt: Timestamp
id(Primary): Auto-increment IDamount: Donation amountdesc: Donation messageuser: Foreign key to Users tablecreatedAt: Timestamp
├── configs.json # Bot configuration
├── ecosystem.config.js # PM2 configuration
├── index.js # Application entry point
├── package.json # Dependencies and scripts
├── data/ # SQLite database
├── logs/ # Application logs
├── public/ # Static assets (GIFs, images, videos)
├── src/ # Source code
│ ├── Bot.js # Telegram bot instance
│ ├── Commands.js # Command definitions
│ ├── Database.js # Database connection
│ ├── History.js # Conversation state management
│ ├── Response.js # Response formatting
│ ├── Service.js # Business logic
│ └── Schemas.js # Database schemas
├── templates/ # Handlebars templates
└── utils/ # Utility functions
pnpm run lintThe bot uses SQLite for data persistence. The database file is located at data/Home.sqlite and is automatically created on first run.
Commands are defined in src/Commands.js with the following structure:
def: Command definitiondesc: Command descriptionregex: Pattern matching for command recognitioncont: Whether the command requires conversation flowprops: Input properties for conversational commandsprotect: Whether the command requires user confirmationaction: Async function to execute the command
The bot supports multiple response types:
- Plain text responses
- GIF responses (welcome, correct)
- Video responses (unrecognized)
- Formatted lists using Handlebars templates
- User Confirmation: Commands are protected and require password confirmation
- Roommate Verification: Financial operations restricted to confirmed roommates
- Input Validation: All user inputs are validated before processing
- Error Handling: Comprehensive error handling with user-friendly messages
- Fork the repository
- Create a feature branch
- Make your changes
- Run linting:
pnpm run lint - Submit a pull request
ISC License - see package.json for details
nazmirket