Изменена структура из-за ограничений телеги

This commit is contained in:
Григорич 2022-02-15 18:31:07 +00:00
parent b4449eeda2
commit 11c8a1bd57

View File

@ -1,7 +1,6 @@
import json import json
from xlwt import Workbook from xlwt import Workbook
import xlwt import xlwt
import config
import os import os
import asyncio import asyncio
from my_functions import * from my_functions import *
@ -12,48 +11,56 @@ api_hash = config.api_hash
session = 'session.session' session = 'session.session'
loop = asyncio.get_event_loop() loop = asyncio.get_event_loop()
try: # Получаем чат пользователя, проверяем, что за ссылку он отправил и ожидаем правильной ссылки
# Получаем чат пользователя, проверяем, что за ссылку он отправил и ожидаем правильной ссылки while True:
while True: link = input('Введите ссылку на чат: ')
link = input('Введите ссылку на чат: ') res = check_link(link)
# link = ('osint_flood') if not res:
res = check_link(link) print('Неверная ссылка. Попробуйте другую.')
if not res: elif res == 'url' or res == 'id':
print('Неверная ссылка. Попробуйте другую.') if res == 'id':
elif res == 'url' or res == 'id': res = loop.run_until_complete(check_chat(link, 'id'))
if res == 'id': else:
res = loop.run_until_complete(check_chat(link, 'id')) res = loop.run_until_complete(check_chat(link, 'url'))
else: if res is not False and res['status'] == 'ok':
res = loop.run_until_complete(check_chat(link, 'url')) members = res['members']
if res is not False: admins = res['admins']
members = res[0] chat = res['ch']
admins = res[1] users = res['users']
chat = res[2] channel_type = res['channel_type']
users = res[3] channel_title = res['channel_title']
channel_type = res[4] break
channel_title = res[5] elif res is not False and res['status'] == 'error' and res['error_type'] == 'too_many_users':
break chat = res['ch']
elif res == 'close': channel_type = res['channel_type']
chat = loop.run_until_complete(inv_chat(link)) channel_title = res['channel_title']
res = loop.run_until_complete(check_chat(chat, 'url')) break
if res is not False: elif res == 'close':
members = res[0] chat = loop.run_until_complete(inv_chat(link))
admins = res[1] res = loop.run_until_complete(check_chat(chat, 'url'))
chat = res[2] if res is not False and res['status'] == 'ok':
users = res[3] members = res['members']
channel_type = 'Чаты' admins = res['admins']
channel_title = chat.title chat = res['ch']
break users = res['users']
title = channel_title channel_type = 'Чаты'
for x in ['\\', '|', '"', '/', ':', channel_title = chat.title
'?', '*', '<', '>']: break
title = title.replace(x, ' ') elif res is not False and res['status'] == 'error' and res['error_type'] == 'too_many_users':
if os.path.exists(f'../Чаты') is False: chat = res['ch']
os.mkdir(f'../Чаты') channel_type = 'Чаты'
if os.path.exists(f'../Каналы') is False: channel_title = chat.title
os.mkdir(f'../Каналы') break
if os.path.exists(f'../{channel_type}/{title}') is False: for x in ['\\', '|', '"', '/', ':',
os.mkdir(f'../{channel_type}/{title}') '?', '*', '<', '>']:
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}.json', 'w', encoding='utf8') as f:
with open(f'../{channel_type}/{title}/Участники {title}.txt', 'w', encoding='utf8') as file: with open(f'../{channel_type}/{title}/Участники {title}.txt', 'w', encoding='utf8') as file:
all_users = { all_users = {
@ -114,22 +121,12 @@ try:
while True: while True:
otvet = input('''\nЖелаете ли вы сохранить историю сообщений? otvet = input('''\nЖелаете ли вы сохранить историю сообщений?
1 - да 1 - да
2 - нет ''') 2 - нет ''')
if str(otvet) == '1' or str(otvet) == '2': if str(otvet) == '1' or str(otvet) == '2':
break break
if str(otvet) == '1': if str(otvet) == '1':
loop.run_until_complete(dump_messages(chat, title)) loop.run_until_complete(dump_messages(chat, title))
input('\nСканирование закончено. Можете нажать "Enter", чтобы закрыть окно.') input('\nСканирование закончено. Можете нажать "Enter", чтобы закрыть окно.')
except Exception as e:
print(f'''Упс... Возникла ошибка
Текст ошибки:
{e}
Отправьте скриншот разработчику.''')
raise e
input('\nНажмите "Enter", чтобы закрыть окно.')