From 11c8a1bd57ed843dc216e344157dd057d2c89a32 Mon Sep 17 00:00:00 2001 From: JSDio Date: Tue, 15 Feb 2022 18:31:07 +0000 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B0=20=D1=81=D1=82=D1=80=D1=83=D0=BA=D1=82=D1=83=D1=80=D0=B0?= =?UTF-8?q?=20=D0=B8=D0=B7-=D0=B7=D0=B0=20=D0=BE=D0=B3=D1=80=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D1=87=D0=B5=D0=BD=D0=B8=D0=B9=20=D1=82=D0=B5=D0=BB=D0=B5?= =?UTF-8?q?=D0=B3=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/main.py | 121 +++++++++++++++++++++++++-------------------------- 1 file changed, 59 insertions(+), 62 deletions(-) diff --git a/data/main.py b/data/main.py index d8b75f0..c489832 100644 --- a/data/main.py +++ b/data/main.py @@ -1,7 +1,6 @@ import json from xlwt import Workbook import xlwt -import config import os import asyncio from my_functions import * @@ -12,48 +11,56 @@ api_hash = config.api_hash session = 'session.session' loop = asyncio.get_event_loop() -try: - # Получаем чат пользователя, проверяем, что за ссылку он отправил и ожидаем правильной ссылки - while True: - link = input('Введите ссылку на чат: ') - # link = ('osint_flood') - res = check_link(link) - if not res: - print('Неверная ссылка. Попробуйте другую.') - elif res == 'url' or res == 'id': - if res == 'id': - res = loop.run_until_complete(check_chat(link, 'id')) - else: - res = loop.run_until_complete(check_chat(link, 'url')) - if res is not False: - members = res[0] - admins = res[1] - chat = res[2] - users = res[3] - channel_type = res[4] - channel_title = res[5] - break - elif res == 'close': - chat = loop.run_until_complete(inv_chat(link)) - res = loop.run_until_complete(check_chat(chat, 'url')) - if res is not False: - members = res[0] - admins = res[1] - chat = res[2] - users = res[3] - channel_type = 'Чаты' - channel_title = chat.title - break - title = channel_title - for x in ['\\', '|', '"', '/', ':', - '?', '*', '<', '>']: - title = title.replace(x, ' ') - if os.path.exists(f'../Чаты') is False: - os.mkdir(f'../Чаты') - if os.path.exists(f'../Каналы') is False: - os.mkdir(f'../Каналы') - if os.path.exists(f'../{channel_type}/{title}') is False: - os.mkdir(f'../{channel_type}/{title}') +# Получаем чат пользователя, проверяем, что за ссылку он отправил и ожидаем правильной ссылки +while True: + link = input('Введите ссылку на чат: ') + res = check_link(link) + if not res: + print('Неверная ссылка. Попробуйте другую.') + elif res == 'url' or res == 'id': + if res == 'id': + res = loop.run_until_complete(check_chat(link, 'id')) + else: + res = loop.run_until_complete(check_chat(link, 'url')) + if res is not False and res['status'] == 'ok': + members = res['members'] + admins = res['admins'] + chat = res['ch'] + users = res['users'] + channel_type = res['channel_type'] + channel_title = res['channel_title'] + break + elif res is not False and res['status'] == 'error' and res['error_type'] == 'too_many_users': + chat = res['ch'] + channel_type = res['channel_type'] + channel_title = res['channel_title'] + break + elif res == 'close': + chat = loop.run_until_complete(inv_chat(link)) + res = loop.run_until_complete(check_chat(chat, 'url')) + if res is not False and res['status'] == 'ok': + members = res['members'] + admins = res['admins'] + chat = res['ch'] + users = res['users'] + channel_type = 'Чаты' + channel_title = chat.title + break + elif res is not False and res['status'] == 'error' and res['error_type'] == 'too_many_users': + chat = res['ch'] + channel_type = 'Чаты' + channel_title = chat.title + break +for x in ['\\', '|', '"', '/', ':', + '?', '*', '<', '>']: + title = channel_title.replace(x, ' ') +if os.path.exists(f'../Чаты') is False: + os.mkdir(f'../Чаты') +if os.path.exists(f'../Каналы') is False: + os.mkdir(f'../Каналы') +if os.path.exists(f'../{channel_type}/{title}') is False: + os.mkdir(f'../{channel_type}/{title}') +if res['status'] == 'ok': with open(f'../{channel_type}/{title}/Участники {title}.json', 'w', encoding='utf8') as f: with open(f'../{channel_type}/{title}/Участники {title}.txt', 'w', encoding='utf8') as file: all_users = { @@ -114,22 +121,12 @@ try: - while True: - otvet = input('''\nЖелаете ли вы сохранить историю сообщений? - 1 - да - 2 - нет ''') - if str(otvet) == '1' or str(otvet) == '2': - break - if str(otvet) == '1': - loop.run_until_complete(dump_messages(chat, title)) - input('\nСканирование закончено. Можете нажать "Enter", чтобы закрыть окно.') - -except Exception as e: - print(f'''Упс... Возникла ошибка -Текст ошибки: - -{e} - -Отправьте скриншот разработчику.''') - raise e - input('\nНажмите "Enter", чтобы закрыть окно.') +while True: + otvet = input('''\nЖелаете ли вы сохранить историю сообщений? +1 - да +2 - нет ''') + if str(otvet) == '1' or str(otvet) == '2': + break +if str(otvet) == '1': + loop.run_until_complete(dump_messages(chat, title)) +input('\nСканирование закончено. Можете нажать "Enter", чтобы закрыть окно.')