mirror of
https://gitea.augustin64.fr/piair/MsRewards-Reborn.git
synced 2025-08-09 15:06:36 +02:00
oh boy i probably just broke everything
This commit is contained in:
77
modules/tools.py
Normal file
77
modules/tools.py
Normal file
@ -0,0 +1,77 @@
|
||||
from time import sleep
|
||||
from random import uniform
|
||||
import discord
|
||||
from discord import ( # Importing discord.Webhook and discord.RequestsWebhookAdapter
|
||||
Colour,
|
||||
Webhook,
|
||||
)
|
||||
|
||||
from modules.config import *
|
||||
|
||||
"""
|
||||
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))
|
||||
|
||||
def LogError(message, driver, log=FULL_LOG):
|
||||
print(f"\n\n\033[93m Erreur : {str(message)} \033[0m\n\n")
|
||||
if DISCORD_ENABLED_ERROR:
|
||||
with open("page.html", "w") as f:
|
||||
f.write(gdriver.page_source)
|
||||
|
||||
gdriver.save_screenshot("screenshot.png")
|
||||
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")
|
||||
embed.set_footer(text=_mail)
|
||||
webhookFailure.send(embed=embed, file=file)
|
||||
webhookFailure.send(file=discord.File("page.html"))
|
||||
|
||||
|
||||
|
||||
|
||||
# add the time arround the text given in [text]
|
||||
# [text] : string
|
||||
def Timer(text="undefined"):
|
||||
return(f"[{_mail} - {timedelta(seconds = round(float(time() - START_TIME)))}] " + str(text))
|
||||
|
||||
|
||||
# replace the function print, with more options
|
||||
# [txt] : string, [driver] : selenium wbdriver
|
||||
def printf(txt, LOG = False):
|
||||
if LOG:
|
||||
print(Timer(txt))
|
||||
|
||||
|
||||
|
||||
|
||||
# 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
|
||||
|
||||
|
Reference in New Issue
Block a user