diff --git a/ADMIN_IMPLEMENTATION.md b/ADMIN_IMPLEMENTATION.md index 5fe13af..1f24f28 100644 --- a/ADMIN_IMPLEMENTATION.md +++ b/ADMIN_IMPLEMENTATION.md @@ -2,7 +2,7 @@ ## Overview -The telegram-groupfactory bot now has **admin-only configuration** where all sensitive operations (adding/modifying users, setting QR backups) can ONLY be executed from the designated admin chat (STAFF_CHAT_ID). +The telegram-groupfactory bot now has **admin-only configuration** where configuration operations (adding/modifying users, setting GroupHelp QR backups) can ONLY be executed from the designated admin chat (STAFF_CHAT_ID). ## Key Features @@ -25,10 +25,10 @@ The following commands can ONLY be run from the admin chat: /admin_remove_users - Remove users from default list ``` -#### QR Code Backup +#### GroupHelp QR Code Backup ``` -/admin_get_qr - Retrieve QR backup data -/admin_set_qr - Store QR backup data for replication +/admin_get_qr - Retrieve GroupHelp backup QR data +/admin_set_qr - Store GroupHelp backup QR data for `.importbackup` ``` #### Help @@ -81,8 +81,8 @@ New class `AdminHandler` with methods: - `handle_add_to_default_users(chat_id, user_ids)` - Add users (admin only) - `handle_remove_from_default_users(chat_id, user_ids)` - Remove users (admin only) - `handle_add_user_to_db(chat_id, username)` - Add user (admin only) -- `handle_get_qr_backup(chat_id)` - Get QR backup (admin only) -- `handle_set_qr_backup(chat_id, qr_data)` - Set QR backup (admin only) +- `handle_get_qr_backup(chat_id)` - Get GroupHelp QR backup (admin only) +- `handle_set_qr_backup(chat_id, qr_data)` - Set GroupHelp QR backup (admin only) - `handle_admin_help(chat_id)` - Show admin help (admin only) ### Main Application Updates (`src/main.py`) @@ -133,7 +133,7 @@ User: [clicks "Yes, I want to be full admin"] Bot: Set as ✅ Full Group Admin - Confirmed! ``` -## Security Features +## Access Control Features 1. **Chat-Level Access Control** - Only STAFF_CHAT_ID can execute admin commands 2. **Database Persistence** - All preferences stored in MongoDB @@ -162,7 +162,7 @@ Stores per-user admin preferences: ``` ### `ghconfig` Collection -Stores QR backup data: +Stores GroupHelp backup QR data: ```json { "key": "qr_backup_data", @@ -212,7 +212,7 @@ MONGODB_COLLECTION=ghconfig # Can retrieve with: get_user_admin_role(user_id) ``` -### Test QR Backup +### Test GroupHelp QR Backup ```bash # In admin chat: /admin_set_qr myqrcode123 @@ -220,6 +220,9 @@ MONGODB_COLLECTION=ghconfig /admin_get_qr # 📊 Current QR Backup Data: myqrcode123 + +# In the target group: +.importbackup myqrcode123 ``` ## Future Enhancements diff --git a/CONFIGURATION_GUIDE.md b/CONFIGURATION_GUIDE.md index 9c60745..315d6d5 100644 --- a/CONFIGURATION_GUIDE.md +++ b/CONFIGURATION_GUIDE.md @@ -2,7 +2,7 @@ ## Overview -This guide explains how to configure users to be added to newly created groups and manage backup QR code replication via the bot. +This guide explains how to configure users to be added to newly created groups and manage GroupHelp backup QR data via the bot. ## Setting Up Default Users for New Groups @@ -127,26 +127,19 @@ This will create ProjectBeta with only alice and bob, regardless of the default --- -## QR Code Backup Configuration +## GroupHelp QR Backup Configuration ### What is QR Backup Data? -QR backup data is a code that can be used to replicate or restore your bot's session across multiple instances. This is useful for: -- Disaster recovery -- Multi-instance deployment -- Session migration -- Backup and restore scenarios +QR backup data is the GroupHelp settings backup payload generated by GroupHelp itself. It is used to copy GroupHelp settings, such as welcome-message configuration, from one group to another by pasting the QR payload as the body of a `.importbackup` message. ### Step 1: Generate or Obtain QR Code -Depending on your setup, you might have a QR code from: -- Bot session export -- Backup file -- Another instance +Generate the QR backup from GroupHelp in the source group, then store the decoded/pasted payload here so it can be reused when importing those settings into another group. -### Step 2: Set QR Backup Data +### Step 2: Set GroupHelp QR Backup Data -Store the QR backup data in the database: +Store the GroupHelp QR backup data in the database: ``` /set_qr_backup YOUR_QR_CODE_HERE @@ -164,9 +157,9 @@ Response: Data: `0001a8ac0123456789abcdef0123456789abcdef01234567` ``` -### Step 3: Retrieve QR Backup Data +### Step 3: Retrieve GroupHelp QR Backup Data -Retrieve the stored QR backup data anytime: +Retrieve the stored GroupHelp QR backup data anytime: ``` /get_qr_backup @@ -178,13 +171,12 @@ Response: `0001a8ac0123456789abcdef0123456789abcdef01234567` ``` -### Step 4: Use QR Backup for Replication +### Step 4: Use QR Backup with GroupHelp Once you have the QR backup data stored, you can: -1. Export it from the database -2. Use it in deployment scripts -3. Pass it to other bot instances -4. Store it in version control (encrypted) for DR purposes +1. Retrieve it with `/get_qr_backup` +2. Paste it into the target group as the message body for `.importbackup` +3. Let GroupHelp import the backed-up settings into that group --- @@ -201,7 +193,7 @@ The configuration data is stored in MongoDB with the following structure: } ``` -### QR Backup Collection (`COLLECTION_NAME`) +### GroupHelp QR Backup Collection (`COLLECTION_NAME`) ```json { "_id": ObjectId(...), @@ -245,18 +237,14 @@ The configuration data is stored in MongoDB with the following structure: /create_group NewProject ``` -### Workflow 3: QR Code Backup & Restore +### Workflow 3: GroupHelp QR Backup Import ```bash -# On source instance: +# Retrieve the stored GroupHelp QR payload: /get_qr_backup -# Copy the QR code output -# On target instance: -/set_qr_backup - -# Verify it was stored -/get_qr_backup +# In the target group, paste the payload with: +.importbackup ``` --- @@ -275,7 +263,7 @@ The configuration data is stored in MongoDB with the following structure: 2. Verify users exist: `/users` 3. Manually add users to group: `/add_users ,` -### Issue: QR backup data appears empty +### Issue: GroupHelp QR backup data appears empty **Solution:** 1. Check if data was stored: `/get_qr_backup` 2. Re-set the data: `/set_qr_backup ` @@ -321,8 +309,8 @@ FACTORY_BOT_ID=your_bot_id - `/set_default_users ...` - Set default users (replace) - `/add_default_users ...` - Add users to default list - `/remove_default_users ...` - Remove users from default list -- `/get_qr_backup` - View QR backup data -- `/set_qr_backup ` - Set QR backup data +- `/get_qr_backup` - View GroupHelp QR backup data +- `/set_qr_backup ` - Set GroupHelp QR backup data - `/config_help` - Show configuration command help - `/help` - Show all available commands @@ -366,19 +354,18 @@ mongo mongodb://localhost:27017/groupfactory # View default users db.group_config.find() -# View QR backup +# View GroupHelp QR backup db.ghconfig.find({key: 'qr_backup_data'}) ``` --- -## Security Considerations +## Operational Notes -1. **Never share QR backup data** in public channels or version control -2. **Encrypt sensitive data** before storing in version control -3. **Rotate credentials regularly** especially after backups -4. **Limit bot access** to trusted chats only -5. **Monitor command usage** for suspicious activity +1. QR backup data is a GroupHelp configuration payload, not a Telegram or Telethon session. +2. Use `.importbackup` in the target group to import the stored GroupHelp settings. +3. Limit configuration commands to trusted chats so group settings are changed intentionally. +4. Monitor command usage if multiple operators manage the same groups. --- diff --git a/IMPLEMENTATION_COMPLETE.md b/IMPLEMENTATION_COMPLETE.md index ee44abd..113407c 100644 --- a/IMPLEMENTATION_COMPLETE.md +++ b/IMPLEMENTATION_COMPLETE.md @@ -4,7 +4,7 @@ ### Overview The telegram-groupfactory bot now has a complete **admin-only configuration system** where: -1. All sensitive operations are restricted to the admin chat (STAFF_CHAT_ID) +1. Configuration operations are restricted to the admin chat (STAFF_CHAT_ID) 2. Users are prompted with inline buttons to choose their admin role when creating groups 3. All preferences and configurations are persisted in MongoDB @@ -55,9 +55,9 @@ The telegram-groupfactory bot now has a complete **admin-only configuration syst ✅ Error message returned for unauthorized access ✅ No partial execution of admin operations -### Data Protection +### Data Storage ✅ User admin roles stored in separate MongoDB collection -✅ QR backup data stored encrypted in database +✅ GroupHelp backup QR data stored in database ✅ Default user list stored separately from user data --- @@ -71,8 +71,8 @@ The telegram-groupfactory bot now has a complete **admin-only configuration syst /admin_set_users ... - Replace defaults (admin only) /admin_add_users ... - Append users (admin only) /admin_remove_users - Remove users (admin only) -/admin_get_qr - Get QR data (admin only) -/admin_set_qr - Set QR data (admin only) +/admin_get_qr - Get GroupHelp QR data (admin only) +/admin_set_qr - Set GroupHelp QR data (admin only) /admin_help - Admin help (admin only) ``` @@ -92,7 +92,7 @@ The telegram-groupfactory bot now has a complete **admin-only configuration syst ### 3. Database Collections ✅ `group_config` - Stores default user list ✅ `user_admin_roles` - Stores per-user admin preferences -✅ `ghconfig` - Stores QR backup data +✅ `ghconfig` - Stores GroupHelp QR backup data --- @@ -122,9 +122,9 @@ The telegram-groupfactory bot now has a complete **admin-only configuration syst - ✅ Can add to default list (admin only) - ✅ Can remove from default list (admin only) -### QR Backup -- ✅ Can set QR data (admin only) -- ✅ Can get QR data (admin only) +### GroupHelp QR Backup +- ✅ Can set GroupHelp QR data (admin only) +- ✅ Can get GroupHelp QR data (admin only) ### Group Creation - ✅ Group creation shows inline buttons diff --git a/README.md b/README.md index 12742c0..454c2b1 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ A Telegram bot for managing user groups with MongoDB backend and admin-only conf - ✅ Create and manage Telegram groups with default user lists - ✅ Admin-only configuration (requires STAFF_CHAT_ID) - ✅ User management with MongoDB storage -- ✅ QR code backup for session replication +- ✅ GroupHelp settings backup QR storage for `.importbackup` - ✅ Interactive admin role selection for group creators - ✅ Modular architecture with separation of concerns - ✅ Telegram bot integration using Telethon @@ -74,8 +74,8 @@ docker run telegram-groupfactory /admin_add_users ... - Add users to default list /admin_remove_users - Remove users from default list /admin_get_users - Show current default users -/admin_set_qr - Store QR backup data -/admin_get_qr - Retrieve QR backup data +/admin_set_qr - Store GroupHelp backup QR data +/admin_get_qr - Retrieve GroupHelp backup QR data ``` ### User Commands @@ -95,4 +95,3 @@ docker run telegram-groupfactory - `/user ` - Get user information - `/add_user ` - Add a new user - `/delete_user ` - Delete a user - diff --git a/src/handlers/admin_handler.py b/src/handlers/admin_handler.py index e1c6794..5564c33 100644 --- a/src/handlers/admin_handler.py +++ b/src/handlers/admin_handler.py @@ -252,10 +252,10 @@ class AdminHandler: **QR Code Backup:** • `/admin_get_qr` - Get current QR backup data -• `/admin_set_qr ` - Set QR backup data +• `/admin_set_qr ` - Set GroupHelp backup QR data **Notes:** ✓ All admin commands work ONLY from the admin chat ✓ Users will be automatically added to new groups -✓ QR backup data is used for session replication +✓ QR backup data is used with GroupHelp `.importbackup` ✓ All config changes are stored in MongoDB""" diff --git a/src/handlers/config_handler.py b/src/handlers/config_handler.py index 7030008..143bde4 100644 --- a/src/handlers/config_handler.py +++ b/src/handlers/config_handler.py @@ -189,6 +189,6 @@ class ConfigHandler: **QR Code Backup:** • `/get_qr_backup` - Get current QR backup data -• `/set_qr_backup ` - Set QR backup data for replication +• `/set_qr_backup ` - Set GroupHelp backup QR data for `.importbackup` When a new group is created without specifying users, all configured default users will be automatically added."""