A powerful Telegram bot that converts text, HTML, and URLs to beautifully formatted markdown. Perfect for developers, writers, and anyone who works with markdown formatting.
- 📝 Text to Markdown: Convert plain text to markdown format
- 🌐 URL Processing: Fetch and convert web pages to markdown
- 🔗 Smart Link Handling: Convert HTML links to markdown format
- 🏷️ Keyword Mapping: Replace predefined keywords with their corresponding URLs
- 📄 File Output: Get results as downloadable markdown files
- 🎨 HTML Support: Convert HTML content to clean markdown
- Python 3.7+
- A Telegram Bot Token (get one from @BotFather)
-
Clone the repository
git clone https://github.com/your-username/markdown-bot.git cd markdown-bot -
Create a virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Set up environment variables
Create a
.envfile in the project root:YOUR_BOT_TOKEN=your_telegram_bot_token_here
-
Configure keywords (optional)
Edit
keywords.jsonto add your custom keyword-to-URL mappings:{ "Google": "https://www.google.com/", "YouTube": "https://www.youtube.com/", "GitHub": "https://github.com/", "YourKeyword": "https://your-url.com/" } -
Run the bot
python markdown_bot.py
- Send any text to convert it to markdown format
- Send a URL to fetch and convert the webpage to markdown
- Use keywords from your
keywords.jsonto auto-replace them with links
Text Input:
Hello World! Visit Google for search.
Bot Output:
Hello World! Visit [Google](https://www.google.com/) for search.URL Input:
https://example.com
Bot Output:
- Fetches the webpage content
- Converts it to clean markdown
- Sends it as a downloadable
.mdfile
markdown-bot/
├── .env # Environment variables (create this)
├── .gitignore # Git ignore file
├── Dockerfile # Docker configuration
├── keywords.json # Keyword-to-URL mappings
├── markdown_bot.py # Main bot script
├── requirements.txt # Python dependencies
├── README.md # This file
└── START.md # Setup instructions
You can also run the bot using Docker:
-
Build the image
docker build -t markdown-bot . -
Run the container
docker run -d --name markdown-bot --env-file .env markdown-bot
| Variable | Description | Required |
|---|---|---|
YOUR_BOT_TOKEN |
Telegram Bot Token from BotFather | Yes |
The keywords.json file allows you to define custom mappings that the bot will automatically convert:
{
"keyword1": "https://example1.com",
"keyword2": "https://example2.com"
}When users send text containing these keywords, they'll be automatically converted to markdown links.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
# Clone the repo
git clone https://github.com/your-username/markdown-bot.git
cd markdown-bot
# Create virtual environment
python -m venv venv
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Create .env file with your bot token
echo "YOUR_BOT_TOKEN=your_token_here" > .env
# Run the bot
python markdown_bot.pypython-telegram-bot- Telegram Bot API wrapperpython-dotenv- Environment variable managementmarkdown- Markdown processingmarkdownify- HTML to Markdown conversionbeautifulsoup4- HTML parsing
If you have any questions or run into issues:
- Check the Issues page
- Create a new issue if your problem isn't already reported
- Include as much detail as possible about your setup and the issue
Give a ⭐️ if this project helped you!
Made with ❤️ for the Telegram community