Skip to content

NgrhDn/Project-Forward-Bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿค– Project Forward Bot Telegram

Bot otomatis untuk memforward media (foto, video, dan GIF) dari channel Telegram ke grup/tujuan tertentu dengan AUTO-RECONNECT, SMART PAUSE SYSTEM, dan optimasi khusus untuk Termux/Android.


๐Ÿ“ฆ Fitur Utama

  • โœ… Auto-Reconnect: Tidak pernah berhenti karena masalah jaringan
  • โœ… Smart Pause System: Auto-pause saat memory penuh dengan interactive resume
  • โœ… Perfect Anti-Duplicate: Per-message ID tracking yang tidak pernah duplicate
  • โœ… Memory Monitoring: Real-time memory monitoring dengan auto-pause threshold
  • โœ… Interactive Controls: Pause/resume/quit controls yang responsive
  • โœ… Auto Log Management: Otomatis setup folder log baru saat ganti source channel
  • โœ… Termux Optimized: Dioptimasi khusus untuk Android/Termux environment
  • โœ… FloodWait Handling: Handle rate limiting Telegram dengan sempurna
  • โœ… Real-time Monitoring: Forward otomatis saat ada media baru
  • โœ… Batch Processing: Scan semua pesan lama atau sejumlah tertentu
  • โœ… Connection Monitor: Monitor koneksi real-time setiap 20 detik
  • โœ… Graceful Shutdown: Berhenti dengan aman menggunakan Ctrl+C
  • โœ… Helper Scripts: setup_channel.py untuk easy channel switching

๐Ÿ†• Fitur Terbaru (v2.1.0)

  • โธ๏ธ Smart Pause System: Auto-pause saat memory penuh dengan interactive resume controls
  • ๐Ÿ†” Perfect Anti-Duplicate: Per-message ID tracking yang tidak pernah duplicate meskipun restart
  • ๐Ÿ“ Auto Log Management: Otomatis backup log lama dan setup folder log baru saat ganti source channel
  • ๐Ÿ”ง Memory Monitoring: Real-time memory monitoring dengan threshold auto-pause (< 100MB atau > 90% usage)
  • ๐ŸŽฎ Interactive Controls: Pause/resume/quit controls dengan pilihan c/q/m yang responsive
  • ๐Ÿ’พ Smart ID Management: Improved ID tracking dan file handling dengan UTF-8 encoding
  • ๐Ÿ“Š Better Progress Display: Progress tracking dengan memory status real-time setiap 25 pesan
  • ๐Ÿ› ๏ธ Helper Scripts: setup_channel.py untuk easy channel switching dan auto-backup
  • ๐Ÿ”„ Batch Optimization: Smaller batch size (25) untuk optimal Termux performance
  • ๐Ÿ“ฑ Enhanced Mobile Support: Better resource management untuk Android/Termux environment

๐Ÿš€ Instalasi & Jalankan

๐Ÿ“ฑ Untuk Termux (Android) - RECOMMENDED

1. Clone & Setup

git clone https://github.com/NgrhDn/Project-Forward-Bot.git
cd Project-Forward-Bot

# Jalankan setup otomatis (sekali saja)
chmod +x setup_termux.sh
./setup_termux.sh

2. Konfigurasi Channel

# Gunakan helper script (recommended)
python setup_channel.py

# Atau manual edit main.py

3. Jalankan Bot

# Simple (Recommended)
python main.py

# Dengan Auto-Restart
chmod +x run_termux.sh
./run_termux.sh

๐Ÿ’ป Untuk Windows

1. Clone & Install

git clone https://github.com/NgrhDn/Project-Forward-Bot.git
cd Project-Forward-Bot
pip install -r requirements.txt

2. Konfigurasi

# Setup channel dengan helper script
python setup_channel.py

3. Jalankan

# Simple
python main.py

# Dengan Auto-Restart
python run_bot.py

# Atau double-click
start_bot.bat

๐Ÿง Untuk Linux/VPS

git clone https://github.com/NgrhDn/Project-Forward-Bot.git
cd Project-Forward-Bot
pip install -r requirements.txt
python setup_channel.py  # Setup channel
python main.py           # Jalankan bot

โš™๏ธ Konfigurasi

1. Mendapatkan API Credentials

  • Kunjungi my.telegram.org
  • Login dengan nomor Telegram
  • Buat aplikasi baru
  • Salin api_id dan api_hash

2. Setup Channel dengan Helper Script (RECOMMENDED)

# Jalankan helper script
python setup_channel.py

# Script akan meminta:
# - Source channel ID (channel sumber)
# - Target channel ID (grup/channel tujuan)
# 
# Dan otomatis:
# โœ… Backup log lama ke logs_backup/
# โœ… Buat folder log baru
# โœ… Update konfigurasi main.py
# โœ… Ready to run!

3. Manual Setup (Alternative)

Edit main.py secara manual:

# === Konfigurasi API ===
api_id = 12345678  # Your API ID
api_hash = 'your_api_hash_here'

# === ID Channel dan Grup ===
source_channel = -1001234567890  # Channel sumber
target_channel = -1009876543210  # Grup/channel tujuan

๐ŸŽฎ Cara Penggunaan

Mode Scanning

  1. Scan Semua: Scan semua pesan dari awal channel
  2. Scan Terbatas: Scan sejumlah pesan terakhir (contoh: 1000)
  3. Real-time Only: Langsung ke mode real-time tanpa scan

Interactive Controls (NEW!)

Bot dilengkapi dengan sistem kontrol interaktif:

Saat Memory Penuh:

โธ๏ธ BOT DIJEDA: Memory penuh - 45MB tersisa (95.2% used)
๐Ÿ”ง Silakan bersihkan memory/storage atau perbaiki masalah
โšก Ketik 'c' + Enter untuk melanjutkan setelah masalah diperbaiki

๐Ÿ’ก Pilihan:
   c = Continue (lanjutkan setelah bersihkan memory)
   q = Quit (keluar dari bot)
   m = Check memory status

Pilihan (c/q/m): _

Controls Available:

  • c = Continue (lanjutkan setelah pause)
  • q = Quit (keluar dari bot)
  • m = Memory check (cek status memory)
  • Ctrl+C = Graceful shutdown

Ganti Source Channel

# Gunakan helper script (SANGAT MUDAH!)
python setup_channel.py

# Otomatis:
# 1. Input channel ID baru
# 2. Backup log lama ke logs_backup/
# 3. Buat folder log baru
# 4. Update main.py
# 5. Siap dijalankan!

Monitor Progress dengan Memory Status

๐Ÿ“Š Progress: 25/1000 | Memory OK: 150MB tersisa (75.2% used)
[25 dari 1000] โœ… Dikirim (ID: 12345) ๐Ÿ“ฅ Scan
๐Ÿ›‘ Delay 20 detik untuk keamanan (per 25 pesan)...

๐Ÿ“ฑ Tips Khusus Termux

Optimasi Android

  1. Disable Battery Optimization:

    • Settings โ†’ Apps โ†’ Termux โ†’ Battery โ†’ Don't optimize
  2. Keep Termux Active:

    • Jangan minimize terlalu lama
    • Pin Termux di recent apps
  3. Network Stability:

    • Gunakan WiFi stabil
    • Hindari mobile data yang tidak stabil
  4. Memory Management:

    • Bot otomatis pause saat memory < 100MB
    • Bersihkan storage secara berkala
    • Tutup aplikasi lain yang tidak perlu
  5. Permissions & Setup:

    # Install Termux API untuk wake lock
    pkg install termux-api
    
    # Grant storage permission
    termux-setup-storage
    
    # Install psutil untuk memory monitoring
    pip install psutil

๐Ÿ› ๏ธ Troubleshooting

Memory Full Issues (NEW!)

โธ๏ธ BOT DIJEDA: Memory penuh - 50MB tersisa (92.1% used)
๐Ÿ”ง Silakan bersihkan memory/storage atau perbaiki masalah

โœ… SOLUSI: 
1. Bersihkan storage/memory HP
2. Tutup aplikasi lain yang tidak perlu  
3. Hapus file tidak perlu
4. Ketik 'c' untuk melanjutkan

Connection Issues

โŒ ConnectionError: Connection to Telegram failed
โœ… SOLUSI: Bot akan auto-reconnect, tunggu saja

FloodWait Errors

โŒ FloodWaitError: Too many requests
โœ… SOLUSI: Bot akan otomatis pause dan resume setelah delay

Duplicate Messages

โ™ป๏ธ Lewat (ID: 12347) Sudah pernah dikirim
โœ… SOLUSI: Bot otomatis skip pesan yang sudah dikirim (Perfect!)

Permission Denied (Termux)

chmod +x *.sh

Module Not Found

pip install -r requirements.txt --upgrade

๐Ÿ“Š Monitoring & Logs

File Log Structure

logs/
โ”œโ”€โ”€ {source_channel_id}/
โ”‚   โ”œโ”€โ”€ forwarded_ids.txt    # ID pesan yang sudah dikirim
โ”‚   โ”œโ”€โ”€ failed_ids.txt       # ID pesan yang gagal
โ”‚   โ””โ”€โ”€ log.txt             # Log aktivitas lengkap
โ””โ”€โ”€ logs_backup/            # Backup otomatis log lama
    โ””โ”€โ”€ {old_channel}_{timestamp}/

Real-time Status Display

โœ… Dikirim (ID: 12345) ๐Ÿ“ฅ Realtime
โŒ Gagal kirim ID 12346 
โ™ป๏ธ Lewat (ID: 12347) Sudah pernah dikirim
๐Ÿ”„ Retry batch 10 media gagal...
๐Ÿ“ก Koneksi pulih!
๐Ÿ“Š Progress: 25/1000 | Memory OK: 150MB tersisa (75.2% used)
โธ๏ธ BOT DIJEDA: Memory penuh - bersihkan storage
๐Ÿ’พ Saved forwarded ID: 12348
๐Ÿ—‘๏ธ Removed from failed list: 12349

Memory Monitoring Display

๐Ÿ“Š Memory OK: 250MB tersisa (65.5% used)
๐Ÿ“Š Memory rendah: 80MB tersisa (92.1% used)
โธ๏ธ BOT DIJEDA: Memory penuh - 45MB tersisa (95.2% used)

๐Ÿ”ง Advanced Configuration

Memory Threshold Customization

# Edit di check_memory_usage() function
if available_mb < 100 or used_percent > 90:  # Threshold default
    return False, "Memory rendah"

# Bisa diubah sesuai kebutuhan:
# available_mb < 200  # Untuk threshold 200MB
# used_percent > 85   # Untuk threshold 85%

Batch Size Optimization

# Edit di berbagai bagian kode
retry_batch = list(failed_ids)[:25]  # Default: 25 untuk Termux
# Bisa diubah ke 50 untuk PC yang lebih powerful

# Memory check interval
if count % 25 == 0:  # Default: setiap 25 pesan
# Bisa diubah ke 50 atau 100 untuk device powerful

Auto Log Management

  • Log otomatis terpisah per channel ID
  • Backup otomatis saat ganti channel dengan timestamp
  • Struktur: logs/{channel_id}/ dan logs_backup/{old_channel}_{timestamp}/
  • Helper script setup_channel.py untuk easy switching

๐Ÿ“‹ Requirements

Minimum System

  • Python 3.7+
  • 100MB free storage minimum (untuk log dan cache)
  • 512MB RAM minimum (1GB recommended)
  • Internet connection (WiFi recommended untuk Termux)

Dependencies

telethon==1.40.0
psutil>=5.8.0 (untuk memory monitoring)

Optional (Termux)

termux-api (untuk wake lock)

๐Ÿ› ๏ธ Helper Scripts

setup_channel.py (NEW!)

Script untuk mengganti source channel dengan mudah:

python setup_channel.py

# Fitur:
โœ… Input channel ID baru dengan validasi
โœ… Backup log lama otomatis ke logs_backup/
โœ… Buat folder log baru dengan struktur lengkap
โœ… Update konfigurasi main.py otomatis
โœ… Backup main.py sebelum edit
โœ… Setup lengkap untuk channel baru
โœ… Ready to run langsung setelah setup

Memory Management (NEW!)

Bot secara otomatis:

  • Monitor memory setiap 25 pesan
  • Pause saat memory < 100MB atau usage > 90%
  • Berikan kontrol interaktif untuk resume
  • Log status memory di setiap progress update
  • Cross-platform: psutil + /proc/meminfo fallback

Auto-Restart Scripts

# Termux
./run_termux.sh          # Advanced dengan monitoring
nohup ./run_termux.sh &  # Background mode

# Windows  
start_bot.bat            # Batch file auto-restart
python run_bot.py        # Python auto-restart

# Linux
python run_bot.py        # Python auto-restart

๐Ÿค Contributing

Kontribusi sangat diterima! Silakan:

  1. Fork repository
  2. Buat feature branch (git checkout -b feature/AmazingFeature)
  3. Commit perubahan (git commit -m 'Add AmazingFeature')
  4. Push ke branch (git push origin feature/AmazingFeature)
  5. Buka Pull Request

Areas yang membutuhkan kontribusi:

  • Multi-language support
  • GUI interface
  • Database integration
  • Advanced filtering options
  • Performance optimizations

๐Ÿ“„ License

Distributed under the MIT License. See LICENSE for more information.


๐Ÿ™ Acknowledgments

  • Telethon - MTProto API client
  • Termux - Android terminal emulator
  • psutil - System and process utilities
  • Komunitas Telegram Bot Indonesia

๐Ÿ“ž Support


๐Ÿ”„ Changelog

v2.1.0 (Latest)

  • โธ๏ธ Smart Pause System: Auto-pause saat memory penuh dengan interactive resume
  • ๐Ÿ†” Perfect Anti-Duplicate: Per-message ID tracking yang tidak pernah duplicate
  • ๐Ÿ“ Auto Log Management: Otomatis setup folder log baru saat ganti source channel
  • ๐Ÿ”ง Memory Monitoring: Real-time memory monitoring dengan threshold auto-pause
  • ๐ŸŽฎ Interactive Controls: Pause/resume/quit controls yang responsive
  • ๐Ÿ’พ Smart ID Management: Improved ID tracking dan file handling
  • ๐Ÿ“Š Better Progress Display: Progress dengan memory status real-time
  • ๐Ÿ› ๏ธ Helper Scripts: setup_channel.py untuk easy channel switching
  • ๐Ÿ”„ Batch Optimization: Smaller batch size (25) untuk Termux performance

v2.0.0

  • โœจ AUTO-RECONNECT: Never stops due to network issues
  • ๐Ÿ›ก๏ธ Error Recovery: Automatic recovery from all network errors
  • ๐Ÿ“ฑ Termux Optimization: Full Android/Termux support
  • โšก Performance: Faster processing with smart delays
  • ๐Ÿ” Wake Lock: Prevent Android from killing the process
  • ๐Ÿ“Š Better Logging: Comprehensive logging system
  • ๐ŸŽฏ Smart Retry: Progressive delays for retry attempts

v1.0.0

  • ๐ŸŽ‰ Initial release
  • โœ… Basic forwarding functionality
  • ๐Ÿ“ Log system per channel
  • ๐Ÿ”„ Retry mechanism for failed messages

โญ Jika project ini membantu, berikan star di GitHub!

๐Ÿš€ Ready to use dengan confidence - Bot yang tidak pernah berhenti!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published