A powerful Telegram bot that generates CSV files with random user data for Google Workspace bulk import. Features admin-controlled authentication, username-based authorization, interactive menu system, and customizable password options.
- CSV Generation: Generate CSV files with random user data
- Google Workspace Compatible: Perfect format for bulk user import
- Custom Passwords: Support for default or custom passwords
- Flexible Email Format: Uses realistic year-based email addresses (1950-2100)
- Interactive Menu System: Easy-to-use inline keyboard navigation
- Button-Based Navigation: Intuitive menu system with emoji icons
- Mobile-Friendly: Optimized for mobile Telegram usage
- Quick Actions: Direct access to common functions from start screen
- Admin Control: Two hardcoded admin users with full control
- User Authentication: Only authorized users can use the bot
- Username-based Auth: Admins can authorize users by Telegram username
- Auto-Authorization: Users get automatically authorized when they first interact
- Rate Limiting: 5 requests per minute per user
- Access Logging: All unauthorized access attempts are logged
- Admin Panel: Dedicated admin interface with organized sections
- User Management: Add/remove users by ID or username through menu
- Pending System: Pre-authorize users by username before they use the bot
- Statistics Dashboard: View bot usage and user statistics in organized format
- User Lists: View all authorized and pending users with navigation
| Command | Description | Example |
|---|---|---|
/start |
Show welcome message with quick action buttons | /start |
/menu |
Open interactive menu system | /menu |
/help |
Display detailed help information | /help |
/status |
Check your access status | /status |
/g <quantity> <domain> [password] |
Generate CSV file | /g 100 company.com |
| Command | Description | Example |
|---|---|---|
/adduser <user_id> |
Grant access to user by ID | /adduser 123456789 |
/addusername <username> |
Grant access by username | /addusername johndoe |
/removeuser <user_id> |
Remove user access by ID | /removeuser 123456789 |
/removeusername <username> |
Remove pending username | /removeusername johndoe |
/listusers |
List all authorized users | /listusers |
/pendingusers |
List pending usernames | /pendingusers |
/stats |
View bot statistics | /stats |
- 📊 Generate CSV: Step-by-step instructions with examples
- ❓ Help: Comprehensive help with command reference
- 📋 Status: Your authorization status and bot statistics
- 📖 Examples: Detailed command examples and usage tips
- 👑 Admin Panel: Admin-only section (for authorized administrators)
- 👥 Manage Users: View and manage authorized users
- 📝 Manage Usernames: Handle pending username authorizations
- 📊 Statistics: Detailed bot statistics and configuration info
- 🔙 Back Buttons: Easy navigation between menu sections
- 🔄 Refresh: Update menu with current information
- Inline Keyboards: Tap buttons instead of typing commands
- Context-Aware: Menus adapt based on user permissions
The generated CSV files include 29 fields compatible with Google Workspace:
First Name [Required],Last Name [Required],Email Address [Required],Password [Required],...
Matthew,Young,matthewyoung1987@company.com,Soller123@,,/,,,,,,,,,,,,,,,,,,,,,,,- Pattern:
<firstname><lastname><year>@<domain> - Year Range: 1950-2100
- Examples:
johndoe1965@company.comjanesmith2034@example.org
- Python 3.8 or higher
- Telegram Bot Token (from @BotFather)
-
Clone or download the project files
git clone <repository-url> cd gen_bot
-
Install dependencies
pip install -r requirements.txt
-
Set up your bot token
# Windows PowerShell $env:TELEGRAM_BOTCSV_TOKEN="YOUR_BOT_TOKEN_HERE" # Or edit bot.py and replace the token directly
-
Ensure name_us.json exists
- The bot requires
name_us.jsonfile with an array of names - This file should contain a JSON array of names for random generation
- The bot requires
-
Run the bot
python bot.py
You can also run the bot in a Docker container.
cd gen_bot
docker build -t telegram-csv-bot .Make sure TELEGRAM_BOTCSV_TOKEN is set (or replace inline below), and that bot.py and name_us.json are in the project directory.
docker run -d ^
--name telegram-csv-bot ^
-e TELEGRAM_BOTCSV_TOKEN=YOUR_BOT_TOKEN_HERE ^
-v "%cd%\generated_files:/app/generated_files" ^
telegram-csv-botOn Unix-like shells:
docker run -d \
--name telegram-csv-bot \
-e TELEGRAM_BOTCSV_TOKEN="$TELEGRAM_BOTCSV_TOKEN" \
-v "$(pwd)/generated_files:/app/generated_files" \
telegram-csv-botThis repository includes a docker-compose.yml. Set TELEGRAM_BOTCSV_TOKEN in your environment or create a .env file next to docker-compose.yml:
TELEGRAM_BOTCSV_TOKEN=YOUR_BOT_TOKEN_HEREThen start the bot:
cd gen_bot
docker compose up -dGenerated CSV files will be available in the local generated_files directory.
gen_bot/
├── bot.py # Main bot application
├── requirements.txt # Python dependencies
├── name_us.json # Names database (required)
├── authorized_users.json # Authorized users (auto-created)
├── pending_usernames.json # Pending usernames (auto-created)
├── generated_files/ # Output directory (auto-created)
└── README.md # This file
The following user IDs are hardcoded as administrators:
12417619751355685828
| Setting | Default Value | Description |
|---|---|---|
MAX_QUANTITY |
10,000 | Maximum users per CSV file |
RATE_LIMIT_PER_MINUTE |
5 | Requests per minute per user |
OUTPUT_DIR |
generated_files |
Directory for generated files |
| Variable | Description | Required |
|---|---|---|
TELEGRAM_BOTCSV_TOKEN |
Your Telegram bot token | Yes |
/adduser 123456789- Admin adds user by Telegram ID
- User is immediately authorized
- Can use bot right away
/addusername johndoe- Admin adds user by Telegram username
- User gets authorized when they first interact with the bot
- Automatic welcome message sent upon authorization
- User tries to use the bot
- Bot checks if user is in authorized list
- If not authorized, checks if username is in pending list
- If in pending list, automatically authorizes and removes from pending
- If not in either list, denies access with contact admin message
- Send
/startto the bot - Click 📋 Open Menu button
- Navigate using the interactive menu system
- Click 📊 Generate CSV for instructions
- Type your
/gcommand directly in chat
- Send
/menufor the main menu - Use commands directly:
/g 100 company.com - Use
/helpfor detailed information
- Tap buttons instead of typing commands
- Use 🔙 Back buttons to navigate between sections
- Admin users get additional menu options
- All information is organized and easy to find
1. Send: /menu
2. Tap: 📊 Generate CSV
3. Read instructions
4. Type: /g 100 company.com
/g 100 company.com- Creates:
100-company.com.csv - Password:
Soller123@ - Contains: 100 random users
/g 50 example.org MySecurePass123- Creates:
50-example.org.csv - Password:
MySecurePass123 - Contains: 50 random users
1. Send: /menu
2. Tap: 👑 Admin Panel
3. Choose: 👥 Manage Users or 📝 Manage Usernames
4. View information and use commands as needed
/addusername johndoe- Adds @johndoe to pending list
- When @johndoe sends any message, they're automatically authorized
- 5 requests per minute per user
- Automatic cleanup of old request timestamps
- Rate limit applies to CSV generation only
- Authentication Required: Only authorized users can generate CSVs
- Admin Protection: Admin users cannot be removed
- Access Logging: Unauthorized attempts are logged
- File Cleanup: Generated files are automatically deleted after sending
- Input Validation: All user inputs are validated
- Menu Security: Inline keyboard callbacks respect user permissions
- Check if
TELEGRAM_BOTCSV_TOKENenvironment variable is set - Verify bot token is valid
- Ensure
name_us.jsonfile exists
- Check if user is authorized:
/listusers(admin only) - Add user:
/adduser <user_id>or/addusername <username> - Check user's exact ID in their
/statuscommand - Try using the
/menucommand for easier navigation
- Ensure user is authorized to use the bot
- Try refreshing with
/menucommand - Check if there are any error messages
- Verify domain format is valid
- Check quantity is between 1 and 10,000
- Ensure user hasn't exceeded rate limit
- Use the menu system for examples and help
The bot logs important events including:
- User authorizations
- CSV generation requests
- Error conditions
- Admin actions
- Menu interactions
The bot requires the following Python packages:
python-telegram-bot>=20.0Note: python-dotenv is no longer required as the bot uses direct environment variable access.
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
For support or questions:
- Use the interactive menu system (
/menu) for guidance - Check this README
- Contact the bot administrators
- Check the bot logs for error messages
- ✅ Interactive menu system with inline keyboards
- ✅ Enhanced user interface with navigation buttons
- ✅ Admin panel with organized sections
- ✅ Username-based authentication
- ✅ Auto-authorization system
- ✅ Email format with years (1950-2100)
- ✅ Comprehensive admin controls
- ✅ Rate limiting and security
- ✅ Google Workspace CSV format
- ✅ Mobile-optimized interface
Note: This bot is designed for Google Workspace user management. Use the interactive menu system (/menu) for the best experience. Always test with small quantities first and ensure you have proper authorization before bulk importing users into your organization.