2022-10-24 20:08:33 +02:00
|
|
|
from time import sleep
|
2022-10-25 09:48:34 +02:00
|
|
|
from datetime import timedelta
|
2022-10-24 20:08:33 +02:00
|
|
|
from random import uniform
|
|
|
|
import discord
|
|
|
|
from discord import ( # Importing discord.Webhook and discord.RequestsWebhookAdapter
|
|
|
|
Colour,
|
|
|
|
Webhook,
|
|
|
|
)
|
|
|
|
|
|
|
|
from modules.config import *
|
2022-10-25 10:03:24 +02:00
|
|
|
|
2022-10-24 20:08:33 +02:00
|
|
|
"""
|
|
|
|
send_keys_wait([selenium element:element, str:keys]) send the different keys to the field element, with a random time between each press to simulate human action.
|
|
|
|
keys can be an string, but alos selenium keys
|
|
|
|
"""
|
|
|
|
def send_keys_wait(element, keys):
|
|
|
|
for i in keys:
|
|
|
|
element.send_keys(i)
|
|
|
|
if FAST :
|
|
|
|
pass
|
|
|
|
else :
|
|
|
|
sleep(uniform(0.1, 0.3))
|
|
|
|
|
2022-10-25 10:03:24 +02:00
|
|
|
|
2022-10-25 19:27:54 +02:00
|
|
|
def LogError(message, driver, mail, log=FULL_LOG):
|
2022-10-24 20:08:33 +02:00
|
|
|
print(f"\n\n\033[93m Erreur : {str(message)} \033[0m\n\n")
|
|
|
|
if DISCORD_ENABLED_ERROR:
|
|
|
|
with open("page.html", "w") as f:
|
2022-10-25 19:27:54 +02:00
|
|
|
f.write(driver.page_source)
|
2022-10-24 20:08:33 +02:00
|
|
|
|
2022-10-25 19:27:54 +02:00
|
|
|
driver.save_screenshot("screenshot.png")
|
2022-10-24 20:08:33 +02:00
|
|
|
if not log:
|
|
|
|
embed = discord.Embed(
|
|
|
|
title="An Error has occured",
|
|
|
|
description=str(message),
|
|
|
|
colour=Colour.red(),
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
embed = discord.Embed(
|
|
|
|
title="Full log is enabled",
|
|
|
|
description=str(message),
|
|
|
|
colour=Colour.blue(),
|
|
|
|
)
|
|
|
|
|
|
|
|
file = discord.File("screenshot.png")
|
|
|
|
embed.set_image(url="attachment://screenshot.png")
|
2022-10-30 12:12:00 +01:00
|
|
|
embed.set_footer(text=mail)
|
2022-10-24 20:08:33 +02:00
|
|
|
webhookFailure.send(embed=embed, file=file)
|
|
|
|
webhookFailure.send(file=discord.File("page.html"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# add the time arround the text given in [text]
|
|
|
|
# [text] : string
|
2022-10-25 19:47:05 +02:00
|
|
|
def Timer(text, mail):
|
|
|
|
return(f"[{mail} - {timedelta(seconds = round(float(time() - START_TIME)))}] " + str(text))
|
2022-10-24 20:08:33 +02:00
|
|
|
|
|
|
|
|
|
|
|
# replace the function print, with more options
|
|
|
|
# [txt] : string, [driver] : selenium wbdriver
|
2022-10-25 19:44:33 +02:00
|
|
|
def printf2(txt, mail, LOG = LOG):
|
2022-10-24 20:08:33 +02:00
|
|
|
if LOG:
|
2022-10-25 19:44:33 +02:00
|
|
|
print(Timer(txt, mail))
|
2022-10-24 20:08:33 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# check if the user is using IPV4 using ipify.org
|
|
|
|
# [driver] : selenium webdriver
|
|
|
|
|
|
|
|
def check_ipv4(driver):
|
|
|
|
driver.get("https://api64.ipify.org")
|
|
|
|
elm = driver.find_element(By.TAG_NAME, "body")
|
|
|
|
if len(elm.text.split('.')) == 4 :
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
2022-10-25 19:44:33 +02:00
|
|
|
|
|
|
|
def CustomSleep(temps):
|
|
|
|
try :
|
|
|
|
if FAST and temps > 50:
|
|
|
|
sleep(temps/10)
|
|
|
|
return()
|
|
|
|
if not LOG or not LINUX_HOST: #only print sleep when user see it
|
|
|
|
points = ["⢿", "⣻", "⣽", "⣾", "⣷", "⣯", "⣟", "⡿"]
|
|
|
|
passe = 0
|
|
|
|
for i in range(int(temps)):
|
|
|
|
for i in range(8):
|
|
|
|
sleep(0.125)
|
|
|
|
passe += 0.125
|
|
|
|
print(f"{points[i]} - {round(float(temps) - passe, 3)}", end="\r")
|
|
|
|
print(" ", end="\r")
|
|
|
|
else:
|
|
|
|
sleep(temps)
|
|
|
|
except KeyboardInterrupt :
|
2022-11-06 13:37:12 +01:00
|
|
|
print("attente annulée")
|
2022-10-25 19:44:33 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def progressBar(current, total=30, barLength=20, name="Progress"):
|
|
|
|
percent = float(current + 1) * 100 / total
|
|
|
|
arrow = "-" * int(percent / 100 * barLength - 1) + ">"
|
|
|
|
spaces = " " * (barLength - len(arrow))
|
|
|
|
print(name + ": [%s%s] %d %%" % (arrow, spaces, percent), end="\r")
|