AGENT
import asyncio
import logging
import os
import re
import random
import gc
from datetime import datetime, timedelta
from telethon import TelegramClient, events, functions, Button
from telethon.tl.functions.channels import JoinChannelRequest, LeaveChannelRequest, GetParticipantRequest
from telethon.tl.functions.messages import ImportChatInviteRequest, CheckChatInviteRequest, DeleteHistoryRequest
from telethon.errors import UserNotParticipantError, UserAlreadyParticipantError, FloodWaitError, RPCError
from telethon.network.connection.tcpabridged import ConnectionTcpAbridged
# --- NEW: Android Sleep Fix (Background me code ko sone nahi dega) ---
try:
os.system("termux-wake-lock")
except Exception:
pass
# --- NEW: Aggressive Memory Management ---
gc.enable()
gc.set_threshold(100, 5, 5)
# --- CONFIGURATION ---
API_ID = 37236703
API_HASH = 'a6d70fd6d0f99283ec4eea089e0ea397'
# Old Baymax Bot Token
BOT_TOKEN = '8521329345:AAEVewc37nXg-uAeH3G1e5syoTCkFeHynQ4'
# Watch Earn Bot Token
WATCH_EARN_BOT_TOKEN = '7898908811:AAELEWD6Pe_RFsyr48iuRj4YTiQeQfu3zBA'
# NAYA: YouTube Sub Bot Token
YOUTUBE_SUB_BOT_TOKEN = '8684849367:AAGkmccGzBk0MGZqdz04oP7k-5JsQBXN8c0'
AGENTS = [1, 2, 3, 4, 6, 7, 8, 9]
REPLY_AGENTS = [2, 3, 4, 6, 7, 8, 9] # Agent 1 isme nahi hai, sirf 2-9 reply karenge
MY_GROUP_USER = "lSub4SUb1"
MY_CHANNEL_USER = "LootRadarIndia"
MY_CHANNEL_LINK = "https://t.me/LootRadarIndia"
FRIEND_GROUP_USER = "youtubesubscribers04"
FRIEND_CHANNEL_USER = "RebelKing091"
FRIEND_CHANNEL_LINK = "https://t.me/RebelKing091"
# --- HUNTER CONFIG ---
HUNTER_DESTINATION = "@ExtraPeBot"
HUNTER_TARGETS = ["apnaoffers", "Loots_shopsy"]
# Promo Config (My Group ka link update kar diya gaya hai)
PROMO_URL_MY_GRP = "https://t.me/Youtube20Sub_bot"
PROMO_URL_FRND_GRP = "https://www.vibzon.shop/p/update-new-page.html?m=1"
# Fresh Join Cycle
CYCLE_GROUPS = [
'https://t.me/+WUYF1rZ1ci5jNGNl',
'https://t.me/spreadinggyansub4sub123',
'https://t.me/Rishteytechnical'
]
# --- MESSAGES ---
NORMAL_MSG = """Aap Yha Apni Link Bhejh Skte Ho
👉 https://t.me/lSub4SUb1"""
# --- UPDATE: Naya message set kar diya gaya hai ---
REEL_MSG = """Bhai yaar sach me kasam ye yha par to daily ke 100 subscribe mil re he ek baar YouTube link dal ke Dekho ni mile subscribe to meko aap gali Dena okk lo
https://t.me/Youtube20Sub_bot"""
# --- AUTO REPLY CUSTOM TEXTS ---
SUB_MESSAGES = {
2: "thanku Bhai tumhari vajah SE mere 5K subscribers complete hogye bhot bhot dhaniywad",
3: "Bhai tumahri vajah SE Mera channel monetize hogya thanku",
4: "Bhai mekko aaz ke 100 sub ni mile sirf 78 hi mile esa kyu",
6: "Bhai mene SAB ads par 30 second ruka fir bhi mekko 90 subscriber hi mile",
7: "Bhai aaj sub jaldi aagye, thanku so much daily sub dene ke liye",
8: "Bhai 100 sub ka order lagaya tha, 110 aa gaye, maza aa gaya!",
9: "Koi mujhe bataega refer kaise karna hai isme? Baaki sub to fast aate hain."
}
MONEY_MESSAGES = {
2: "thanku Bhai tumhari vajah SE ab tak mere 3500 rupay hoggye me roz chalta hu ye",
3: "Bhai aaz to meko 85 rupay hi mile",
4: "Bhai par refer 2 rupay hi mil Rey he mekko to",
6: "Maine kal withdraw lagaya tha, subha tak bank me aa gaye paise!",
7: "Thanku bhai, kal mere 500 rupay seedha bank me aagye the",
8: "Bhai mene 10 dosto ko refer kiya par sirf 5 ka paisa mila baaki kab aayega?",
9: "Ye sach me real app hai yaar, pehle mujhe fake lag raha tha"
}
# --- GLOBAL TRACKERS ---
smart_cycle = {}
user_msg_counts = {}
friend_promo_counter = 0
my_promo_counter = 0
# Direct counters for Perfect Rotation
global_sub_promo_count = 0
global_money_promo_count = 0
sub_agent_idx = 0
money_agent_idx = 0
FRIEND_JOIN_STACK = []
MY_JOIN_STACK = []
reel_users_state = {}
agent_clients = {}
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(message)s')
# --- HELPER: CHECK JOIN ---
async def check_joined(client, user_id):
try:
await client(GetParticipantRequest(MY_GROUP_USER, user_id))
return True
except UserNotParticipantError:
return False
except Exception:
return False
# --- HELPER: AGENT REPLY ---
async def agent_reply_to_promo(agent_num, chat_id, msg_id, text):
await asyncio.sleep(random.uniform(2.0, 4.0)) # Type karne ka natak
if agent_num in agent_clients:
try:
await agent_clients[agent_num].send_message(chat_id, text, reply_to=msg_id)
except Exception as e:
print(f"❌ Agent {agent_num} Reply Error: {e}")
# --- TASK 1: SMART 20-MIN WORKER (Ab 5-Min Worker Ban Gaya Hai) ---
async def smart_worker(client, agent_id):
while True:
try:
if agent_id in smart_cycle:
now = datetime.now()
to_process = []
for user_id, data in list(smart_cycle[agent_id].items()):
if now >= data['next_run']:
to_process.append(user_id)
for user_id in to_process:
try:
stage = smart_cycle[agent_id][user_id].get('stage')
# --- UPDATE: Ab 5 minute ke baad direct chat delete karke naya message bhejega ---
if stage == '5_min':
try: await client(DeleteHistoryRequest(peer=user_id, max_id=0, just_clear=False, revoke=True))
except: pass
await asyncio.sleep(1)
try: await client.send_message(user_id, REEL_MSG)
except: pass
if agent_id not in reel_users_state:
reel_users_state[agent_id] = set()
reel_users_state[agent_id].add(user_id)
del smart_cycle[agent_id][user_id]
await asyncio.sleep(2)
except Exception:
if user_id in smart_cycle[agent_id]: del smart_cycle[agent_id][user_id]
await asyncio.sleep(30)
except: await asyncio.sleep(30)
# --- TASK 2: KEEP ONLINE & CYCLE ---
async def agent_task(client, num):
async def keep_online():
while True:
try:
if not client.is_connected():
try: await client.connect()
except: pass
try: await client(functions.updates.GetStateRequest())
except Exception: pass
try:
await client(functions.account.UpdateStatusRequest(offline=False))
except FloodWaitError:
pass
except Exception:
pass
except Exception:
pass
await asyncio.sleep(10)
async def cycle():
if num in AGENTS:
index = AGENTS.index(num)
wait_time = index * 120
if wait_time > 0:
print(f"⏳ Agent {num}: Waiting {wait_time}s to start cycle loop...")
await asyncio.sleep(wait_time)
print(f"🚀 Agent {num}: Cycle Started!")
while True:
try:
for link in CYCLE_GROUPS:
try:
if '+' in link:
hash_v = link.split('+')[1]
try: await client(LeaveChannelRequest(hash_v))
except: pass
await asyncio.sleep(2); await client(ImportChatInviteRequest(hash_v))
else:
u_n = link.split('/')[-1]
try: await client(LeaveChannelRequest(u_n))
except: pass
await asyncio.sleep(2); await client(JoinChannelRequest(u_n))
except: pass
await asyncio.sleep(540)
except: await asyncio.sleep(60)
client.loop.create_task(keep_online())
client.loop.create_task(cycle())
# --- MAIN AGENT START ---
async def start_agent(num):
try:
client = TelegramClient(
f'agent{num}',
API_ID,
API_HASH,
connection=ConnectionTcpAbridged,
connection_retries=None,
retry_delay=1,
timeout=30,
flood_sleep_threshold=60,
auto_reconnect=True
)
await client.start()
smart_cycle[num] = {}
agent_clients[num] = client
@client.on(events.NewMessage(incoming=True, func=lambda e: e.is_private))
async def auto_reply(event):
sender = await event.get_sender()
if sender.bot: return
user_id = sender.id
if num in reel_users_state and user_id in reel_users_state[num]:
try: await event.reply(REEL_MSG)
except: pass
return
try: await event.reply(NORMAL_MSG)
except: pass
# Pehla message aane ke baad 5 minute ka timer start hota hai
if user_id not in smart_cycle[num]:
smart_cycle[num][user_id] = {'next_run': datetime.now() + timedelta(minutes=5), 'stage': '5_min'}
# --- HUNTER LOGIC (AGENT 1) - IMAGE FILTER PERFECT ---
if num == 1:
print(f"🏹 Agent 1: Targeting {HUNTER_TARGETS} (Only Messages with Images)...")
hunter_queue = asyncio.Queue()
async def hunter_sender():
while True:
event = await hunter_queue.get()
try:
msg_text = event.text or ""
if getattr(event, 'photo', None):
await client.send_message(HUNTER_DESTINATION, msg_text, file=event.media)
print(f"✅ Hunter Message Pasted with Image. Waiting 30 minutes for next...")
await asyncio.sleep(1800) # 30 mins wait
except Exception as e:
print(f"❌ Paste Error: {e}")
client.loop.create_task(hunter_sender())
for target in HUNTER_TARGETS:
try:
target_entity = await client.get_entity(target)
try: await client(JoinChannelRequest(target_entity))
except UserAlreadyParticipantError: pass
except Exception as e: print(f"⚠️ Join Warning for {target}: {e}")
except Exception as e:
print(f"❌ HUNTER ERROR for {target}: {e}")
@client.on(events.NewMessage(chats=HUNTER_TARGETS))
async def hunter(event):
if getattr(event, 'photo', None):
await hunter_queue.put(event)
print(f"📥 New image message added to Hunter Schedule. Total pending: {hunter_queue.qsize()}")
else:
pass
client.loop.create_task(smart_worker(client, num))
await agent_task(client, num)
return client
except: return None
# --- BAYMAX GUARD ---
async def start_baymax():
try:
bot = TelegramClient('baymax_guard', API_ID, API_HASH)
await bot.start(bot_token=BOT_TOKEN)
print("🛡️ BAYMAX GUARD STARTED")
@bot.on(events.NewMessage(chats='Hot_videos_HD2'))
async def channel_formatter(event):
if event.reply_markup:
return
text_to_check = event.text or ""
urls = re.findall(r'(https?://[^\s]+)', text_to_check)
if urls:
link = urls[0]
clean_text = text_to_check.replace(link, '').strip()
if not clean_text and not event.media:
clean_text = "Click Below:"
media_to_send = event.media
if media_to_send and 'WebPage' in type(media_to_send).__name__:
media_to_send = None
try:
await bot.send_message(
event.chat_id,
clean_text,
file=media_to_send,
buttons=[[Button.url("Join ✴️", link)]],
link_preview=True
)
await event.delete()
except Exception as e:
print(f"❌ Baymax Channel Format Error: {e}")
@bot.on(events.ChatAction)
async def action_handler(event):
if event.user_joined or event.user_added:
chat = await event.get_chat()
if hasattr(chat, 'username') and chat.username.lower() == MY_GROUP_USER.lower():
user = await event.get_user()
name = f"[{user.first_name}](tg://user?id={user.id})"
await bot.send_message(event.chat_id, f"Welcome 🩷 {name}\n Sub 4 Sub 🖇️")
try: await event.delete()
except: pass
@bot.on(events.NewMessage(incoming=True))
async def msg_handler(event):
global user_msg_counts, friend_promo_counter, my_promo_counter, FRIEND_JOIN_STACK, MY_JOIN_STACK
global global_sub_promo_count, global_money_promo_count, sub_agent_idx, money_agent_idx
if event.is_private or event.sender_id == (await bot.get_me()).id: return
chat = await event.get_chat()
if not hasattr(chat, 'username') or not chat.username: return
c_user = chat.username.lower()
u_id = event.sender_id
sender = await event.get_sender()
sender_name = "User"
if sender:
if hasattr(sender, 'first_name') and sender.first_name:
sender_name = sender.first_name
elif hasattr(sender, 'title') and sender.title:
sender_name = sender.title
mention = f"[{sender_name}](tg://user?id={u_id})" if u_id else sender_name
if c_user == FRIEND_GROUP_USER.lower():
try: await bot(GetParticipantRequest(FRIEND_CHANNEL_USER, u_id))
except UserNotParticipantError:
try: await event.delete()
except: pass
btn = [[Button.url("Join Channel 🚀", FRIEND_CHANNEL_LINK)]]
m = await event.respond(f"⛔️ {mention}\n\n~ Message karne ke liye pehle channel join karein! 👇🏻", buttons=btn)
FRIEND_JOIN_STACK.append(m.id)
while len(FRIEND_JOIN_STACK) > 3:
old_id = FRIEND_JOIN_STACK.pop(0)
try: await bot.delete_messages(event.chat_id, old_id)
except: pass
return
friend_promo_counter += 1
if friend_promo_counter % 1 == 0:
btn = [[Button.url("50 subscribe", PROMO_URL_FRND_GRP)]]
await event.respond(f"{mention}\nDaily Free 50 subscribe 100% real active ( non drop) Subscribe Pane ke liye click kare 👇", buttons=btn)
return
elif c_user == MY_GROUP_USER.lower():
try: await bot(GetParticipantRequest(MY_CHANNEL_USER, u_id))
except UserNotParticipantError:
try: await event.delete()
except: pass
btn = [[Button.url("Channel Link 🖇️", MY_CHANNEL_LINK)]]
m = await event.respond(f"✴️~{mention}\n\n⚠️~ Message karne ke liye\nPele channel join kare 👇", buttons=btn)
MY_JOIN_STACK.append(m.id)
while len(MY_JOIN_STACK) > 3:
old_id = MY_JOIN_STACK.pop(0)
try: await bot.delete_messages(event.chat_id, old_id)
except: pass
return
my_promo_counter += 1
# --- 100 Subscribe Wala Message ---
if my_promo_counter % 10 == 5:
btn = [[Button.url("100 Subscribe", PROMO_URL_MY_GRP)]]
m = await event.reply(f"{mention}\nDaily Free 100 subscribe 100% real active ( non drop) Subscribe Pane ke liye click kare 👇", buttons=btn)
global_sub_promo_count += 1
if global_sub_promo_count % 4 == 0:
selected_agent = REPLY_AGENTS[sub_agent_idx]
custom_text = SUB_MESSAGES.get(selected_agent, "Nice trick bhai!")
asyncio.create_task(agent_reply_to_promo(selected_agent, event.chat_id, m.id, custom_text))
sub_agent_idx = (sub_agent_idx + 1) % len(REPLY_AGENTS)
# --- Paise Kamaye Wala Message ---
elif my_promo_counter % 10 == 0:
btn_watch = [[Button.url("Paise kamaye", "https://t.me/WatchEarn178_bot")]]
m = await event.reply(f"{mention}\nDin ke 100₹ kamaye photo dekh ke\n100% real he per refer 3₹", buttons=btn_watch)
global_money_promo_count += 1
if global_money_promo_count % 4 == 0:
selected_agent = REPLY_AGENTS[money_agent_idx]
custom_text = MONEY_MESSAGES.get(selected_agent, "Mujhe paise mil gaye, thanks!")
asyncio.create_task(agent_reply_to_promo(selected_agent, event.chat_id, m.id, custom_text))
money_agent_idx = (money_agent_idx + 1) % len(REPLY_AGENTS)
return
return bot
except: return None
# --- WATCH EARN BOT LOGIC ---
async def start_watch_earn_bot():
try:
we_bot = TelegramClient('watch_earn_bot', API_ID, API_HASH)
await we_bot.start(bot_token=WATCH_EARN_BOT_TOKEN)
print("🎮 WATCH EARN BOT STARTED")
@we_bot.on(events.NewMessage(pattern='/start', incoming=True, func=lambda e: e.is_private))
async def start_handler(event):
btn = [[Button.url("Play ▶️", "https://www.vibzon.shop/p/insta.html")]]
await event.respond("Paise kamane ke liye click kare👇", buttons=btn)
return we_bot
except Exception as e:
print(f"❌ Watch Earn Bot Error: {e}")
return None
# --- YOUTUBE SUB BOT LOGIC ---
async def start_youtube_sub_bot():
try:
ys_bot = TelegramClient('youtube_sub_bot', API_ID, API_HASH)
await ys_bot.start(bot_token=YOUTUBE_SUB_BOT_TOKEN)
print("🎁 YOUTUBE SUB BOT STARTED")
@ys_bot.on(events.NewMessage(incoming=True, func=lambda e: e.is_private))
async def ys_handler(event):
btn = [[Button.url("100 Subscribe", "https://www.vibzon.shop/p/trial-1.html")]]
await event.respond("daily 100 subscribe pane \nke liye click kre👇", buttons=btn)
return ys_bot
except Exception as e:
print(f"❌ YouTube Sub Bot Error: {e}")
return None
async def main():
print("🚦 SYSTEM STARTING...")
tasks = []
for n in AGENTS:
c = await start_agent(n)
if c: tasks.append(c.run_until_disconnected())
b = await start_baymax()
if b: tasks.append(b.run_until_disconnected())
w = await start_watch_earn_bot()
if w: tasks.append(w.run_until_disconnected())
y = await start_youtube_sub_bot()
if y: tasks.append(y.run_until_disconnected())
await asyncio.gather(*tasks)
if __name__ == '__main__':
asyncio.run(main())
Comments
Post a Comment