Sign inSign up

viperadnan/reddit-telegram-bot

By viperadnan

•Updated over 1 year ago

Image
0

537

viperadnan/reddit-telegram-bot repository overview

⁠Reddit Telegram Bot

A powerful Telegram bot that allows users to post content directly to Reddit, supporting multiple media types and subreddit-specific features.

⁠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

⁠Prerequisites

  • Python 3.7+
  • MongoDB instance
  • Reddit API credentials
  • Telegram Bot Token

⁠Installation

  1. Clone the repository:
git clone https://github.com/viperadnan-git/reddit-telegram-bot.git
cd reddit-telegram-bot
  1. Install required dependencies:
pip install -r requirements.txt
  1. 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'

⁠Configuration

⁠Reddit API Setup
  1. Go to Reddit's App Preferences⁠
  2. Create a new application
  3. Select "web" as the application type
  4. Set the redirect URI to your OAuth callback URL
  5. Note down the client ID and client secret
⁠Telegram Bot Setup
  1. Talk to @BotFather⁠ on Telegram
  2. Create a new bot using /newbot
  3. Copy the provided bot token

⁠Usage

  1. Start the bot:
python -m src
  1. In Telegram, start a conversation with your bot

  2. Available commands:

  • /start - Initialize the bot
  • /login - Authenticate with Reddit
  • Send any text, image, or video to start creating a post

⁠Project Structure

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

⁠Contributing

  1. Fork the repository
  2. Create a new branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

⁠License

This project is licensed under the MIT License - see the LICENSE⁠ file for details.

⁠Acknowledgments

⁠Support

If you encounter any issues or have questions, please open an issue⁠.

Tag summary

Content type

Image

Digest

sha256:12f4b07b4…

Size

57.5 MB

Last updated

over 1 year ago

docker pull viperadnan/reddit-telegram-bot