changed from discord bot to webhook

This commit is contained in:
piair 2022-02-15 22:40:39 +01:00
parent c98e54153a
commit 025aa68173
1 changed files with 39 additions and 54 deletions

89
V4.py
View File

@ -21,18 +21,34 @@ main = True
Headless = True Headless = True
Log = False Log = False
def printf(txt):
if not Log :
print(txt)
else :
CustomSleep(5)
LogError(txt)
IsLinux = platform == "linux" IsLinux = platform == "linux"
print("Linux : "+ str(IsLinux)) print("Linux : "+ str(IsLinux))
if IsLinux :
MotPath = "/home/pi/MsReward/liste.txt"
LogPath= "/home/pi/MsReward/login.csv"
WebHookPath = "/home/pi/MsReward/webhook.txt"
else :
MotPath = resource_path('D:\Documents\Dev\MsReward\liste/liste.txt')
LogPath = resource_path('D:\Documents\Dev\MsReward\login/login.csv')
WebHookPath = resource_path('D:\Documents\Dev\MsReward/token/webhook.txt')
system("")
g = open(MotPath, "r" , encoding="utf-8")
Liste_de_mot=(list(g.readline().split(',')))
g.close()
g = open(WebHookPath,"r")
SuccesLink, ErrorLink = g.readline().split(',')
g.close
def resource_path(relative_path): #permet de recuperer l'emplacement de chaque fichier, su linux et windows def resource_path(relative_path): #permet de recuperer l'emplacement de chaque fichier, su linux et windows
try: try:
base_path = sys._MEIPASS base_path = sys._MEIPASS
@ -68,25 +84,15 @@ def FirefoxPC(Headless = Headless):
return(webdriver.Firefox(options=options)) return(webdriver.Firefox(options=options))
if IsLinux :
MotPath = "/home/pi/MsReward/liste.txt"
LogPath= "/home/pi/MsReward/login.csv"
TokenPath = "/home/pi/MsReward/token.txt"
else :
MotPath = resource_path('D:\Documents\Dev\MsReward\liste/liste.txt')
LogPath = resource_path('D:\Documents\Dev\MsReward\login/login.csv')
TokenPath = resource_path('D:\Documents\Dev\MsReward/token/token.txt')
system("")
def printf(txt):
if not Log :
print(txt)
else :
CustomSleep(5)
LogError(txt)
g = open(MotPath, "r" , encoding="utf-8")
Liste_de_mot=(list(g.readline().split(',')))
g.close()
g = open(TokenPath,"r")
Token = g.readline()
g.close
def CustomSleep(temps): def CustomSleep(temps):
if Log or not IsLinux : if Log or not IsLinux :
@ -126,35 +132,21 @@ def LogError(message,log = Log, Mobdriver = None):
gdriver = driver gdriver = driver
if not IsLinux : if not IsLinux :
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
print(f'\033[93m Erreur : {str(message)} \033[0m') print(f'\033[93m Erreur : {str(message)} \033[0m')
else : else :
with open('page.html', 'w') as f: with open('page.html', 'w') as f:
f.write(gdriver.page_source) f.write(gdriver.page_source)
gdriver.save_screenshot("screenshot.png") gdriver.save_screenshot("screenshot.png")
asyncio.set_event_loop(asyncio.new_event_loop())
client = discord.Client() webhook = Webhook.from_url(ErrorLink, adapter=RequestsWebhookAdapter()) # Initializing webhook
@client.event webhook.send(content="------------------------------------\n" + _mail)
async def on_ready(): webhook.send(ListTabs(Mdriver=Mobdriver))
channel = client.get_channel(861181899987484692) webhook.send(str(message))
if log :
channel = client.get_channel(833275838837030912) #channel de log
await channel.send("------------------------------------\n" + _mail)
await channel.send(ListTabs(Mdriver=Mobdriver))
await channel.send(str(message))
CustomSleep(1) CustomSleep(1)
await channel.send(file=discord.File('screenshot.png')) webhook.send(file=discord.File('screenshot.png'))
await channel.send(file=discord.File('page.html')) webhook.send(file=discord.File('page.html'))
await channel.send("------------------------------------") webhook.send("------------------------------------")
await client.close()
client.run(Token)
def progressBar(current, total=30, barLength = 20, name ="Progress"): def progressBar(current, total=30, barLength = 20, name ="Progress"):
@ -663,18 +655,11 @@ def LogPoint(account="unknown"): #log des points sur discord
CustomSleep(uniform(3,20)) CustomSleep(uniform(3,20))
account = account.split('@')[0] account = account.split('@')[0]
client = discord.Client()
@client.event
async def on_ready():
channel = client.get_channel(841338253625917450)
await channel.send(f'{account} actuellement à {str(point)} points') webhook = Webhook.from_url(ErrorLink, adapter=RequestsWebhookAdapter())
CustomSleep(1) webhook.send(f'{account} actuellement à {str(point)} points')
await client.close()
client.run(Token)
def Fidelité(): def Fidelité():
try : try :