A professional Telegram bot for automated rotation of collectible usernames on channels and groups. GroupSwitch enables interval-based username swapping, allowing you to cycle through multiple purchased usernames on a scheduled basis.
Telegram allows channels and groups to have multiple collectible usernames. GroupSwitch automates the process of rotating these usernames at configurable intervals, making it easy to:
- Showcase Multiple Brands: Rotate between different username identities for your channel
- Maximize Username Visibility: Display different collectible usernames to your audience over time
- Automated Management: Set custom intervals (minutes, hours, days) for automatic username rotation
- Multi-Channel Support: Manage username rotation across multiple channels from different Telegram accounts
The bot continuously monitors your configured channels and automatically swaps the active username according to your schedule, while preserving your primary (non-collectible) username.
- Automated Username Rotation: Schedule automatic swapping of collectible usernames for channels and groups
- Multi-Session Management: Handle multiple Telegram accounts simultaneously
- Interval-Based Swapping: Configure custom swap intervals (minutes, hours, days) per channel
- Dual Authentication: Support for both phone number and Telegram Desktop session file import
- Smart Caching: 15-minute username cache to minimize API calls and improve performance
- Bulk Operations: Enable or disable swapping for all channels at once
- Real-time Status: Monitor swap progress with countdown timers and next swap information
- Primary Username Protection: Automatically detect and preserve primary (non-collectible) usernames
- Flexible Configuration: Different intervals for different channels based on your needs
- Go 1.21 or higher
- MongoDB instance (local or cloud)
- Telegram Bot Token from @BotFather
- Telegram API credentials (APP_ID and APP_HASH) from my.telegram.org
- Clone the repository:
git clone github.com/AmarnathCJD/GroupSwitch
cd GroupSwitch- Install dependencies:
go mod download- Configure environment variables:
cp .env.example .env- Edit
.envwith your credentials:
BOT_TOKEN=your_bot_token_here
APP_ID=your_app_id_here
APP_HASH=your_app_hash_here
MONGO_URI=your_mongodb_connection_string
LOGS_CHANNEL=0go run .Or build and run:
go build -o groupswitch
./groupswitch| Command | Description |
|---|---|
/start |
Display welcome message and available commands |
/addsession |
Add a new Telegram session (phone or file) |
/sessions |
List all active sessions with statistics |
/manage |
Manage sessions and channel configurations |
/status |
View current swap status and countdown timers |
Via Phone Number:
- Use
/addsessionand select "📱 Via Phone Number" - Enter your phone number
- Enter the verification code
- Enter 2FA password if enabled
Via Telegram Desktop Session:
- Export your Telegram Desktop
tdatafolder - Compress it into a ZIP file
- Use
/addsessionand select "📁 Via Session File" - Upload the ZIP file
- Use
/manageto view your sessions - Select a session to view its channels
- Use "➕ Add Channel" to add channels/groups from your account
- Click on any channel to configure:
- Toggle username swapping on/off
- Set custom swap intervals for rotation
- Remove channel from rotation
Note: Channels must have at least 2 usernames (collectible usernames) to enable swapping. The primary username is automatically excluded from rotation.
Specify intervals in the following formats:
- Minutes:
5m,10m,30m - Hours:
1h,2h,12h - Days:
1d,7d
Minimum interval: 5 minutes
The bot will rotate through all collectible usernames sequentially, changing the active username at each interval.
GroupSwitch/
├── main.go # Application entry point
├── config.go # Environment configuration
├── bot.go # Bot initialization and handlers
├── sessions.go # Session and channel management
├── database.go # MongoDB operations
├── swapper.go # Background username rotation engine
├── tdata.go # Telegram Desktop session parser
└── utils.go # Utility functions
All session data is securely stored in MongoDB with the following structure:
- User credentials (encrypted string sessions)
- Channel configurations
- Swap schedules and intervals
- Username cache with 15-minute TTL
- Check if swap interval has elapsed for each channel
- Retrieve cached usernames or fetch from Telegram API if cache expired
- Identify primary username (non-editable/non-collectible) and skip it from rotation
- Deactivate all collectible usernames
- Activate next collectible username in sequential rotation
- Update last swap time and continue cycle
- Username caching reduces API calls by ~30x
- Background goroutine prevents blocking operations
- Panic recovery ensures continuous operation
- Efficient MongoDB queries with proper indexing
- Environment-based configuration prevents credential exposure
.envfile excluded from version control- Secure session string storage in MongoDB
- Input validation for file uploads (ZipSlip protection)
The bot implements comprehensive error handling:
- Graceful recovery from panics in background workers
- User-friendly error messages with emoji indicators
- Automatic retry logic for transient failures
- Detailed logging for debugging
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For issues, questions, or feature requests, please open an issue on GitHub.
- Built with gogram - MTProto implementation in Go
- MongoDB driver for Go
- godotenv for environment configuration
Note: This bot is designed for managing collectible usernames on Telegram channels and groups. Users are responsible for complying with Telegram's Terms of Service and username policies.