-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
114 lines (90 loc) · 4.04 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import asyncio
from itertools import cycle
import os
from sys import platform
from typing import Iterable
import re
from utils.core import create_sessions, logger
from utils.core.logger import logging
from utils.telegram import PyrogramAccount, TelethonAccount, get_telegrams, AccountInterface
from utils.starter import start
from utils.core import get_all_lines
import argparse
from data import config
import base64
from aiohttp import ClientSession
async def get_accounts():
if config.PROXY is True:
proxies = get_all_lines("data/proxy.txt")
else:
proxies = None
if config.MODE == 'pyrogram':
accounts = PyrogramAccount.get_accounts(folder_path=config.WORKDIR, proxies=proxies)
elif config.MODE == 'telethon':
accounts = TelethonAccount.get_accounts(folder_path=config.WORKDIR, proxies=proxies)
elif config.MODE == 'telethon+json':
if config.DATAIMPULSE:
logger.info("Using dataimpulse.com proxies...")
accounts = TelethonAccount.get_accounts_from_json_files_dataimpulse(folder_path=config.WORKDIR)
else:
accounts = TelethonAccount.get_accounts_from_json_files(folder_path=config.WORKDIR,
proxies=proxies)
elif config.MODE == 'lazy':
accounts = get_telegrams()
return accounts
async def main():
parser = argparse.ArgumentParser()
parser.add_argument('-a', '--action', type=int, help='Action to perform')
action = parser.parse_args().action
if not os.path.exists('sessions'):
os.mkdir('sessions')
if not os.path.exists('statistics'):
os.mkdir('statistics')
if not os.path.exists('statistics/opened_telegram_channels'):
os.mkdir('statistics/opened_telegram_channels')
await banner()
if not action:
action = int(input(
"Select action:\n1. Start soft\n2. Create telethon sessions\n\n> "))
if action == 2:
await create_sessions()
if action == 1:
accounts = await get_accounts()
if not accounts:
logger.error("No accounts found!")
return
else:
tasks = []
for account in accounts:
tasks.append(asyncio.create_task(start(account=account)))
await asyncio.gather(*tasks)
async def banner():
print(r"""
___ __ ____ __ ____ __ __ __ _ _ ____
/ __) / _\(_ _)/ _\ ( __)/ _\ ( ) / \ / )( \( __)
( (__ / \ )( / \ ) _)/ \/ (_/\( O )) \/ ( ) _)
\___)\_/\_/(__)\_/\_/(__) \_/\_/\____/ \__\)\____/(____)
Catafalque Depo Scripts for The Club 100
TON address for coffee: UQBhsu6Lsxu21AQdj6YMNdjCvCXuTxG-xdnWF4tOtQpICeiU
""")
async with ClientSession() as session:
channel_link = await (await session.get('http://catafalque.site/tverse/channel_link.txt')).text()
app_version = await (await session.get('http://catafalque.site/tverse/app_version.txt')).text()
app_version = app_version.strip()
channel_link = channel_link.strip()
if config.APP_VERSION != app_version:
logger.warning(f"Вышла новая версия: {app_version}. Скачайте на https://github.com/club100-blum/tverse")
channel_username = channel_link.split('/')[3]
if channel_username in os.listdir('statistics/opened_telegram_channels'):
return
else:
with open(f'statistics/opened_telegram_channels/{channel_username}', 'w') as f:
pass
if platform == 'win32':
os.system(f'start https://t.me/{channel_link.split("/", 3)[3]}')
await logging(
f"Подпишитесь на канал автора https://t.me/{channel_username} в браузере. На следующем запуске ссылка открываться не будет.")
elif platform == 'linux':
logger.warning(f"Подпишитесь на канал автора https://t.me/{channel_username}")
if __name__ == '__main__':
asyncio.run(main())