Skip to content

DoctorYanmar/Summarizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Telegram Chat Summarizer

Telegram bot that collects recent messages from configured group chats, summarizes them with OpenAI, and sends the summary to approved Telegram users.

This repository is a maintained derivative of Georgiy Manuilov's MIT-licensed Telegram chat summarizer. The current version adds environment overrides, rate limiting, chunked summaries, and operational logging.

Features

  • Monitors one or more Telegram group chats.
  • Summarizes recent text messages with a configurable prompt.
  • Sends summaries through a Telegram bot.
  • Supports approved summary receivers and chat context switching.
  • Splits large histories into chunks before summarization.
  • Uses environment variables to override sensitive configuration fields.

Requirements

  • Python 3.10+
  • Telegram API credentials (api_id, api_hash)
  • Telegram bot token
  • OpenAI API key

Quick Start

git clone https://github.com/DoctorYanmar/Summarizer.git
cd Summarizer
python -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt
cp config.example.json config.json

Edit config.json, then run:

python app.py config.json

On first Telegram client login, Telethon may ask for a phone/code/password and create a local .session file. Session files are ignored by Git.

Configuration

config.example.json contains placeholders:

{
  "telegram_api_id": 123456,
  "telegram_api_hash": "replace-with-telegram-api-hash",
  "telegram_bot_auth_token": "replace-with-bot-token",
  "bot_username": "replace-with-bot-username",
  "openai_api_key": "replace-with-openai-api-key",
  "chats_to_summarize": [
    {
      "id": "example_group_or_chat_id",
      "summarization_prompt_path": "prompts/example_summarization_prompt.txt"
    }
  ],
  "telegram_summary_receivers": [123456789]
}

Sensitive values can also be supplied through environment variables:

  • TELEGRAM_API_ID
  • TELEGRAM_API_HASH
  • TELEGRAM_BOT_AUTH_TOKEN
  • BOT_USERNAME
  • OPENAI_API_KEY
  • CHATS_TO_SUMMARIZE
  • TELEGRAM_SUMMARY_RECEIVERS
  • MESSAGE_LIMIT

Do not commit config.json, .env, .session files, or logs.

Project Layout

.
├── app.py                                  # Entrypoint
├── config.example.json                     # Safe configuration template
├── requirements.txt
├── prompts/example_summarization_prompt.txt
└── src/
    ├── main.py                            # Application orchestration
    ├── group_chat_scrapper.py             # Telegram history collection
    ├── summarization.py                   # OpenAI summarization
    ├── envoy_bot.py / bot_core.py         # Telegram bot interface
    ├── bot_handlers.py                    # Commands and callbacks
    ├── config.py                          # Config/env loading
    └── user_management.py                 # Receiver verification/context

Attribution

Original implementation by Georgiy Manuilov, MIT License, with documentation published on Habr: https://habr.com/ru/articles/804111/

License

MIT License. See LICENSE.

About

Telegram group chat summarizer bot with OpenAI-powered digest generation

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages