feat: implment bot discord for alert when one person is enrol in tournament
Browse files- bot_discord.py +0 -3
- echo_server.py +5 -0
- server.py +0 -3
bot_discord.py
CHANGED
|
@@ -6,8 +6,6 @@ from dotenv import load_dotenv
|
|
| 6 |
load_dotenv()
|
| 7 |
WEBHOOK_URL = os.getenv("DISCORD_WEBHOOK_URL") # Plus simple qu'un bot complet
|
| 8 |
|
| 9 |
-
mcp = FastMCP(name="DiscordServer", stateless_http=True)
|
| 10 |
-
|
| 11 |
def format_announcement(nom_participant, nom_tournoi, lien_inscription, date, lieu):
|
| 12 |
nom_participant_stylé = f"✨ **@{nom_participant}** ✨"
|
| 13 |
return (
|
|
@@ -18,7 +16,6 @@ def format_announcement(nom_participant, nom_tournoi, lien_inscription, date, li
|
|
| 18 |
f"Préparez-vous à encourager et à passer un bon moment ! 💪"
|
| 19 |
)
|
| 20 |
|
| 21 |
-
@mcp.tool(description='Envoie un message sur Discord pour annoncer qu\'un participant rejoint un tournoi.')
|
| 22 |
def trigger_message(nom: str, tournoi: str, lien: str, date: str, lieu: str):
|
| 23 |
"""Envoie un message Discord via webhook - beaucoup plus simple !"""
|
| 24 |
try:
|
|
|
|
| 6 |
load_dotenv()
|
| 7 |
WEBHOOK_URL = os.getenv("DISCORD_WEBHOOK_URL") # Plus simple qu'un bot complet
|
| 8 |
|
|
|
|
|
|
|
| 9 |
def format_announcement(nom_participant, nom_tournoi, lien_inscription, date, lieu):
|
| 10 |
nom_participant_stylé = f"✨ **@{nom_participant}** ✨"
|
| 11 |
return (
|
|
|
|
| 16 |
f"Préparez-vous à encourager et à passer un bon moment ! 💪"
|
| 17 |
)
|
| 18 |
|
|
|
|
| 19 |
def trigger_message(nom: str, tournoi: str, lien: str, date: str, lieu: str):
|
| 20 |
"""Envoie un message Discord via webhook - beaucoup plus simple !"""
|
| 21 |
try:
|
echo_server.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import requests
|
|
|
|
| 2 |
from mcp.server.fastmcp import FastMCP
|
| 3 |
|
| 4 |
mcp = FastMCP("Chess Analysis Server")
|
|
@@ -26,6 +27,10 @@ def analyze_latest_game(username: str, player_color: str):
|
|
| 26 |
return {"player_username": username, "pgn": game["games"][-1]["pgn"]}
|
| 27 |
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
# @mcp.tool(description="Extracts FEN from a Chess.com game URL")
|
| 30 |
# def get_game_pgn_from_url(game_url: str, player_username: str):
|
| 31 |
# game_id = game_url.split("/")[-1]
|
|
|
|
| 1 |
import requests
|
| 2 |
+
from bot_discord import trigger_message
|
| 3 |
from mcp.server.fastmcp import FastMCP
|
| 4 |
|
| 5 |
mcp = FastMCP("Chess Analysis Server")
|
|
|
|
| 27 |
return {"player_username": username, "pgn": game["games"][-1]["pgn"]}
|
| 28 |
|
| 29 |
|
| 30 |
+
@mcp.tool(description='Envoie un message sur Discord pour annoncer qu\'un participant rejoint un tournoi.')
|
| 31 |
+
def send_message_discord(nom: str, tournoi: str, lien: str, date: str, lieu: str):
|
| 32 |
+
trigger_message(nom, tournoi, lien, date, lieu)
|
| 33 |
+
|
| 34 |
# @mcp.tool(description="Extracts FEN from a Chess.com game URL")
|
| 35 |
# def get_game_pgn_from_url(game_url: str, player_username: str):
|
| 36 |
# game_id = game_url.split("/")[-1]
|
server.py
CHANGED
|
@@ -5,7 +5,6 @@ from fastapi.staticfiles import StaticFiles
|
|
| 5 |
from fastapi.templating import Jinja2Templates
|
| 6 |
from echo_server import mcp as echo_mcp
|
| 7 |
from math_server import mcp as math_mcp
|
| 8 |
-
from bot_discord import mcp as bot_discord_mcp
|
| 9 |
import os
|
| 10 |
|
| 11 |
|
|
@@ -15,7 +14,6 @@ async def lifespan(app: FastAPI):
|
|
| 15 |
async with contextlib.AsyncExitStack() as stack:
|
| 16 |
await stack.enter_async_context(echo_mcp.session_manager.run())
|
| 17 |
await stack.enter_async_context(math_mcp.session_manager.run())
|
| 18 |
-
await stack.enter_async_context(bot_discord_mcp.session_manager.run())
|
| 19 |
yield
|
| 20 |
|
| 21 |
|
|
@@ -40,7 +38,6 @@ async def index(request: Request):
|
|
| 40 |
base_url = f"{request.url.scheme}://{request.url.netloc}"
|
| 41 |
return templates.TemplateResponse("index.html", {"request": request, "base_url": base_url})
|
| 42 |
|
| 43 |
-
app.mount("/bot-discord", bot_discord_mcp.streamable_http_app())
|
| 44 |
app.mount("/echo", echo_mcp.streamable_http_app())
|
| 45 |
app.mount("/math", math_mcp.streamable_http_app())
|
| 46 |
|
|
|
|
| 5 |
from fastapi.templating import Jinja2Templates
|
| 6 |
from echo_server import mcp as echo_mcp
|
| 7 |
from math_server import mcp as math_mcp
|
|
|
|
| 8 |
import os
|
| 9 |
|
| 10 |
|
|
|
|
| 14 |
async with contextlib.AsyncExitStack() as stack:
|
| 15 |
await stack.enter_async_context(echo_mcp.session_manager.run())
|
| 16 |
await stack.enter_async_context(math_mcp.session_manager.run())
|
|
|
|
| 17 |
yield
|
| 18 |
|
| 19 |
|
|
|
|
| 38 |
base_url = f"{request.url.scheme}://{request.url.netloc}"
|
| 39 |
return templates.TemplateResponse("index.html", {"request": request, "base_url": base_url})
|
| 40 |
|
|
|
|
| 41 |
app.mount("/echo", echo_mcp.streamable_http_app())
|
| 42 |
app.mount("/math", math_mcp.streamable_http_app())
|
| 43 |
|