StomChat is a hybrid Telegram Userbot + Bot system powered by Google Gemini and Groq. It automatically archives dental community chat messages, analyzes media files (images, clinical photos, X-rays, videos), uses agentic search APIs to verify facts, and publishes daily/weekly AI-synthesized digests and knowledge articles to Telegraph and Telegram channels.
- Userbot Listener: Listens to targeted dental chats, groups, and channels to archive messages and media into SQLite.
- Bot Publisher: A dedicated bot client that formats, drafts, and posts summarized digests and Telegraph pages without cluttering your personal userbot session.
- Daily Digest: Auto-compiles daily summaries from dental chat discussions (focusing on cases, queries, clinic issues).
- Weekly Newspaper: Formulates a structured weekly report on dentistry developments and discussed clinical cases.
- Powered by Gemini & Groq: Dynamic multi-key API rotation with built-in cooldowns for 429/timeouts.
- Integrates Tavily Search API and DuckDuckGo API to perform web searches, verify claims made in dental chats, and add authoritative medical references.
- Automatic Frame Extraction: Leverages
OpenCVandFFmpegto extract keyframes from uploaded clinical videos. - X-Ray & Photo Inspection: Inspects dental X-rays, clinic setups, and dental photographs using multimodal Gemini Vision models.
- Automatically compiles long discussions into beautifully formatted Telegraph articles using
html-telegraph-posterand publishes them to channels.
flowchart TD
A[Dental Community Chats / Channels] -->|1. MTProto Stream| B[Telethon Userbot Listener]
subgraph Archiver [Ingestion & Storage]
B -->|2. Save Raw Messages & Media| C[(SQLite Database / aiosqlite)]
B -->|3. Extract Video Keyframes| D[OpenCV / FFmpeg Pipeline]
end
subgraph Intelligence [AI Processing Engine]
C -->|4. Fetch Unprocessed Case Batch| E[Gemini 1.5 Vision / Groq LPU]
D -->|5. Vision Frame Analysis| E
E -->|6. Agentic Medical Fact-Check| F[Tavily & DuckDuckGo Search API]
F -->|7. Generate Daily/Weekly Digest| G[Telegraph HTML Renderer]
end
G -->|8. Create Article| H[Telegraph API]
H -->|9. Post Telegraph Link| I[Telegram Bot Publisher Channel]
stomchat/
├── bot/ # Core bot handlers & Telegram event triggers
├── userbot/ # Telethon MTProto listener & media grabber
├── ai/ # Gemini Vision & Groq cascade processing
├── database/ # SQLite async connectors & schema models
├── media/ # Video frame extractor & image pre-processors
├── publisher/ # Telegraph HTML formatting & publishing engine
├── assets/ # Documentation banners & graphics
├── requirements.txt # Python dependency manifest
└── main.py # Daemon launcher entry point
| Component | Primary Tech | Role / Description |
|---|---|---|
main.py |
Python 3.10 | Application entry point running Telethon listener and async scheduler |
userbot/ |
Telethon / MTProto | Userbot module capturing incoming messages, photos, and video attachments |
ai/ |
Gemini GenAI / Groq | Multimodal AI engine inspecting X-rays, generating clinical digests |
publisher/ |
Telegraph HTML API | Renderer formatting markdown digests into published Telegraph web articles |
database/ |
aiosqlite / SQLite | High-concurrency async SQLite interface storing messages & medical tags |
- Core: Python 3.10+
- Telegram Protocol: Telethon (MTProto Client) & Pyrogram
- LLM / Vision: Google GenAI SDK (Gemini 1.5 Pro/Flash), Groq, OpenAI API
- Web Search Tools: Tavily API, DuckDuckGo Search API
- Video & Image Processing: OpenCV, Pillow, FFmpeg
- Database: SQLite (via
aiosqlite) - Telemetry & Process Guard:
psutil, custom heartbeat watchdog
- Python 3.10+
- API ID & API Hash from my.telegram.org
- Google Gemini API Key
- Groq API Key (optional)
- Tavily API Key (optional)
- FFmpeg installed in system path
-
Clone the repository:
git clone https://github.com/marko1olo/stomchat.git cd stomchat -
Install dependencies:
pip install -r requirements.txt
-
Configure Environment Variables: Create a
.envfile in the root directory:API_ID=your-telegram-api-id API_HASH=your-telegram-api-hash BOT_TOKEN=your-telegram-bot-token SESSION_NAME=your-userbot-session GEMINI_API_KEY=your-gemini-key TAVILY_API_KEY=your-tavily-key GROQ_API_KEY=your-groq-key REPORT_CHAT_ID=-100xxxxxxxxxx REPORT_HOUR=20
-
Run the Bot:
python main.py
The text below represents 100% of the original pre-agent developer documentation preserved verbatim from repository initial commit history:
### StomChat (Original Developer Documentation)
[](https://www.python.org/)
[](https://github.com/LonamiWebs/Telethon)
[](https://deepmind.google/technologies/gemini/)
[](https://groq.com/)
StomChat is a hybrid Telegram Userbot + Bot system powered by Google Gemini and Groq. It automatically archives dental community chat messages, analyzes media files (images, clinical photos, X-rays, videos), uses agentic search APIs to verify facts, and publishes daily/weekly AI-synthesized digests and knowledge articles to Telegraph and Telegram channels.🇷🇺 Краткое описание на русском
StomChat — гибридный комплекс из Telegram-юзербота и публикатора (Telethon/Pyrogram), предназначенный для автоматического сбора, AI-анализа и каталогизации профессиональных стоматологических дискуссий, рентген-снимков и клинических кейсов.
- Архивация со сбором медиа: Слушатель (Telethon MTProto) автоматически сохраняет сообщения, клинические фотографии, дентальные снимки и видео из профессиональных каналов в БД SQLite.
- Мультимодальный AI-анализ (Gemini Vision & OpenCV): Извлечение ключевых кадров из видео (OpenCV/FFmpeg) и автоматический анализ рентгенограмм и снимков через Google Gemini Vision.
- Агентская валидация фактов (Tavily & DuckDuckGo): Проверка утверждений из чатов через поисковые API с добавлением ссылок на медицинские источники.
- Дайджесты и Telegraph-статьи: Генерирует ежедневные сводки и еженедельные выпуски "Dental Newspaper", публикуя их на платформе Telegraph через
html-telegraph-poster. - Каскад API-ключей Gemini и Groq: Автоматическое переключение между ключами при лимитах 429.