-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
69 lines (50 loc) · 2.02 KB
/
utils.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
import random
import time
import requests
from loguru import logger
from openpyxl import Workbook
from tqdm import tqdm
from config import USE_MOBILE_PROXY, IP_CHANGE_LINK
def read_from_txt(file_path):
try:
with open(file_path, "r") as file:
return [line.strip() for line in file]
except Exception as e:
raise Exception(f"Encountered an error while reading a txt file '{file_path}': {str(e)}")
def export_json(data, destination):
try:
workbook = Workbook()
sheet = workbook.active
headers = ["Address", "Scroll Marks"]
sheet.append(headers)
for key, value in data.items():
sheet.append([key, value])
workbook.save(destination)
except Exception as e:
logger.error(f"Encountered an error while exporting db to Excel: {str(e)}")
exit()
def change_mobile_ip() -> None:
try:
if USE_MOBILE_PROXY:
res = requests.get(IP_CHANGE_LINK)
if res.status_code == 200:
logger.info("IP address changed successfully", send_to_tg=False)
else:
raise Exception("Failed to change IP address")
except Exception as e:
raise Exception(f"Encountered an error when changing ip address, check your proxy provider: {e}")
def sleep(delay_range):
random_delay = random.randint(*delay_range)
with tqdm(total=random_delay, desc="Waiting", unit="s", dynamic_ncols=True, colour="blue") as pbar:
for _ in range(random_delay):
time.sleep(1)
pbar.update(1)
def print_greeting_msg():
start_message = r"""
__ _ __ __
_______ __/ /_ (_) / _ __ ____ ____ _/ /______ ____ ___
/ ___/ / / / __ \/ / / | | / / /_ / / __ `/ //_/ __ \/ __ \/ _ \
(__ ) /_/ / /_/ / / / | |/ / / /_/ /_/ / ,< / /_/ / / / / __/
/____/\__, /_.___/_/_/ |___/ /___/\__,_/_/|_|\____/_/ /_/\___/
/____/ """
logger.success(start_message)