Refacto
This commit is contained in:
@@ -3,7 +3,7 @@ import webbrowser
|
|||||||
import os
|
import os
|
||||||
from urllib.parse import urlencode
|
from urllib.parse import urlencode
|
||||||
from http.server import HTTPServer, BaseHTTPRequestHandler
|
from http.server import HTTPServer, BaseHTTPRequestHandler
|
||||||
from tools.get_server_token import GetServerTokenForDiscord
|
from fivemserver.get_server_token import GetServerTokenForDiscord
|
||||||
from config.constants import CLIENT_ID, REDIRECT_URI, SCOPES, AUTENTICATION_SUCCESS_MESSAGE
|
from config.constants import CLIENT_ID, REDIRECT_URI, SCOPES, AUTENTICATION_SUCCESS_MESSAGE
|
||||||
|
|
||||||
# Disable stderr output
|
# Disable stderr output
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
import psutil
|
import psutil
|
||||||
|
|
||||||
from pypresence.presence import Presence
|
from pypresence.presence import Presence
|
||||||
from tools.get_server_token import GetServerTokenForDiscord
|
from fivemserver.get_server_token import GetServerTokenForDiscord
|
||||||
from config.constants import Urls
|
from config.constants import Urls
|
||||||
from tools.discord_oauth import CLIENT_ID
|
from discord.discord_oauth import CLIENT_ID
|
||||||
|
|
||||||
|
|
||||||
class DiscordToken:
|
class DiscordToken:
|
||||||
@@ -65,12 +65,12 @@ class GetServerTokenForDiscord:
|
|||||||
aesgcm = AESGCM(GetServerTokenForDiscord.derived_key) # type: ignore[arg-type]
|
aesgcm = AESGCM(GetServerTokenForDiscord.derived_key) # type: ignore[arg-type]
|
||||||
return aesgcm.decrypt(nonce, encrypted_data, None)
|
return aesgcm.decrypt(nonce, encrypted_data, None)
|
||||||
|
|
||||||
# @staticmethod
|
@staticmethod
|
||||||
# def register_discord_user(user_id: str, server = API_URL) -> str:
|
def register_discord_user(user_id: str, server = Urls.API_URL.value) -> str:
|
||||||
# if server is None:
|
if server is None:
|
||||||
# server = API_URL
|
server = Urls.API_URL.value
|
||||||
# registeredId = requests.post(server + "/api_v2/connection/register", verify=False, json={
|
registeredId = requests.post(server + "/api_v2/connection/register", verify=False, json={
|
||||||
# "x-session-id": user_id
|
"x-session-id": user_id
|
||||||
# }).json()
|
}).json()
|
||||||
#
|
|
||||||
# return registeredId["discord_id"]
|
return registeredId["discord_id"]
|
||||||
23
src/fivemserver/whitelistmanager.py
Normal file
23
src/fivemserver/whitelistmanager.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import requests
|
||||||
|
from urllib3 import disable_warnings
|
||||||
|
from urllib3.exceptions import InsecureRequestWarning
|
||||||
|
|
||||||
|
# Supress only InsecureRequestWarning
|
||||||
|
disable_warnings(InsecureRequestWarning)
|
||||||
|
|
||||||
|
WHITELIST_URL_ENDPOINT = f'iswhitelist/'
|
||||||
|
|
||||||
|
class WhiteList:
|
||||||
|
@staticmethod
|
||||||
|
def checkwhitelist(url, discord_user_id: str) -> bool:
|
||||||
|
print('🗒️ Vérification de la whitelist...')
|
||||||
|
|
||||||
|
response = requests.get(url + WHITELIST_URL_ENDPOINT + discord_user_id, verify=False)
|
||||||
|
api_data = response.json()
|
||||||
|
|
||||||
|
if api_data['whitelisted']:
|
||||||
|
print("👍 Vous êtes en whitelist")
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
print('🙅♂️ Désole mais vous n\'êtes pas whitelisté sur le serveur.')
|
||||||
|
return False
|
||||||
@@ -9,8 +9,8 @@ from PySide6.QtWidgets import QApplication
|
|||||||
from config.config_manager import ConfigManager
|
from config.config_manager import ConfigManager
|
||||||
|
|
||||||
# Imports pour la vérification Discord
|
# Imports pour la vérification Discord
|
||||||
from tools.discord_tools import CheckDiscord
|
from discord.discord_tools import CheckDiscord
|
||||||
from tools.custom_message_box import CustomMessageBox
|
from ui.custom_message_box import CustomMessageBox
|
||||||
|
|
||||||
# Ne pas supprimer ! Enregistre les ressources Qt
|
# Ne pas supprimer ! Enregistre les ressources Qt
|
||||||
import resources # noqa: F401 - required to register Qt resources
|
import resources # noqa: F401 - required to register Qt resources
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ from config.config_manager import ConfigManager
|
|||||||
from controllers.audio_controller import AudioController
|
from controllers.audio_controller import AudioController
|
||||||
from controllers.glow_animator import GlowAnimator
|
from controllers.glow_animator import GlowAnimator
|
||||||
from controllers.window_dragger import WindowDragger
|
from controllers.window_dragger import WindowDragger
|
||||||
from tools import discord_oauth
|
from discord import discord_oauth
|
||||||
from config.constants import NO_STAFF, Urls
|
from config.constants import NO_STAFF, Urls
|
||||||
|
|
||||||
from fake_patch_notes import patch_note
|
from fake_patch_notes import patch_note
|
||||||
|
|||||||
Reference in New Issue
Block a user