EV9H/TeSo

โ˜… 0Forks 0PythonGitHub โ†—Compare

README

TeSo

Python Version Poetry License

TeSo is a Telegram message scraping and search engine that allows you to collect and analyze messages from Telegram channels using both user-bot and bot interfaces.

๐Ÿš€ Features

  • Automated message scraping from Telegram channels
  • PostgreSQL database integration for message storage
  • Configurable batch processing with rate limiting
  • Search functionality through a Telegram bot interface
  • Docker support for easy database setup

๐Ÿ“‹ Prerequisites

  • Python 3.8 or higher
  • Poetry for dependency management
  • Docker (optional, for local database setup)
  • Telegram account and bot token

โš™๏ธ Installation

  1. Clone the repository
  2. Install dependencies using Poetry:
poetry install

๐Ÿ”ง Configuration

  1. Create a .env file in the project root with the following variables:
API_ID=your_api_id                # Telegram API ID
API_HASH=your_api_hash           # Telegram API Hash
PHONE=your_phone_number          # Phone number for user-bot
DATABASE_URL=postgresql_url      # PostgreSQL connection URL
TELEGRAM_BOT_TOKEN=bot_token     # Telegram Bot Token

Obtaining Credentials

  • API_ID and API_HASH: Get from my.telegram.org/apps
  • TELEGRAM_BOT_TOKEN: Create a new bot through @BotFather
  • DATABASE_URL format: postgresql://user:password@localhost:5432/dbname

๐Ÿƒโ€โ™‚๏ธ Running the Application

1. Start the Database

If using Docker for local development:

docker compose up -d

2. Activate Poetry Environment

poetry shell

3. Run Message Scraper

python teso.engine

Scraping Configuration

Current settings (configurable in code):

batch_size = 50      # Messages per batch
batch_delay = 2      # Seconds between batches
channel_delay = 30   # Seconds between channels
max_attempts = 3     # Retry attempts

4. Launch the Bot

python -m teso.bot

5. Optional: Test Search Functionality

python -m teso.search

๐Ÿ” Search Features

  • Full-text search across scraped messages
  • Channel-specific filtering
  • Date range filtering
  • Customizable result limits

โš ๏ธ Rate Limiting

The scraper implements rate limiting to avoid Telegram's FloodWaitError:

  • Batch processing with configurable delays
  • Automatic retry mechanism
  • Channel-specific delays

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Open a Pull Request

๐Ÿ“ License

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

๐Ÿ“ฎ Contact

For questions and support, please open an issue in the GitHub repository.


Note: This project is under active development. Features and documentation may change.

Contributors

EV9H

Issues