A Telegram bot for automatic article posting from .txt, .doc, .docx files.
Parses metadata (author, genre, rating), publishes to Telegraph, and asks for approval.
Pet project created as part of learning Python development.
- 📄 File processing: reads
.txt,.doc,.docx - 🧠 Metadata parsing: extracts author, genre, rating from headers
- 📰 Telegraph publishing: creates articles via Telegraph API
- ✅ Approval workflow: inline buttons to approve or reject
- ⏰ Scheduler: periodic reminders every 3 days
- 📊 Statistics: track published, skipped, and errored files
- 🔗 Link removal: cleans URLs from text automatically
| Technology | Description |
|---|---|
| Python 3.10+ | Core language |
| aiogram 3.x | Telegram Bot API framework |
| Telegraph API | Article publishing platform |
| SQLite | Processed files database |
| python-docx | Reading .docx files |
| schedule | Periodic task scheduler |
- Python 3.10 or higher
- Git installed
- A bot registered via @BotFather
- Telegraph account (token auto-generated on first run)
git clone https://github.com/EvanesskoHub/tg-autoposter.git
cd tg-autoposter
python -m venv venv
source venv/bin/activate (Linux/MacOS)
venv\Scripts\activate (Windows)
pip install -r requirements.txt
Create an .env file in the project root:
cp .env.example .env
Open .env and fill in your data:
BOT_TOKEN=your_telegram_bot_token
CHANNEL_ID=your_channel_id
YOUR_USER_ID=your_telegram_user_id
TELEGRAPH_TOKEN=your_telegraph_token (leave empty on first run — bot will generate it)
Create an articles/ folder and put your .txt, .doc, .docx files there:
mkdir articles
python main.py
On first run, the bot will create a Telegraph account and print the token.
Copy it to your .env file and restart the bot.
tg-autoposter/ ├── main.py # Entry point, scheduler thread ├── poster_bot.py # Bot handlers, approval logic ├── config.py # Paths, limits, constants ├── db.py # SQLite database for processed files ├── file_processor.py # File reading, header parsing, cleaning ├── telegraph_publisher.py # Telegraph API integration ├── scheduler.py # Reminder scheduler ├── requirements.txt # Dependencies ├── .env.example # Environment variables template ├── .gitignore # Git ignore rules └── README.md # This file
(Add screenshots here)
This project demonstrates:
- Asynchronous Python (aiogram)
- External API integration (Telegraph)
- File parsing (.txt, .doc, .docx)
- Metadata extraction with regex
- SQLite for state tracking
- Background task scheduling
- Environment variables and security
TG AutoPoster — бот для автопостинга статей (Telegraph) из файлов.
Функции: чтение .txt/.doc/.docx, парсинг автора/жанра/рейтинга, публикация в Telegraph, одобрение через кнопки, напоминания, статистика.
Стек: Python, aiogram, Telegraph API, SQLite.