├── README.md ├── start.bat ├── work.py └── Мануал по работе со скриптом.docx /README.md: -------------------------------------------------------------------------------- 1 | # TG-user-in-chat-parser 2 | Парсер участников ТГ чатов 3 | -------------------------------------------------------------------------------- /start.bat: -------------------------------------------------------------------------------- 1 | python work.py 2 | pause -------------------------------------------------------------------------------- /work.py: -------------------------------------------------------------------------------- 1 | from signal import raise_signal 2 | from telethon import TelegramClient, events 3 | from telethon.sync import TelegramClient 4 | from telethon.tl.functions.messages import GetDialogsRequest 5 | from telethon.tl.types import InputPeerEmpty 6 | import os, sys 7 | import configparser 8 | import csv 9 | import time 10 | import asyncio 11 | import pandas as pd 12 | ############################################### 13 | api_id = '********' # 14 | api_hash = '********************************' # 15 | phone = '**********' # 16 | ############################################### 17 | client = TelegramClient('session_name', api_id, api_hash) 18 | client.connect() 19 | if not client.is_user_authorized(): 20 | client.send_code_request(phone) 21 | os.system('cls') 22 | client.sign_in(phone, input('[+] Введите код: ')) 23 | os.system('cls') 24 | 25 | chats = [] 26 | last_date = None 27 | chunk_size = 200 28 | groups=[] 29 | 30 | result = client(GetDialogsRequest( 31 | offset_date=last_date, 32 | offset_id=0, 33 | offset_peer=InputPeerEmpty(), 34 | limit=chunk_size, 35 | hash = 0 36 | )) 37 | chats.extend(result.chats) 38 | 39 | for chat in chats: 40 | try: 41 | if chat.megagroup== True: 42 | groups.append(chat) 43 | except: 44 | continue 45 | 46 | print('[+] Выберите групу для парсинга участников :') 47 | i=0 48 | for g in groups: 49 | print('['+str(i)+']'+' - '+ g.title) 50 | i+=1 51 | 52 | print('') 53 | g_index = input("[+] Введите номер : ") 54 | target_group=groups[int(g_index)] 55 | chat = target_group.id 56 | # Айди чата вставлять без кавычек 57 | df = pd.DataFrame(columns=['Users']) 58 | lst = [] 59 | async def main(): 60 | async with client: 61 | async for user in client.iter_participants(chat): 62 | lst.append(str(user.id) + ' @' + str(user.username)) 63 | print(user.id) 64 | loop = asyncio.get_event_loop() 65 | loop.run_until_complete(main()) 66 | df['Users'] = lst 67 | df.to_csv('Users.csv') 68 | for i in lst: 69 | with open('logs.txt','a') as file: 70 | file.write(i + '\n') -------------------------------------------------------------------------------- /Мануал по работе со скриптом.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Foxius/TG-user-in-chat-parser/26f6a59bd5bbfdd2404ad3453c6a73793b2222aa/Мануал по работе со скриптом.docx --------------------------------------------------------------------------------