Skip to content

EvanesskoHub/tg-autoposter

Repository files navigation

🤖 TG AutoPoster

Tests Python aiogram Telegraph

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.

✨ Features

  • 📄 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

🛠 Tech Stack

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

⚙️ Installation & Launch

Prerequisites

  • Python 3.10 or higher
  • Git installed
  • A bot registered via @BotFather
  • Telegraph account (token auto-generated on first run)

1. Clone the repository

git clone https://github.com/EvanesskoHub/tg-autoposter.git

cd tg-autoposter

2. Set up a virtual environment

python -m venv venv

source venv/bin/activate (Linux/MacOS)

venv\Scripts\activate (Windows)

3. Install dependencies

pip install -r requirements.txt

4. Configure environment variables

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)

5. Prepare articles folder

Create an articles/ folder and put your .txt, .doc, .docx files there:

mkdir articles

6. Run the bot

python main.py

7. First launch

On first run, the bot will create a Telegraph account and print the token.
Copy it to your .env file and restart the bot.

📁 Project Structure

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

📸 Screenshots

(Add screenshots here)

📝 Notes

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

💬 Contact: Telegram | Email


📚 Русская версия / Russian

TG AutoPoster — бот для автопостинга статей (Telegraph) из файлов.

Функции: чтение .txt/.doc/.docx, парсинг автора/жанра/рейтинга, публикация в Telegraph, одобрение через кнопки, напоминания, статистика.

Стек: Python, aiogram, Telegraph API, SQLite.

Контакты: Telegram | Email

Releases

Packages

Contributors

Languages