From 3bba63ba03aa28e74a1a489e9b115ebc0a45be68 Mon Sep 17 00:00:00 2001 From: augustin64 Date: Thu, 17 Feb 2022 12:12:29 +0100 Subject: [PATCH 1/2] Switch to Discord Embeds --- V4.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/V4.py b/V4.py index f405b17..87a6105 100644 --- a/V4.py +++ b/V4.py @@ -8,7 +8,7 @@ import discord import asyncio from sys import platform from csv import reader -from discord import Webhook, RequestsWebhookAdapter # Importing discord.Webhook and discord.RequestsWebhookAdapter +from discord import Webhook, RequestsWebhookAdapter, Embed, Colour # Importing discord.Webhook and discord.RequestsWebhookAdapter from selenium import webdriver from selenium.webdriver.firefox.options import Options @@ -141,13 +141,17 @@ def LogError(message,log = Log, Mobdriver = None): gdriver.save_screenshot("screenshot.png") - webhookFailure.send(content="------------------------------------\n" + _mail) - webhookFailure.send(ListTabs(Mdriver=Mobdriver)) - webhookFailure.send(str(message)) - CustomSleep(1) - webhookFailure.send(file=discord.File('screenshot.png')) + embed = discord.Embed( + title="An Error has occured", + description=str(message), + url = ListTabs(Mdriver=Mobdriver)[0], + colour = Colour.red() + ) + 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')) - webhookFailure.send("------------------------------------") def progressBar(current, total=30, barLength = 20, name ="Progress"): @@ -656,8 +660,12 @@ def LogPoint(account="unknown"): #log des points sur discord account = account.split('@')[0] - - webhookSuccess.send(f'{account} actuellement à {str(point)} points') + embed = discord.Embed( + title=f"{account} actuellement à {str(point)} points", + colour = Colour.green() + ) + embed.set_footer(text=_mail) + webhookSuccess.send(embed=embed) From 0e5bc99779e438362e04d23813c1e5cc7440ca4b Mon Sep 17 00:00:00 2001 From: augustin64 Date: Thu, 17 Feb 2022 12:19:47 +0100 Subject: [PATCH 2/2] Sort imports --- V4.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/V4.py b/V4.py index 87a6105..1e67ca1 100644 --- a/V4.py +++ b/V4.py @@ -1,22 +1,23 @@ #!/usr/bin/python3 -import os -from time import sleep -from random import uniform, choice, randint,shuffle -from re import search,findall -from os import path, sys, system -import discord import asyncio +import os +from csv import reader +from os import path, sys, system +from random import choice, randint, shuffle, uniform +from re import findall, search from sys import platform -from csv import reader -from discord import Webhook, RequestsWebhookAdapter, Embed, Colour # Importing discord.Webhook and discord.RequestsWebhookAdapter +from time import sleep +import discord +from discord import ( # Importing discord.Webhook and discord.RequestsWebhookAdapter + Colour, Embed, RequestsWebhookAdapter, Webhook) from selenium import webdriver -from selenium.webdriver.firefox.options import Options -from selenium.webdriver.common.keys import Keys -from selenium.webdriver.common.by import By -from selenium.webdriver.support.ui import WebDriverWait -from selenium.webdriver.support import expected_conditions as EC from selenium.common import exceptions +from selenium.webdriver.common.by import By +from selenium.webdriver.common.keys import Keys +from selenium.webdriver.firefox.options import Options +from selenium.webdriver.support import expected_conditions as EC +from selenium.webdriver.support.ui import WebDriverWait main = True Headless = True