-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
52 lines (38 loc) · 1.7 KB
/
main.py
File metadata and controls
52 lines (38 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"""
main.py — Point d'entrée de BotDiff.
Charge les variables d'environnement et lance le bot Discord.
"""
from __future__ import annotations
import logging
import os
import sys
from dotenv import load_dotenv
from bot import BotDiff
from database import Database
from riot_api import RiotAPI
def main() -> None:
# ── Chargement de la configuration ──────────────────────
load_dotenv()
discord_token = os.getenv("DISCORD_TOKEN")
riot_api_key = os.getenv("RIOT_API_KEY")
riot_region = os.getenv("RIOT_REGION", "europe")
riot_platform = os.getenv("RIOT_PLATFORM", "euw1")
if not discord_token:
sys.exit("❌ Variable d'environnement DISCORD_TOKEN manquante.")
if not riot_api_key:
sys.exit("❌ Variable d'environnement RIOT_API_KEY manquante.")
# ── Logging ─────────────────────────────────────────────
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s %(levelname)-8s %(name)s %(message)s",
datefmt="%H:%M:%S",
)
# ── Instanciation ──────────────────────────────────────
riot = RiotAPI(api_key=riot_api_key, region=riot_region)
db = Database()
bot = BotDiff(riot_api=riot, db=db, platform=riot_platform)
# ── Lancement ──────────────────────────────────────────
logging.info("Démarrage de BotDiff…")
bot.run(discord_token, log_handler=None)
if __name__ == "__main__":
main()