A powerful Telegram bot that allows users to post content directly to Reddit, supporting multiple media types and subreddit-specific features.
- 🔐 OAuth2 Authentication with Reddit
- 📝 Create text posts
- 🖼️ Upload images and videos
- 🔗 Share URLs
- 🏷️ Support for subreddit flairs
- 💬 Custom post titles and descriptions
- 📱 Intuitive conversation-based interface
- 🔄 Persistent user sessions
- 🎯 Subreddit-specific posting requirements
- Python 3.7+
- MongoDB instance
- Reddit API credentials
- Telegram Bot Token
- Clone the repository:
git clone https://github.com/viperadnan-git/reddit-telegram-bot.git
cd reddit-telegram-bot
- Install required dependencies:
pip install -r requirements.txt
- Create a
.env
file in the root directory with the following variables:
TELEGRAM_BOT_TOKEN=your_telegram_bot_token
REDDIT_CLIENT_ID=your_reddit_client_id
REDDIT_CLIENT_SECRET=your_reddit_client_secret
MONGO_URI=your_mongodb_connection_string
TEMP_DIR=tmp # Optional, defaults to 'tmp'
- Go to Reddit's App Preferences
- Create a new application
- Select "web" as the application type
- Set the redirect URI to your OAuth callback URL
- Note down the client ID and client secret
- Talk to @BotFather on Telegram
- Create a new bot using
/newbot
- Copy the provided bot token
- Start the bot:
python -m src
-
In Telegram, start a conversation with your bot
-
Available commands:
/start
- Initialize the bot/login
- Authenticate with Reddit- Send any text, image, or video to start creating a post
The project follows a modular architecture:
src/
├── __init__.py # Logger configuration
├── __main__.py # Application entry point
├── config.py # Environment configuration
├── constant.py # Conversation states
├── database.py # MongoDB interface
├── enums.py # Media type enums
├── handlers/ # Command handlers
│ ├── login.py # Authentication handlers
│ └── post.py # Posting handlers
├── models/ # Data models
│ └── reddit_post.py # Post structure
├── modules/ # Core functionality
│ ├── bot_context.py # Bot context
│ ├── decorators.py # Auth decorators
│ └── reddit_manager.py # Reddit API wrapper
└── utils.py # Helper functions
- Fork the repository
- Create a new branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add 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.
- python-telegram-bot for the Telegram Bot API wrapper
- PRAW for the Reddit API wrapper
- pymongo for MongoDB integration
If you encounter any issues or have questions, please open an issue.