Skip to content

Pycomet/escrow-service-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Escrow Service Bot

A secure Telegram bot for facilitating escrow services with cryptocurrency payments through BTCPay Server.

Escrow Bot

πŸš€ Quick Start

Prerequisites

  • Python 3.8+
  • Docker (for production)
  • ngrok (for local development)
  • Telegram Bot Token
  • BTCPay Server setup

Installation

  1. Clone the repository:

    git clone https://github.com/Pycomet/escrow-service-bot.git
    cd escrow-service-bot
  2. Install dependencies:

    make install-dev
  3. Set up environment variables:

    cp .env.example .env
    # Edit .env with your configuration
  4. Start development environment:

    make dev

πŸ› οΈ Development Workflow

This project uses a comprehensive Makefile for all development tasks:

Code Quality

make format          # Format code with black and isort
make lint            # Run linting with flake8 and mypy
make check           # Run both formatting and linting

Testing

make test            # Run all tests
make test-unit       # Run unit tests only
make test-coverage   # Run tests with coverage report

Development & Deployment

make dev             # Start development environment (ngrok + bot)
make deploy          # Deploy to production (Docker)
make status          # Check system status

Quick Development Cycle

make dev-cycle       # Format, lint, test, and start dev environment

View all available commands:

make help

πŸ“‹ Features

Core Functionality

  • Secure Escrow Service: Automated escrow platform for safe trading
  • Multi-Cryptocurrency Support: Bitcoin, Ethereum, and other major cryptocurrencies
  • BTCPay Integration: Secure payment processing through BTCPay Server
  • Telegram Bot Interface: User-friendly chat-based interface

Admin Features

  • Wallet Management: View and manage user wallets
  • Balance Monitoring: Real-time cryptocurrency balance tracking
  • Trade Oversight: Monitor all active trades
  • System Statistics: Platform usage analytics

Security Features

  • Multi-Signature Wallets: Enhanced security for funds
  • Encrypted Storage: Secure handling of sensitive data
  • Audit Trails: Complete transaction history
  • Admin Controls: Restricted access to sensitive operations

πŸ€– Bot Commands & Features

πŸ“± User Commands

Command Description Usage
/start Welcome message and main menu Start interacting with the bot
/help Show help information Get assistance and guidance
/trade Create a new trade Initiate a new escrow transaction
/join Join an existing trade Enter a trade ID to join as buyer
/status Show your active trades View current trade status
/history View trade history See completed and past trades
/wallet Manage your wallets View and manage crypto wallets
/editwallet Edit wallet settings Modify wallet configurations
/rules Platform trading rules Read terms and conditions
/community Community guidelines Community rules and info
/review Review completed trades Rate and review trading partners
/report Report issues Report problems or disputes
/affiliate Affiliate program Join referral program
/broker Become a broker Apply for broker status
/disputes Dispute resolution Handle trade disputes
/cancel Cancel current action Stop ongoing processes

πŸ‘¨β€πŸ’Ό Admin Commands

Command Description Access Level
/admin Access admin panel Admin only
/debug Debug user state Admin only
/delete_trade Delete trades Admin only

πŸ”„ Interactive Features

Trade Management

  • Create Trades: Step-by-step trade creation with multiple cryptocurrencies
  • Join Trades: Simple trade joining with ID verification
  • Payment Proof: Upload images/documents as payment evidence
  • Status Tracking: Real-time trade status updates
  • Dispute Resolution: Built-in mediation system

Wallet Operations

  • Multi-Wallet Support: Create and manage multiple crypto wallets
  • Balance Checking: Real-time balance updates
  • Transaction History: Complete transaction logs
  • Wallet Refresh: Manual balance refresh options

Broker System

  • Broker Registration: Apply to become a verified broker
  • Commission Tracking: Automatic commission calculations
  • Reputation System: Rating and review system for brokers
  • Trade Mediation: Professional dispute resolution

🎯 State-Based Interactions

The bot uses intelligent state management to handle complex workflows:

  • Trade Creation Flow: Multi-step process with validation
  • Join Process: Trade ID verification and buyer onboarding
  • Broker Registration: Multi-step application process
  • Report System: Structured issue reporting
  • Admin Operations: Secure administrative functions

πŸ“Š Handler Architecture

The bot uses a priority-based handler system to ensure proper message routing:

Priority Handler Type Purpose
Group 0 Command Handlers Process all bot commands
Group 1 Join Flow Handle trade joining process
Group 2 Broker Flow Handle broker registration
Group 3 Report Flow Handle issue reporting
Group 5 Trade Flow Handle trade creation
Group 10 Admin Flow Handle admin operations

This architecture prevents handler conflicts and ensures reliable message processing.

πŸ—οΈ Architecture

escrow-service-bot/
β”œβ”€β”€ handlers/          # Telegram bot command handlers
β”œβ”€β”€ functions/         # Core business logic
β”œβ”€β”€ payments/          # Payment processing (BTCPay, etc.)
β”œβ”€β”€ database/          # Database models and types
β”œβ”€β”€ utils/             # Utility functions and helpers
β”œβ”€β”€ tests/             # Test suite
β”œβ”€β”€ main.py           # Application entry point
β”œβ”€β”€ config.py         # Configuration management
└── Makefile          # Development workflow automation

πŸ§ͺ Testing

The project includes comprehensive tests:

  • Unit Tests: Individual component testing
  • Integration Tests: Component interaction testing
  • Service Tests: End-to-end service testing

Run tests with coverage:

make test-coverage

πŸš€ Deployment

Development Environment

make dev              # Start with ngrok for webhook testing
make dev-stop         # Stop development environment
make dev-logs         # Monitor development logs

Production Deployment

make deploy           # Deploy using Docker
make deploy-stop      # Stop production deployment
make deploy-logs      # Monitor production logs

πŸ“ Project Structure

β”œβ”€β”€ handlers/                 # Telegram bot handlers
β”‚   β”œβ”€β”€ admin.py             # Admin commands
β”‚   β”œβ”€β”€ trade_flows/         # Trade process handlers
β”‚   └── webhook.py           # Webhook processing
β”œβ”€β”€ functions/               # Core business logic
β”‚   β”œβ”€β”€ broker.py            # Broker functionality
β”‚   β”œβ”€β”€ trade.py             # Trade management
β”‚   β”œβ”€β”€ user.py              # User management
β”‚   └── wallet.py            # Wallet operations
β”œβ”€β”€ payments/                # Payment processors
β”‚   └── btcpay.py            # BTCPay integration
β”œβ”€β”€ tests/                   # Test suite
β”‚   β”œβ”€β”€ unit/                # Unit tests
β”‚   β”œβ”€β”€ integration/         # Integration tests
β”‚   └── service/             # Service tests
β”œβ”€β”€ utils/                   # Utilities
β”‚   β”œβ”€β”€ enums.py             # Enumerations
β”‚   β”œβ”€β”€ keyboard.py          # Telegram keyboards
β”‚   └── messages.py          # Message templates
β”œβ”€β”€ main.py                  # Application entry point
β”œβ”€β”€ config.py                # Configuration
β”œβ”€β”€ requirements.txt         # Python dependencies
β”œβ”€β”€ docker-compose.yml       # Docker configuration
β”œβ”€β”€ Makefile                 # Development automation
└── README.md               # This file

πŸ”§ Configuration

Create a .env file with the following variables:

# Telegram Bot Configuration
TOKEN=your_telegram_bot_token
ADMIN_ID=your_admin_telegram_id

# Database Configuration
DATABASE_URL=mongodb://localhost:27017
DATABASE_NAME=escrowbot

# BTCPay Configuration
BTCPAY_URL=https://your-btcpay-server.com
BTCPAY_STORE_ID=your_store_id
BTCPAY_API_KEY=your_api_key

# Webhook Configuration (for production)
WEBHOOK_MODE=true
WEBHOOK_URL=https://your-domain.com/webhook

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature-name
  3. Make your changes and run tests: make test-cycle
  4. Commit your changes: git commit -m 'Add feature'
  5. Push to the branch: git push origin feature-name
  6. Submit a pull request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ†˜ Support

  • Documentation: Check the code comments and docstrings
  • Issues: Report bugs and request features via GitHub Issues
  • Telegram: Contact the bot directly at @escrowbbot

πŸ™ Acknowledgments

  • BTCPay Server for secure payment processing
  • Python Telegram Bot library for Telegram integration
  • MongoDB for data storage
  • All contributors and users of this project

Built with ❀️ for secure trading

About

Simple and automated escrow service bot on telegram

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages