from pyrogram import Client
import asyncio
import time
API_ID = 20336506
API_HASH = '53df51966cc63f31020bb504ab7fe446'
async def clone_channel(source_channel_ids: list, target_chanel_id: int):
client = Client(name='client', api_id=API_ID, api_hash=API_HASH)
await client.start()
try:
replace_list = [('https://telegram.me/joinchat/AAAAAEfPbzByz7MhJXcSAA', '@buzzboxnews'),('Qo\'qonliklar','BuzzBox'),('t.me/UFCuz_official','@buzzboxnews')]
for source_channel_id in source_channel_ids:
try:
messages = client.get_chat_history(chat_id=source_channel_id, limit=1)
async for message in messages:
if message.caption:
for old, new in replace_list:
message.caption = message.caption.replace(old, new)
await message.copy(chat_id=target_channel_id, caption=message.caption)
time.sleep(3) # Pause for 1 second
except Exception as e:
print(f"An error occurred: {e}")
print(traceback.format_exc())
finally:
await client.stop()
if __name__ == '__main__':
source_channel_ids = [-1001204776752, -1001456172102] # Add more source channel IDs to this list
target_channel_id = -1002036926923
asyncio.run(clone_channel(source_channel_ids=source_channel_ids, target_chanel_id=target_channel_id))