Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

A Telegram bot that helps users get their Telegram user information, including username, ID, and analytics.

License

Notifications You must be signed in to change notification settings

kareem2099/DotShare_Key

DotSharePY OAuth Toolkit πŸ”

License: MIT Python 3.9+ MongoDB Security

A secure, production-ready toolkit for generating OAuth tokens and tracking user analytics. It combines a Telegram Bot interface with a robust OAuth 2.0 Server to handle authentication flows securely.

🌟 Key Features

πŸ” Security First

  • Magic Link Pattern: Uses secure, one-time-use links for authentication. Sensitive credentials (Client Secrets) are never exposed in URLs.
  • Data Masking: Intelligent log masking protects tokens and secrets in server logs.
  • Session Management: Automatic cleanup of expired sessions using MongoDB TTL indexes.

πŸ“± Telegram Bot

  • Multi-Platform Support: Generate tokens for LinkedIn and Reddit.
  • User Analytics: Tracks Daily/Weekly active users and interactions using MongoDB.
  • Admin Tools: Detailed stats command (/stats) restricted to the admin.
  • Public Stats: View general usage statistics with /publicstats.
  • Identity Tools: Quickly fetch User ID (/myid) or Username.

🌐 OAuth Server

  • Standalone HTTP server handling OAuth 2.0 callbacks.
  • Supports both Localhost and Cloud Deployment (Railway/Heroku).
  • Unified callback handler for multiple providers.

πŸ› οΈ Setup & Installation

1. Prerequisites

  • Python 3.9+
  • MongoDB Database (Local or Atlas)
  • Telegram Bot Token

2. Environment Variables

Copy .env.example to .env and configure the following:

# Bot Configuration
TELEGRAM_BOT_TOKEN=your_bot_token_here
ADMIN_USER_ID=123456789  # Your Telegram User ID (Integer)

# Database
MONGODB_URI=mongodb+srv://user:[email protected]/dbname
MONGODB_BOT_DB_NAME=DotSharePY

# Server Configuration
# Use http://localhost:3000 for local dev
# Use [https://your-app.up.railway.app](https://your-app.up.railway.app) for production
SERVER_BASE_URL=http://localhost:3000

3. Platform Setup

πŸ”— LinkedIn App

  1. Create an app at LinkedIn Developers.
  2. Set Redirect URL: YOUR_SERVER_BASE_URL/callback (e.g., http://localhost:3000/callback).
  3. Enable products: Sign In with LinkedIn and Share on LinkedIn.

πŸ€– Reddit App

  1. Create an app at Reddit Prefs.
  2. Select type: web app.
  3. Set Redirect URI: YOUR_SERVER_BASE_URL/callback.

πŸš€ Running the Project

Local Development

  1. Install dependencies:
pip install -r requirements.txt
  1. Run the bot (this will also utilize the server logic):
python bot.py
# Note: For OAuth flow, ensure server.py is running or integrated
python server.py

🐳 Docker Support

Build and run the container securely:

docker build -t dotshare-py .
docker run -p 3000:3000 --env-file .env dotshare-py

πŸš‚ Deploy on Railway

  1. Connect your GitHub repository to Railway.
  2. Add variables from your .env to Railway variables.
  3. Update SERVER_BASE_URL to your new Railway domain (e.g., https://dotshare.up.railway.app).
  4. Update your LinkedIn/Reddit apps with the new Callback URL.

πŸ§ͺ Testing

Run the comprehensive test suite to ensure system integrity:

python -m pytest tests/ -v

πŸ“Š Analytics

Data is stored in MongoDB collections:

  • users: Stores user profiles and interaction counts.
  • analytics: Tracks daily active users (DAU).
  • pending_auth: Temporary storage for secure Magic Links (TTL enabled).

πŸ“„ License

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

About

A Telegram bot that helps users get their Telegram user information, including username, ID, and analytics.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages