diff --git a/.env_template b/.env_template index 015c89c..b21c7e2 100644 --- a/.env_template +++ b/.env_template @@ -2,4 +2,5 @@ TOKEN= APPLICATIONID= FORTNITEAPI= XBOXAPI= +FIREBASEURL= DEBUGMODE=OFF \ No newline at end of file diff --git a/README.md b/README.md index 36321a5..93fb479 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# R4Bot ![Version](https://img.shields.io/badge/Latest-1.1.1/master-blue.svg) +# R4Bot ![Version](https://img.shields.io/badge/Latest-1.1.2/master-blue.svg) Discord-бот, созданный для облегчения модерации серверов, и не только. Используются слэш-команды. ## 🛠️ Установка @@ -60,5 +60,6 @@ TOKEN= // Токен бота Discord APPLICATIONID= // Application ID приложения бота с Discord Developer Portal FORTNITEAPI= // Ключ API для получения данных с https://fortnite-api.com/ XBOXAPI= // Ключ API для получения данных с https://xbl.io/ +FIREBASEURL= // Адрес для подключения к БД Firebase Realtime DEBUGMODE=OFF // Значение DEBUG-режима ``` diff --git a/main.py b/main.py index ad9c509..fd248d7 100644 --- a/main.py +++ b/main.py @@ -1,9 +1,9 @@ import discord from modules.firebase import create_firebase_app -from options import token, debugmode, version, gearsList +from options import token, debugmode, version, gearsList, firebaseURL -create_firebase_app() +create_firebase_app(firebaseURL) # Define intents for the bot to receive all available events intents = discord.Intents.all() @@ -14,6 +14,7 @@ # Create the Discord bot instance with specified intents bot = discord.Bot(case_insensitive=True, intents=intents) + # Gears are always cool # Event that runs when the bot is ready and connected to Discord @@ -27,7 +28,7 @@ async def on_ready(): for guild in bot.guilds: print(f"Подключились к серверу: {guild}") print("------") - + # Set bot status and activity based on debug mode if debugmode == "ON": status = discord.Status.dnd @@ -37,6 +38,7 @@ async def on_ready(): activity = discord.Activity(type=discord.ActivityType.listening, name=f"обиды участников (v{version})") await bot.change_presence(status=status, activity=activity) + for module_name in gearsList: try: bot.load_extension(f'gears.{module_name}') diff --git a/modules/firebase.py b/modules/firebase.py index fe5384a..939b80b 100644 --- a/modules/firebase.py +++ b/modules/firebase.py @@ -3,10 +3,10 @@ from firebase_admin import credentials, initialize_app, db -def create_firebase_app(): - cred_obj = credentials.Certificate("firebaseConfig.json", ) +def create_firebase_app(databaseURL: str): + cred_obj = credentials.Certificate("firebaseConfig.json") firebase = initialize_app(cred_obj, - {"databaseURL": "https://r4bot-50baf-default-rtdb.firebaseio.com/"}) + {"databaseURL": databaseURL}) return firebase diff --git a/options.py b/options.py index 03d7934..90b48e2 100644 --- a/options.py +++ b/options.py @@ -7,13 +7,14 @@ # Load environment variables from .env file load_dotenv() -version = "1.1.1" +version = "1.1.2" # Get environment variables token = environ.get('TOKEN') applicationID = environ.get('APPLICATIONID') fortniteapi = environ.get('FORTNITEAPI') xboxapi = environ.get('XBOXAPI') +firebaseURL = environ.get('FIREBASEURL') debugmode = environ.get('DEBUGMODE') try: