forked from HiddenCodeDevs/BlumTelegramBot
-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
37 lines (31 loc) · 1.12 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
import asyncio
from contextlib import suppress
from bot.core.launcher import process
from bot.utils import PROXY_CHAIN, logger
from bot.utils.proxy_utils import get_proxy_chain, check_proxy
from os import system, name as os_name
def set_window_title(title):
if os_name == 'nt':
system(f'title {title}')
else:
print(f'\033]0;{title}\007', end='', flush=True)
async def main():
if PROXY_CHAIN:
proxy_str, proxy = await get_proxy_chain(PROXY_CHAIN)
if proxy:
logger.info("Getting proxy for Proxy Chain")
if await check_proxy(proxy_str):
import socket, socks
socks.set_default_proxy(proxy)
socket.socket = socks.socksocket
else:
logger.error("Proxy chain didn't respond. Can't start the bot using proxy chain")
input('Press any key to exit: ')
exit(0)
else:
logger.warning("No valid proxy found. Skipping")
await process()
if __name__ == '__main__':
set_window_title('Blum')
with suppress(KeyboardInterrupt):
asyncio.run(main())