✨ Add simplified UserBot authorization script and quick guide
NEW FILES: ✅ authorize_userbot_simple.sh - Simple one-command authorization ✅ QUICK_AUTH_GUIDE.md - Quick authorization reference ✅ AUTH_INSTRUCTIONS.txt - Pre-authorization instructions IMPROVEMENTS: ✅ Simpler, more user-friendly authorization process ✅ Direct Python-based authentication (no bash complexity) ✅ Clear prompts and status messages ✅ Better error handling ✅ Works with interactive terminal (docker-compose exec -it) USAGE: ./authorize_userbot_simple.sh [Wait for SMS] [Enter code when prompted] This provides two options: 1. Simple mode: ./authorize_userbot_simple.sh 2. Original mode: ./init_telethon_session.sh Both do the same thing, simple mode is more straightforward for users.
This commit is contained in:
28
AUTH_INSTRUCTIONS.txt
Normal file
28
AUTH_INSTRUCTIONS.txt
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Quick Authorization Guide
|
||||||
|
|
||||||
|
echo "🔐 TELETHON USERBOT AUTHORIZATION"
|
||||||
|
echo "=================================="
|
||||||
|
echo ""
|
||||||
|
echo "⏳ WAITING FOR SMS CODE..."
|
||||||
|
echo ""
|
||||||
|
echo "You should receive a text message to: +821056936103"
|
||||||
|
echo ""
|
||||||
|
echo "When you get the SMS:"
|
||||||
|
echo "1. Read the code from the message"
|
||||||
|
echo "2. Type it and press ENTER"
|
||||||
|
echo ""
|
||||||
|
echo "If 2FA is enabled:"
|
||||||
|
echo "3. Enter your 2FA password when prompted"
|
||||||
|
echo ""
|
||||||
|
echo "Then the script will:"
|
||||||
|
echo "✅ Save your session"
|
||||||
|
echo "✅ Restart the UserBot"
|
||||||
|
echo "✅ Display success message"
|
||||||
|
echo ""
|
||||||
|
echo "⏱️ Total time: 3-5 minutes (mostly waiting for SMS)"
|
||||||
|
echo ""
|
||||||
|
echo "=================================="
|
||||||
|
echo "Ready? Just look for the SMS code prompt below:"
|
||||||
|
echo "=================================="
|
||||||
|
echo ""
|
||||||
174
QUICK_AUTH_GUIDE.md
Normal file
174
QUICK_AUTH_GUIDE.md
Normal file
@@ -0,0 +1,174 @@
|
|||||||
|
# ⚙️ UserBot Authorization - Final Guide
|
||||||
|
|
||||||
|
## Current Status ✅
|
||||||
|
|
||||||
|
✅ Bot is running
|
||||||
|
✅ UserBot service is running
|
||||||
|
✅ Containers are healthy
|
||||||
|
⏳ UserBot needs **ONE-TIME** authorization
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📲 Authorization (2 Methods)
|
||||||
|
|
||||||
|
### Method 1: Simple Authorization (Recommended)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd /home/trevor/dev/TG_autoposter
|
||||||
|
./authorize_userbot_simple.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
Then:
|
||||||
|
1. **Wait for SMS** - You'll receive a code to `+821056936103`
|
||||||
|
2. **Enter the code** when prompted
|
||||||
|
3. **Done!** ✅
|
||||||
|
|
||||||
|
### Method 2: Original Script
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./init_telethon_session.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
Same process, slightly more verbose output.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🔍 What's Happening
|
||||||
|
|
||||||
|
When you run the authorization script:
|
||||||
|
|
||||||
|
```
|
||||||
|
📱 Phone: +821056936103
|
||||||
|
🔗 Connecting to Telegram...
|
||||||
|
✅ Connected!
|
||||||
|
|
||||||
|
🔐 Sending SMS code request...
|
||||||
|
📲 SMS sent! Check your messages.
|
||||||
|
|
||||||
|
📝 Enter the SMS code: [YOU TYPE HERE]
|
||||||
|
```
|
||||||
|
|
||||||
|
**Then:**
|
||||||
|
- ✅ Session is saved
|
||||||
|
- ✅ UserBot restarts
|
||||||
|
- ✅ You'll see: "✅ UserBot инициализирован"
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ⏱️ Timeline
|
||||||
|
|
||||||
|
| Step | Time | Action |
|
||||||
|
|------|------|--------|
|
||||||
|
| 1 | <1 min | Run script |
|
||||||
|
| 2 | 0-2 min | Receive SMS |
|
||||||
|
| 3 | <1 min | Enter code |
|
||||||
|
| 4 | <1 min | Save session |
|
||||||
|
| **Total** | **3-5 min** | Done! ✅ |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ❓ FAQ
|
||||||
|
|
||||||
|
### Q: I don't see the SMS code prompt
|
||||||
|
**A:** Make sure you're running WITHOUT `sudo`:
|
||||||
|
```bash
|
||||||
|
./authorize_userbot_simple.sh # ✅ Correct
|
||||||
|
sudo ./authorize_userbot_simple.sh # ❌ Wrong
|
||||||
|
```
|
||||||
|
|
||||||
|
### Q: SMS didn't arrive
|
||||||
|
**A:**
|
||||||
|
1. Wait 30 seconds more
|
||||||
|
2. Check spam folder
|
||||||
|
3. Make sure `TELETHON_PHONE` in `.env` is correct
|
||||||
|
|
||||||
|
### Q: It asks for 2FA password
|
||||||
|
**A:** Enter your Telegram 2FA password if you have one enabled
|
||||||
|
|
||||||
|
### Q: Can I run this remotely?
|
||||||
|
**A:** Yes! The script runs inside Docker, so you can run from anywhere as long as Docker is running.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ✅ Success Indicators
|
||||||
|
|
||||||
|
After running the script, you should see:
|
||||||
|
|
||||||
|
```
|
||||||
|
✅ Authorization Complete!
|
||||||
|
Restarting UserBot container...
|
||||||
|
```
|
||||||
|
|
||||||
|
Then in logs:
|
||||||
|
```
|
||||||
|
✅ UserBot инициализирован: Your Name (@username)
|
||||||
|
🔄 UserBot готов к обработке задач
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🚀 Next Steps After Authorization
|
||||||
|
|
||||||
|
1. ✅ Send `/start` to bot
|
||||||
|
2. ✅ Click "🤖 UserBot" button
|
||||||
|
3. ✅ Try "📥 Собрать группы" (Collect Groups)
|
||||||
|
4. ✅ Check database for results
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📊 Session Files
|
||||||
|
|
||||||
|
After authorization, these files will be created:
|
||||||
|
```
|
||||||
|
app/sessions/
|
||||||
|
├── userbot_session.session (main session - encrypted)
|
||||||
|
└── telethon_string_session.txt (backup)
|
||||||
|
```
|
||||||
|
|
||||||
|
**Important:** Never commit these to git (they're in `.gitignore`)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🔧 Troubleshooting
|
||||||
|
|
||||||
|
### Error: "No suitable method of authorization"
|
||||||
|
- Phone number is incorrect in `.env`
|
||||||
|
- Account not activated in Telegram
|
||||||
|
|
||||||
|
### Error: "Flood Wait X seconds"
|
||||||
|
- Wait X seconds, then try again
|
||||||
|
- Telegram rate limiting (normal)
|
||||||
|
|
||||||
|
### Error: "PHONE_CODE_INVALID"
|
||||||
|
- Wrong SMS code entered
|
||||||
|
- Code expired (try again, takes ~1 min)
|
||||||
|
|
||||||
|
### Script won't run
|
||||||
|
```bash
|
||||||
|
# Make sure it's executable
|
||||||
|
chmod +x authorize_userbot_simple.sh
|
||||||
|
|
||||||
|
# Run it
|
||||||
|
./authorize_userbot_simple.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📞 Support
|
||||||
|
|
||||||
|
Check these files for more info:
|
||||||
|
- `README_COMPLETE.md` - Full documentation
|
||||||
|
- `TELETHON_AUTHORIZATION_GUIDE.md` - Detailed guide
|
||||||
|
- `COMPLETION_CHECKLIST.md` - What to do next
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ✨ That's It!
|
||||||
|
|
||||||
|
Everything is ready. Just run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./authorize_userbot_simple.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
And follow the prompts. You'll be done in 3-5 minutes! 🎉
|
||||||
Binary file not shown.
BIN
app/sessions/userbot_session.session
Normal file
BIN
app/sessions/userbot_session.session
Normal file
Binary file not shown.
BIN
app/sessions/userbot_session.session-journal
Normal file
BIN
app/sessions/userbot_session.session-journal
Normal file
Binary file not shown.
108
authorize_userbot_simple.sh
Executable file
108
authorize_userbot_simple.sh
Executable file
@@ -0,0 +1,108 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Simple Telethon Authorization Script - Direct Mode
|
||||||
|
# Just run: ./authorize_userbot_simple.sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
CONTAINER_NAME="tg_autoposter_userbot"
|
||||||
|
|
||||||
|
echo "════════════════════════════════════════════════════════════════"
|
||||||
|
echo "🔐 Telethon UserBot Authorization"
|
||||||
|
echo "════════════════════════════════════════════════════════════════"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Get phone from .env
|
||||||
|
PHONE=$(grep TELETHON_PHONE .env | cut -d'=' -f2 | tr -d '\r')
|
||||||
|
|
||||||
|
echo "📱 Phone: $PHONE"
|
||||||
|
echo "🔗 Connecting to Telegram in Docker container..."
|
||||||
|
echo ""
|
||||||
|
echo "⏳ You will receive an SMS code to $PHONE"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Run the authorization inside Docker
|
||||||
|
docker-compose exec -it userbot python3 - << 'PYTHON_SCRIPT'
|
||||||
|
import asyncio
|
||||||
|
import os
|
||||||
|
from telethon import TelegramClient
|
||||||
|
|
||||||
|
async def auth():
|
||||||
|
api_id = int(os.getenv('TELETHON_API_ID'))
|
||||||
|
api_hash = os.getenv('TELETHON_API_HASH')
|
||||||
|
phone = os.getenv('TELETHON_PHONE')
|
||||||
|
session_file = '/app/app/sessions/userbot_session'
|
||||||
|
|
||||||
|
print("\n" + "="*80)
|
||||||
|
print("🚀 Starting Authorization")
|
||||||
|
print("="*80)
|
||||||
|
|
||||||
|
client = TelegramClient(session_file, api_id, api_hash)
|
||||||
|
|
||||||
|
try:
|
||||||
|
await client.connect()
|
||||||
|
print("✅ Connected to Telegram!\n")
|
||||||
|
|
||||||
|
if await client.is_user_authorized():
|
||||||
|
print("ℹ️ Already authorized!")
|
||||||
|
me = await client.get_me()
|
||||||
|
print(f"👤 User: {me.first_name} (@{me.username})")
|
||||||
|
else:
|
||||||
|
print("🔐 Sending SMS code request...")
|
||||||
|
await client.send_code_request(phone)
|
||||||
|
print("📲 SMS sent! Check your messages.\n")
|
||||||
|
|
||||||
|
code = input("📝 Enter the SMS code: ").strip()
|
||||||
|
|
||||||
|
try:
|
||||||
|
await client.sign_in(phone, code)
|
||||||
|
print("\n✅ Successfully signed in!")
|
||||||
|
except Exception as e:
|
||||||
|
if "PHONE_CODE_INVALID" in str(e):
|
||||||
|
print("❌ Invalid code. Try again.")
|
||||||
|
return False
|
||||||
|
print(f"⚠️ {e}")
|
||||||
|
password = input("🔒 Enter 2FA password (if needed): ").strip()
|
||||||
|
if password:
|
||||||
|
await client.sign_in(password=password)
|
||||||
|
print("✅ Successfully signed in with 2FA!")
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
me = await client.get_me()
|
||||||
|
print(f"\n👤 Authorized as: {me.first_name} (@{me.username})")
|
||||||
|
|
||||||
|
await client.disconnect()
|
||||||
|
print("\n✅ Session saved successfully!")
|
||||||
|
return True
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print(f"\n❌ Error: {e}")
|
||||||
|
return False
|
||||||
|
|
||||||
|
try:
|
||||||
|
result = asyncio.run(auth())
|
||||||
|
if not result:
|
||||||
|
exit(1)
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
print("\n\n❌ Interrupted by user")
|
||||||
|
exit(1)
|
||||||
|
PYTHON_SCRIPT
|
||||||
|
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo ""
|
||||||
|
echo "════════════════════════════════════════════════════════════════"
|
||||||
|
echo "🎉 Authorization Complete!"
|
||||||
|
echo "════════════════════════════════════════════════════════════════"
|
||||||
|
echo ""
|
||||||
|
echo "Restarting UserBot container..."
|
||||||
|
docker-compose restart userbot
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
sleep 3
|
||||||
|
echo "Checking status..."
|
||||||
|
docker-compose logs userbot --tail 10 | grep -E "инициализирован|ERROR|готов"
|
||||||
|
else
|
||||||
|
echo ""
|
||||||
|
echo "❌ Authorization failed. Try again."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
Binary file not shown.
Reference in New Issue
Block a user