NEW FILES: ✅ init_telethon_session.py - Interactive Python script for session initialization ✅ init_telethon_session.sh - Bash wrapper for Docker-based authorization ✅ TELETHON_AUTHORIZATION_GUIDE.md - Comprehensive authorization guide ✅ USERBOT_AUTHORIZATION_README.md - Quick start guide for users FEATURES: ✅ Interactive authorization flow with SMS code verification ✅ 2FA password support ✅ Session persistence to app/sessions/ ✅ Docker container integration ✅ Verification of existing sessions ✅ Clear error messages and troubleshooting USAGE: $ ./init_telethon_session.sh Or: $ python3 init_telethon_session.py This solves the UserBot authorization issue where Telethon requires interactive SMS code verification on first setup.
3.1 KiB
3.1 KiB
⚠️ UserBot Authorization Required - IMPORTANT
🔐 What's Happening
You're seeing this message in UserBot logs:
❌ UserBot не авторизован. Требуется повторный вход.
This is normal and expected ✅
✅ Quick Fix (3 minutes)
Step 1: Open a terminal and run
cd /home/trevor/dev/TG_autoposter
# Make the script executable
chmod +x init_telethon_session.sh
# Run the interactive authorization
./init_telethon_session.sh
Step 2: Follow the prompts
- You'll see a message asking for SMS code:
📝 Enter the SMS code: [wait for SMS]
-
You'll receive an SMS with a code to
+821056936103 -
Enter the code and press Enter
-
If 2FA is enabled, enter your password
-
Done! ✅
📋 Alternative: Manual Authorization
If the script doesn't work, try this:
# Run the Python script directly
python3 init_telethon_session.py
Or inside Docker:
docker-compose exec -it userbot python3 init_telethon_session.py
🎯 What's Happening Behind the Scenes
- Telethon (Telegram library) needs to authenticate with your user account
- Telegram sends an SMS code for verification
- The script saves this authentication session to
app/sessions/ - Docker container uses this saved session to work as your UserBot
- No interaction needed after authorization - fully automated
✅ How to Know It Worked
After authorization, you'll see in logs:
✅ UserBot инициализирован: Your Name (@username)
🔄 UserBot готов к обработке задач
And the bot will show "🤖 UserBot" button in the menu.
🐛 Troubleshooting
"SMS code not received"
- Wait 30 seconds
- Check spam folder
- Make sure
TELETHON_PHONEin.envis correct
"Invalid API credentials"
- Verify
TELETHON_API_IDandTELETHON_API_HASHin.env - Get them from https://my.telegram.org
"Session file already exists"
- Delete old session:
rm -rf app/sessions/ - Run authorization again
Script timeout
- Re-run the script
- Make sure you're connected to internet
📁 Files Created After Authorization
app/sessions/
├── userbot_session.session ← Main session file
└── telethon_string_session.txt ← Backup
These files are encrypted and contain your session data.
🚀 What to Do Next
After successful authorization:
-
✅ Restart the bot:
docker-compose restart bot -
✅ Test
/startcommand to bot -
✅ Click "🤖 UserBot" button
-
✅ Collect groups or members
⏱️ Expected Timeline
| Step | Time |
|---|---|
| Open terminal | 1 min |
| Run script | 1 min |
| Receive SMS | 0-2 min |
| Enter code | 1 min |
| Done | ~5 minutes |
📞 Still Having Issues?
- Check the detailed guide
- Review logs:
docker-compose logs userbot -f - Verify
.envhas all TELETHON variables - Make sure internet connection is stable
Start authorization now:
./init_telethon_session.sh
✨ You got this!