Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
73c1baa
Update app.log
Oreshout Jul 16, 2025
4285e3d
Merge pull request #1 from Oreshout/main
Oreshout Jul 16, 2025
60eab14
add build for documentation sphinx
Oreshout Jul 16, 2025
551c2e4
Main page and Get started of the documentation
Oreshout Jul 16, 2025
abe3c47
Update .env
Oreshout Jul 16, 2025
14a23df
add terms of service
Oreshout Jul 16, 2025
cf47b60
Merge branch 'Dev' of https://github.com/Oreshout/Private_Bot_Discord…
Oreshout Jul 16, 2025
20f79e2
Add build folder content
Oreshout Jul 16, 2025
a89c98a
privacy_policy
Oreshout Jul 16, 2025
0e11607
visuel doc
Oreshout Jul 16, 2025
0b33dc0
ajout French without compil
Oreshout Jul 16, 2025
b454c60
langue fr de base avec les .po et .mo
Oreshout Jul 16, 2025
f1a1f37
readme update
Oreshout Jul 16, 2025
3417faa
ajout .github + TODO
Oreshout Jul 17, 2025
21c5dc6
Update TODO.md
Oreshout Jul 17, 2025
aec859d
c'est pas encore ca
Oreshout Jul 17, 2025
4cda5a8
Correction bugs
Victoirrr Jul 17, 2025
3e80be3
Update .gitignore
Victoirrr Jul 17, 2025
e15109c
Ajout de 1 modif max
Victoirrr Jul 17, 2025
236d3fd
Debut visualisation
Oreshout Jul 17, 2025
e1364f1
Fonction de visualisation ✅
Victoirrr Jul 17, 2025
63f5c98
Ajout commande présentation
Oreshout Jul 18, 2025
d9e94de
Correction texte
Oreshout Jul 18, 2025
45aed8f
changement migration build -> docs pour la page github de doc
Oreshout Jul 18, 2025
65556de
maj de la documentation
Oreshout Jul 18, 2025
f13602a
static to dev
Oreshout Jul 18, 2025
9058052
static prod to Dev
Oreshout Jul 18, 2025
3bb1681
source -> Docs
Oreshout Jul 18, 2025
f9700fe
ajout myst-parser au fichier yml
Oreshout Jul 18, 2025
0c7a0aa
bug de chemin dans conf.py
Oreshout Jul 18, 2025
f92ecfe
install furo
Oreshout Jul 18, 2025
0ed0fad
correction bug graphique
Oreshout Jul 18, 2025
96fb0b4
correction visuel site docu V2
Oreshout Jul 18, 2025
a11b30d
ajout de l'arborescence dans la docu
Oreshout Jul 18, 2025
f703670
correction doc + requirement.txt
Oreshout Jul 18, 2025
4f7f12e
modification tableau
Oreshout Jul 18, 2025
df82693
traduction
Oreshout Jul 18, 2025
8f3235b
Update get_started.rst
Oreshout Jul 18, 2025
3827ae2
modification emplacement fichier
Oreshout Jul 18, 2025
dda6667
DOC : modification chemin
Oreshout Jul 18, 2025
2bc578f
DOC : test ico
Oreshout Jul 18, 2025
b309bf0
modification logger presentation
Oreshout Jul 21, 2025
d5c13e5
modification des erreurs
Oreshout Jul 21, 2025
c9a98d8
Update app.log
Oreshout Jul 21, 2025
eb2683e
Update static.yml
Oreshout Jul 21, 2025
e3a9761
ajout mail
Oreshout Jul 21, 2025
37ef1be
Update app.log
Oreshout Jul 21, 2025
69b1065
maj index contact support
Oreshout Jul 21, 2025
01a7ecf
forcing space
Oreshout Jul 21, 2025
15b521e
try 2
Oreshout Jul 21, 2025
fa84802
ajout de logo
Oreshout Jul 21, 2025
ab7d2dc
without mistake of indentation
Oreshout Jul 21, 2025
894ad02
Update index.rst
Oreshout Jul 21, 2025
71c7869
Update index.rst
Oreshout Jul 21, 2025
18cb1cb
Update index.rst
Oreshout Jul 21, 2025
306ed58
Update index.rst
Oreshout Jul 21, 2025
80daf3a
Update get_started.rst
Oreshout Jul 21, 2025
5af672d
Update index.rst
Oreshout Jul 21, 2025
5868401
update data
Oreshout Jul 21, 2025
462176a
acknowledgements.rst
Oreshout Jul 21, 2025
ba885d0
Update acknowledgements.rst
Oreshout Jul 21, 2025
f0aca1e
update data
Oreshout Jul 21, 2025
8fc89c5
Réglage BUG presentation
Oreshout Jul 21, 2025
0af46e4
Update app.log
Oreshout Jul 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Deploy Sphinx documentation to GitHub Pages

on:
push:
branches: ["Dev"]
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "pages"
cancel-in-progress: false

jobs:
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install sphinx sphinx_rtd_theme myst-parser furo

- name: Build Sphinx documentation
run: |
sphinx-build -b html ./docs/source ./docs/html

- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./docs/html # Dossier contenant la doc HTML générée

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
venv/
*.env
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<p align="center">
<a href="https://discord.gg/89ENkYSCWE">
<img src="/sprites/Discord-logo.png" alt="Discord Server" width="70" height="45">
<img src="/sprites/discord-logo.png" alt="Discord Server" width="70" height="45">
</a>

<p align="center">
Expand Down
9 changes: 9 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## 🛠️ To-Do List

- [x] Générer la doc avec Sphinx
- [x] Déployer la documentation en ligne
- [ ] Création du jeu F1F
- [ ] Commande administrateur complète
- [ ] Gestions des data
- [ ] Tester le bot à spa en commité réduit (DEV / STAFF / BOOSTEUR)
- [ ] Supprimé la commande ban du bot
1 change: 0 additions & 1 deletion app/.env

This file was deleted.

Binary file added app/__pycache__/admin_command.cpython-313.pyc
Binary file not shown.
Binary file added app/__pycache__/api.cpython-313.pyc
Binary file not shown.
Binary file modified app/__pycache__/classement.cpython-313.pyc
Binary file not shown.
Binary file modified app/__pycache__/config.cpython-313.pyc
Binary file not shown.
Binary file modified app/__pycache__/error_embed.cpython-313.pyc
Binary file not shown.
Binary file added app/__pycache__/f1api.cpython-313.pyc
Binary file not shown.
Binary file added app/__pycache__/pronos.cpython-313.pyc
Binary file not shown.
Binary file modified app/__pycache__/tools.cpython-313.pyc
Binary file not shown.
304 changes: 216 additions & 88 deletions app/_app.py

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions app/admin_command.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from config import EMBED_COLOR_RED, EMBED_THUMBNAIL, EMBED_FOOTER_TEXT, EMBED_IMAGE
from error_embed import chat_Oops
import discord

async def ban(interaction: discord.Interaction, member: discord.Member, reason:str, article: str):
try:
await discord.Member.ban(reason=reason, article=article)

embed = discord.Embed(
title=f"Le membre {member} à été banni!",
description="Zoup dehors",
color=EMBED_COLOR_RED
)

embed.set_footer(text=EMBED_FOOTER_TEXT, icon_url=EMBED_THUMBNAIL)
embed.set_thumbnail(url=interaction.user.display_avatar.url)
embed.set_image(url=EMBED_IMAGE)

await interaction.response.send_message(embed=embed, ephemeral=False)

except ValueError:
chat_Oops(interaction)


230 changes: 156 additions & 74 deletions app/classement.py
Original file line number Diff line number Diff line change
@@ -1,86 +1,168 @@
import json
import os
from thefuzz import fuzz
import discord
from config import logger, EMBED_COLOR_RED, EMBED_THUMBNAIL, EMBED_FOOTER_TEXT, EMBED_IMAGE
import pandas as pd


def calculer_classement(resultats, pronostics_df, output_file_path):
classement = []

# Convertir JSON en dict position -> nom
resultats_dict = {int(pos): nom for pos, nom in resultats}

for _, row in pronostics_df.iterrows():
pseudo = row["Pseudo"]
score = 0

# Si tout est bon → +5 points
if (
row.get("Premier", "").strip().lower() == resultats_dict.get(1, "").strip().lower() and
row.get("Deuxième", "").strip().lower() == resultats_dict.get(2, "").strip().lower() and
row.get("Troisième", "").strip().lower(
) == resultats_dict.get(3, "").strip().lower()
):
score += 5
def saveResults():

try:
with open('../data/Results.json', 'r', encoding='utf-8') as f:
results = json.load(f)
with open('../data/Pronos.json', 'r', encoding='utf-8') as f:
pronos = json.load(f)

except ValueError:
logger.info("Files cannot be accessed, are you sure pronostics exist ?")
return

try:
with open('data/Barem.json', 'r', encoding='utf-8') as f:
barem = json.load(f)
except ValueError:
logger.info("Problem with Barem")
return

Premier = results['1']
Second = results['2']
Troisième = results['3']

for key in pronos.keys():
points = 0
complex = False
logger.info(key)
Premier_Pronos = False
Second_Pronos = False
Troisième_Pronos = False

def match_Position(entry: str, target: str, threshold: int) -> bool:
parts = entry.strip().split(' ', 1)

if (len(parts) == 2):
prenom, nom = parts
else:
prenom = nom = parts[0]

target_prenom, target_nom = target.strip().split(' ', 1)
return fuzz.ratio(target_prenom.lower(), prenom.lower()) >= 90 or fuzz.ratio(target_nom.lower(), nom.lower()) >= threshold

Premier_Pronos = match_Position(pronos[key]['1'], Premier, 90)
Second_Pronos = match_Position(pronos[key]['2'], Second, 90)
Troisième_Pronos = match_Position(pronos[key]['3'], Troisième, 90)

try:
if Premier_Pronos and Second_Pronos and Troisième_Pronos:
logger.info("Tout juste pour "+pronos[key]["Pseudo"])
points += barem["allCorrect"]
complex = True

elif Premier_Pronos and Second_Pronos:
logger.info("Le premier et le deuxième sont bon pour " +
pronos[key]['Pseudo']+" + "+str(barem["first2Correct"])+" Points")
points += barem["first2Correct"]
complex = True

elif Second_Pronos and Troisième_Pronos:

logger.info(
"Le premier est bon"+pronos[key]['Pseudo']+" + "+str(barem["last2Correct"])+" Points")
points += barem["last2Correct"]
complex = True

elif (Troisième_Pronos and Premier_Pronos):

logger.info("Le premier et le dernier sont bons pour " +
pronos[key]['Pseudo']+" + "+str(barem["1and3Correct"])+" Points")
points += barem["1and3Correct"]
complex = True

except KeyError as e:
logger.info(str(e) + "is missing")
pass
except TypeError as e:
logger.info(e)
pass

try:
if (Premier_Pronos and not complex):
logger.info("Le premier est bon pour " +
pronos[key]['Pseudo']+" + "+str(barem["firstCorrect"])+" Points")
points += barem["firstCorrect"]

if (Second_Pronos and not complex):
logger.info("Le deuxième est bon pour " +
pronos[key]['Pseudo']+" + "+str(barem["secondCorrect"])+" Points")
points += barem["secondCorrect"]

if (Troisième_Pronos and not complex):
logger.info("Le troisième est bon pour " +
pronos[key]['Pseudo']+" + "+str(barem["thirdCorrect"])+" Points")
points += barem["thirdCorrect"]

except KeyError as e:
logger.info(str(e) + "is missing")
return

except TypeError as e:
logger.info(e)
return

file_path = 'data/Leaderbord.json'

if not os.path.exists(file_path):
pointsPronos = {
key: {
"Pseudo": pronos[key]["Pseudo"],
"Points": points
}
}
else:
# Comparaison Premier
if "Premier" in row and 1 in resultats_dict:
if row["Premier"].strip().lower() == resultats_dict[1].strip().lower():
score += 1
elif row["Premier"].strip().lower() in [
resultats_dict[2].strip().lower(
), resultats_dict[3].strip().lower()
]:
score += 0.5

# Comparaison Deuxième
if "Deuxième" in row and 2 in resultats_dict:
if row["Deuxième"].strip().lower() == resultats_dict[2].strip().lower():
score += 1
elif row["Deuxième"].strip().lower() in [
resultats_dict[1].strip().lower(
), resultats_dict[3].strip().lower()
]:
score += 0.5

# Comparaison Troisième
if "Troisième" in row and 3 in resultats_dict:
if row["Troisième"].strip().lower() == resultats_dict[3].strip().lower():
score += 1
elif row["Troisième"].strip().lower() in [
resultats_dict[1].strip().lower(
), resultats_dict[2].strip().lower()
]:
score += 0.5

# Ajouter au classement
classement.append((pseudo, score))

# Trier par score décroissant
classement.sort(key=lambda x: x[1], reverse=True)

# Création du DataFrame à partir du classement calculé
colonnes = ["Pseudo", "Score"]
df_classement = pd.DataFrame(classement, columns=colonnes)

# Sauvegarde dans le fichier Excel
df_classement.to_excel(output_file_path, index=False)

logger.info(f"✅ Classement sauvegardé dans : {output_file_path}")

return df_classement

# _______________________________________________________________________________________________________________________________


def embed_classement(classement):
with open(file_path, 'r', encoding='utf-8') as f:
pointsPronos = json.load(f)
if key not in pointsPronos:
pointsPronos[key] = {
"Pseudo": pronos[key]["Pseudo"],
"Points": points
}
else:
pointsPronos[key]["Pseudo"] = pronos[key]["Pseudo"]
pointsPronos[key]["Points"] += points

with open(file_path, 'w', encoding='utf-8') as f:
json.dump(pointsPronos, f, ensure_ascii=False, indent=4)


def Leaderboard():

try:
with open("data/Leaderbord.json", 'r', encoding='utf-8') as f:
pointsPronos = json.load(f)
pronosLeaderboard = dict(
sorted(pointsPronos.items(), key=lambda item: item[1]['Points'], reverse=True))

except FileNotFoundError:
logger.info("The file doesn't exist")
return

except KeyError:
logger.info("Erreur dans la lecture des points")
return

embed = discord.Embed(
title="🏆 Classement des Pronostics",
color=EMBED_COLOR_RED
)
for i, (pseudo, score) in enumerate(classement, start=1):
embed.add_field(name=f"{i}ᵉ - {pseudo}",
value=f"Score : **{score}**", inline=False)

pseudos, points = zip(*[(val['Pseudo'], val['Points'])
for val in pronosLeaderboard.values()])
pseudos = list(pseudos)
points = list(points)
position = 1
for i in range(len(pseudos)):
embed.add_field(name=f"{position}ᵉ - {pseudos[i]}",
value=f"Score : **{points[i]}**", inline=False)
if (i+1 < len(pseudos) and points[i] != points[i+1]):
position += 1
embed.set_footer(text=EMBED_FOOTER_TEXT)
embed.set_image(url=EMBED_IMAGE)
embed.set_thumbnail(url=EMBED_THUMBNAIL)
Expand Down
10 changes: 8 additions & 2 deletions app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
logger = logging.getLogger("F1F_Bot")
logger.setLevel(LOG_LEVEL)

log_path = "../log/app.log"
log_path = "log/app.log"
# Crée le dossier si nécessaire
os.makedirs(os.path.dirname(log_path), exist_ok=True)

Expand All @@ -46,7 +46,7 @@
EMBED_THUMBNAIL = "https://cdn.discordapp.com/attachments/1339299411360088226/1367477935392428083/Votre_texte_de_paragraphe_12.png?ex=6871ac52&is=68705ad2&hm=a63fd375a9f30130247df80b936c43e1d93b3a5b16c3415f7a63cac72614058e&"
EMBED_IMAGE = "https://cdn.discordapp.com/attachments/1339299411360088226/1368544420504272987/Design_sans_titre_2.png?ex=68719910&is=68704790&hm=46bd1e4a625f33cc26d5e029888bef5c265732b842de241daa62662206f13885&"

EMBED_FOOTER_TEXT = "Bot créé par F1F Team"
EMBED_FOOTER_TEXT = "Bot créé par F1F Team (BETA)"
EMBED_FOOTER_ICON = EMBED_THUMBNAIL


Expand All @@ -57,3 +57,9 @@
URL_BASE = "https://fr.motorsport.com/"
URL_RESULT_COURSE = "https://fr.motorsport.com/f1/results/2025"
URL_RESULT_QUALIF = "https://fr.motorsport.com/f1/results/2025/gp-de-grande-bretagne-653245/?st=Q3"

# === Environment variable ===

PRONOS_ID=1395093933176131755
GUILD_ID = 1394054995523010761

Loading