add mtproto configs from test server

This commit is contained in:
Il'ya (Marshal) 2022-05-10 20:12:27 +02:00
parent 593c3bbbb4
commit 55d5bbe0f0
2 changed files with 23 additions and 20 deletions

View file

@ -348,29 +348,32 @@ async def collect_translations_paginated_content(url: str, session: aiohttp.Clie
async def track_mtproto_configs(): async def track_mtproto_configs():
import json
from pyrogram import Client from pyrogram import Client
app = Client('crawler', session_string=os.environ['TELEGRAM_SESSION'])
app_test = Client('crawler_test', session_string=os.environ['TELEGRAM_SESSION_TEST'], test_mode=True)
await app.start()
await app_test.start()
await _fetch_and_track_mtproto(app, '')
await _fetch_and_track_mtproto(app_test, 'test')
async def _fetch_and_track_mtproto(app, output_dir):
from pyrogram.raw import functions from pyrogram.raw import functions
from pyrogram.raw.types import InputStickerSetAnimatedEmoji from pyrogram.raw.types import InputStickerSetAnimatedEmoji
app = Client(
os.environ['TELEGRAM_SESSION'],
api_id=int(os.environ['TELEGRAM_API_ID']),
api_hash=os.environ['TELEGRAM_API_HASH'],
)
await app.start()
configs = { configs = {
'GetConfig': await app.send(functions.help.GetConfig()), 'GetConfig': await app.invoke(functions.help.GetConfig()),
'GetCdnConfig': await app.send(functions.help.GetCdnConfig()), 'GetCdnConfig': await app.invoke(functions.help.GetCdnConfig()),
# 'GetInviteText': await app.send(functions.help.GetInviteText()), # 'GetInviteText': await app.invoke(functions.help.GetInviteText()),
# 'GetSupport': await app.send(functions.help.GetSupport()), # 'GetSupport': await app.invoke(functions.help.GetSupport()),
# 'GetSupportName': await app.send(functions.help.GetSupportName()), # 'GetSupportName': await app.invoke(functions.help.GetSupportName()),
# 'GetPassportConfig': await app.send(functions.help.GetPassportConfig(hash=0)), # 'GetPassportConfig': await app.invoke(functions.help.GetPassportConfig(hash=0)),
'GetCountriesList': await app.send(functions.help.GetCountriesList(lang_code='en', hash=0)), 'GetCountriesList': await app.invoke(functions.help.GetCountriesList(lang_code='en', hash=0)),
'GetAppConfig': await app.send(functions.help.GetAppConfig()), 'GetAppConfig': await app.invoke(functions.help.GetAppConfig()),
# 'GetAppUpdate': await app.send(functions.help.GetAppUpdate(source='')), # 'GetAppUpdate': await app.invoke(functions.help.GetAppUpdate(source='')),
'AnimatedEmoji': await app.send( 'AnimatedEmoji': await app.invoke(
functions.messages.GetStickerSet(stickerset=InputStickerSetAnimatedEmoji(), hash=0) functions.messages.GetStickerSet(stickerset=InputStickerSetAnimatedEmoji(), hash=0)
), ),
} }
@ -401,7 +404,7 @@ async def track_mtproto_configs():
configs['GetConfig'].expires = 0 configs['GetConfig'].expires = 0
configs['GetConfig'].dc_options = [] configs['GetConfig'].dc_options = []
output_dir_name = 'telegram-mtproto' output_dir_name = os.path.join('telegram-mtproto', output_dir)
for file, content in configs.items(): for file, content in configs.items():
filename = os.path.join(OUTPUT_FOLDER, output_dir_name, f'{file}.json') filename = os.path.join(OUTPUT_FOLDER, output_dir_name, f'{file}.json')
os.makedirs(os.path.dirname(filename), exist_ok=True) os.makedirs(os.path.dirname(filename), exist_ok=True)

View file

@ -1,5 +1,5 @@
aiohttp==3.7.4.post0 aiohttp==3.7.4.post0
aiodns==3.0.0 aiodns==3.0.0
aiofiles==0.6.0 aiofiles==0.6.0
Pyrogram==1.4.16 Pyrogram==2.0.19
# uvloop==0.16.0 # uvloop==0.16.0