├── config.data ├── requirements.txt ├── channels.txt ├── README.md └── main.py /config.data: -------------------------------------------------------------------------------- 1 | [Peternish] 2 | version = 2.3 3 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | telethon 2 | configparser 3 | time 4 | -------------------------------------------------------------------------------- /channels.txt: -------------------------------------------------------------------------------- 1 | https://t.me/DarkTradeMarket 2 | https://t.me/badassmarketplace 3 | https://t.me/MarketplaceAIO 4 | https://t.me/discovermarket 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 💖  Auto Forward Tool 2 | 3 | 4 | # 🎆 How to setup 5 | - pip install -r requirements.txt 6 | - First, put your api hash id, id and your number in forward.py, here is a picture attached. 7 | - Then in channels.txt put the URLS https://t.me/lawoficial for example, 8 | here will go the urls of the channels where you want to autopublish, from factory I put that every 2 minutes autopublish, you can edit that! 9 | ![image](https://user-images.githubusercontent.com/116668706/230751359-ac920a33-91c6-4731-a9f2-4db55c0c5042.png) 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | # MADE BY Peternish on github. 2 | 3 | from telethon import TelegramClient, events 4 | from telethon.tl.functions.channels import JoinChannelRequest 5 | 6 | import time 7 | import os 8 | import configparser 9 | from colorama import Fore 10 | 11 | 12 | 13 | class Forwarder: 14 | def setup(): 15 | if os.path.exists("config.data"): 16 | acc = configparser.RawConfigParser() 17 | 18 | acc.add_section('cred') 19 | api_id = input(f"{Fore.LIGHTWHITE_EX}[+] Api ID : ") 20 | 21 | acc.set('cred', 'id', api_id) 22 | api_hash = input(f"{Fore.LIGHTWHITE_EX}[+] Api Hash ID : ") 23 | 24 | acc.set('cred', 'hash', api_hash) 25 | phone = input(f"{Fore.LIGHTGREEN_EX}[+] Phone Number (of acc) : ") 26 | 27 | acc.set('cred', 'phone', phone) 28 | setup = open('config.data', 'w') 29 | 30 | acc.write(setup) 31 | setup.close() 32 | 33 | def start(): 34 | file = configparser.RawConfigParser() 35 | file.read('config.data') 36 | api_id = file['cred']['id'] 37 | api_hash = file['cred']['hash'] 38 | phone = file['cred']['phone'] 39 | client = TelegramClient(phone, api_id, api_hash) 40 | client.start() 41 | ch1 = int(input("Channel ID: ")) 42 | id1 = int(input("ID MESSAGE: ")) 43 | async def get_message(): 44 | message = await client.get_messages(ch1, ids=id1) 45 | return message 46 | 47 | 48 | async def get_chat_id(group_link): 49 | entity = await client.get_entity(group_link) 50 | chat_id = entity.id 51 | return chat_id 52 | 53 | 54 | with open("channels.txt", "r") as f: 55 | lines = f.readlines() 56 | with open("channels_ids.txt", "w") as w: 57 | for i in lines: 58 | chat_id = client.loop.run_until_complete(get_chat_id(i.strip())) 59 | print(chat_id) 60 | w.write(str(chat_id) + "\n") 61 | 62 | 63 | async def forward_message(): 64 | while True: 65 | with open("channels_ids.txt", "r") as y: 66 | lines = y.readlines() 67 | for id_chat in lines: 68 | chat_id = int(id_chat.strip()) 69 | message = await get_message() 70 | try: 71 | await client.forward_messages(chat_id, message) 72 | except Exception as e: 73 | print(f"Error in the chat {chat_id}. Message: {e}") 74 | time.sleep(120) 75 | 76 | 77 | with client: 78 | client.loop.run_until_complete(forward_message()) 79 | def joingroup(): 80 | configf = configparser.RawConfigParser() 81 | configf.read('config.data') 82 | 83 | 84 | api_id = configf['cred']['id'] 85 | api_hash = configf['cred']['hash'] 86 | phone = configf['cred']['phone'] 87 | client = TelegramClient(phone, api_id, api_hash) 88 | async def join_group(group_link): 89 | entity = await client.get_entity(group_link) 90 | await client(JoinChannelRequest(entity)) 91 | 92 | with client: 93 | with open('channels.txt') as f: 94 | group_links = f.readlines() 95 | for link in group_links: 96 | link = link.strip() 97 | try: 98 | client.loop.run_until_complete(join_group(link)) 99 | print(f"{Fore.LIGHTGREEN_EX}Joined Succesfuly! {link}") 100 | except Exception as e: 101 | print(f"Fail to join {link}. \nError: {e}") 102 | 103 | forwarder = Forwarder 104 | print(f"{Fore.GREEN}―――― @Lawxsz Telegram Tool ――――――") 105 | print(f"\n{Fore.YELLOW}1: Setup Account\n2: Start Forwarding\n3: Join to Groups") 106 | enter = input("") 107 | if enter == "1": 108 | forwarder.setup() 109 | elif enter == "2": 110 | forwarder.start() 111 | elif enter == "3": 112 | forwarder.joingroup() 113 | else: 114 | print("ERROR, choice a valid option bro!") 115 | --------------------------------------------------------------------------------