A Matrix bot designed to handle financial transaction templates (上押/加押/下押) with automatic data storage and management capabilities. Built with simplematrixbotlib for easy setup without encryption dependencies.
- Template Processing: Supports three types of financial transaction templates:
- 🟢 上押 (Initial Deposit)
- 🟡 加押 (Additional Deposit)
- 🔵 下押 (Withdrawal)
- Automatic Data Storage: All transactions are automatically saved in JSON format
- Manual Management: Automatically pins usage instructions to the Matrix room
- Expense Tracking: Built-in expense tracking system
- Data Export: Export all transaction data with
!导出command - Data Management: Clear data with
!清除command - Session Persistence: Maintains Matrix session across restarts
- No Encryption Required: Uses simplematrixbotlib - no libolm or encryption dependencies
- Easy Setup: Simple configuration with minimal dependencies
- Python 3.11 or higher
- A Matrix homeserver account (e.g., matrix.org, element.io)
- Access to a Matrix room where the bot will operate
- No encryption setup required (bot uses simplematrixbotlib)
Run the automated setup script:
git clone https://github.com/your-username/hwcw-bot.git
cd hwcw-bot
./setup.shThe script will:
- Check Python version requirements
- Create a virtual environment
- Install dependencies (simplematrixbotlib and requests)
- Set up configuration template
- Provide next steps
-
Clone the repository
git clone https://github.com/your-username/hwcw-bot.git cd hwcw-bot -
Create virtual environment
python3 -m venv .venv source ./.venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
Note: This bot uses
simplematrixbotlibwhich has minimal dependencies and doesn't require encryption libraries like libolm or _libolm that can cause installation issues. -
Configure environment
cp .env.example .env # Edit .env with your Matrix credentials -
Run the bot
python bot.py
-
Clone and build
git clone https://github.com/your-username/hwcw-bot.git cd hwcw-bot docker build -t hwcw-bot .
-
Run with Docker
docker run -d --env-file .env --name hwcw-bot hwcw-bot
Create a .env file based on .env.example:
# Matrix homeserver URL
MATRIX_HOMESERVER=https://matrix.org
# Your bot's Matrix user ID
MATRIX_USER_ID=@your-bot:matrix.org
# Bot's password
MATRIX_PASSWORD=your-secure-password
# Room ID where the bot operates
MATRIX_ROOM_ID=!your-room-id:matrix.org- Create a Matrix account on your preferred homeserver (e.g., matrix.org)
- Get Room ID: In Element (or your Matrix client), go to Room Settings → Advanced → Copy "Internal room ID"
- Invite the bot to your room and give it appropriate permissions
Security Note: The bot uses password authentication for simplicity. For production deployments, consider using access tokens instead.
#工号 123
#群号 专群 456
#上押 1000U 供方
请查收
用户TGid:123456789
#工号 123
#群号 专群 456
#加押 500U 需方
请查收
用户TGid:987654321
#工号 123
#群号 专群 456
#手续费 10U 供方
#下押 1000U 供方
#地址 T9xxxxxxxxxxxxxxxxxxxxxx
| Command | Description |
|---|---|
!导出 |
Export all transaction data |
!清除 |
Clear all expense records |
!更新说明 |
Update and re-pin usage manual (admin only) |
The bot stores transaction data in the following format:
{
"时间": "2025-01-01 12:00",
"发送者": "@user:matrix.org",
"类型": "上押",
"工号": "123",
"群号": "456",
"金额": 1000.0,
"角色": "供方",
"用户TGid": "123456789"
}hwcw-bot/
├── bot.py # Main bot application
├── requirements.txt # Python dependencies
├── Dockerfile # Docker configuration
├── .env.example # Environment template
├── .gitignore # Git ignore rules
├── LICENSE # MIT License
├── README.md # This file
├── MANUAL.md # Usage manual (Chinese)
├── START.md # Quick start guide
├── data.json # Transaction data (auto-generated)
├── expenses.json # Expense data (auto-generated)
├── session.json # Matrix session (auto-generated)
├── sync_token.json # Sync token (auto-generated)
└── manual.json # Manual state (auto-generated)
- Never commit
.envfiles - Contains sensitive credentials - Session files are automatically generated and should not be shared
- Data files contain transaction information and should be backed up securely
- Use strong passwords for Matrix accounts
- Consider using Matrix access tokens instead of passwords for production
This project uses:
- simplematrixbotlib: Lightweight Matrix bot library without encryption dependencies
- requests: HTTP library for API calls
- python-dotenv: Environment variable management
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Make your changes
- Test thoroughly
- Submit a pull request
- Follow PEP 8 Python style guidelines
- Use meaningful variable names
- Add comments for complex logic
- Update documentation when adding features
-
Login Failed
- Check Matrix credentials in
.env - Verify homeserver URL is correct
- Ensure bot account exists and password is correct
- Check Matrix credentials in
-
Room Access Denied
- Verify the bot is invited to the room
- Check room ID format:
!roomid:homeserver.com - Ensure bot has necessary permissions
-
Template Not Recognized
- Check template format matches examples exactly
- Ensure all required fields are present
- Verify amounts end with 'U' (e.g.,
1000U)
-
Installation Issues
- This bot uses
simplematrixbotlibto avoid encryption dependencies - If you encounter issues, try creating a fresh virtual environment
- Ensure Python 3.11+ is installed
- This bot uses
This project switched from matrix-nio[e2e] to simplematrixbotlib to avoid common installation issues:
- No libolm dependency: Eliminates complex C library compilation
- No encryption setup: Simpler for basic bot functionality
- Fewer dependencies: Easier installation and deployment
- Better cross-platform support: Works reliably on macOS, Linux, and Windows
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
If you encounter any issues or have questions:
- Check the troubleshooting section
- Search existing GitHub issues
- Create a new issue with detailed information
- Built with simplematrixbotlib for easy Matrix bot development
- Inspired by the need for automated financial transaction tracking
- Thanks to the Matrix community for the excellent protocol and tools
Note: This bot is designed for specific financial transaction workflows. Please ensure compliance with your organization's policies and applicable regulations when handling financial data.