From 7d830e0ebdf774ba1b0af74cf55ce316e0cddf7b Mon Sep 17 00:00:00 2001 From: Abhi Date: Mon, 22 Jul 2024 23:35:57 +0530 Subject: [PATCH] update configs, fix config loads, musicbot --- .env.dist | 9 ++++++++- app.json | 10 +++++++++- install.sh | 23 +++++++++++++++++++++++ utils/config.py | 15 +++++++++------ 4 files changed, 49 insertions(+), 8 deletions(-) diff --git a/.env.dist b/.env.dist index 1e00455..7722fb7 100644 --- a/.env.dist +++ b/.env.dist @@ -12,8 +12,15 @@ DATABASE_URL={db_url} # STRING SESSION if not set it will be generated at startup STRINGSESSION={@string_session} +# Second session for music bot +# Set if you want to use music bot +SECOND_SESSION={@second_session} + +# Music handler for music bot +MUSIC_HANDLER={@music_handler} + # PM LIMIT for AntiPM plugin -PM_LIMIT=4 +PM_LIMIT={@pm_limit} # apiflash api key only for webshot plugin APIFLASH_KEY={@api_flash_key} diff --git a/app.json b/app.json index 7cb0936..b4461cb 100644 --- a/app.json +++ b/app.json @@ -19,10 +19,18 @@ "required": true }, "PM_LIMIT": { - "description": "set your pm permit warn limit", + "description": "set your pm permit warn limit, default is 4", "value": "4", "required": true }, + "SECOND_SESSION": { + "description": "Pyrorogram v2 session string for music bot, only fill this if you want to use music bot feature", + "required": false + }, + "MUSIC_HANDLER": { + "description": "set your music bot handler, only fill this if you want to use music bot feature, available handlers are: ,.!@; make sure tit doesn't conflict with your main prefix", + "required": false + }, "DATABASE_URL": { "description": "ONLY for MongoDB, get it from https://cloud.mongodb.com", "required": false diff --git a/install.sh b/install.sh index 318260c..31c2e58 100644 --- a/install.sh +++ b/install.sh @@ -53,6 +53,27 @@ if [[ $pm_limit = "" ]]; then echo "limit not provided by user set to default" fi +echo +echo "Do you want to use musicbot? (y/n)" +read -r -p "MUSIC_BOT > " musicbot +if [[ $musicbot = "y" ]]; then + echo + echo "Enter SECOND_SESSION_STRING to be used by musicbot" + read -r -p "SECOND_SESSION > " second_session + if [[ $second_session = "" ]]; then + echo "SECOND_SESSION not provided by user" + second_session="" + else + echo + echo "Please provide handler to be used by msuicbot" + read -r -p "MUSIC_HANDLER > " music_handler + if [[ $music_handler = "" ]]; then + echo "MUSIC_HANDLER not provided by user" + music_handler="" + fi + fi +fi + echo echo "Enter APIFLASH_KEY for webshot plugin" echo "You can get it here -> https://apiflash.com/dashboard/access_keys" @@ -162,6 +183,8 @@ GEMINI_KEY=${gemini_key} VCA_API_KEY=${vca_api_key} COHERE_KEY=${cohere_key} PM_LIMIT=${pm_limit} +SECOND_SESSION=${second_session} +MUSIC_HANDLER=${music_handler} EOL chown -R $SUDO_USER:$SUDO_USER . diff --git a/utils/config.py b/utils/config.py index 85b55cc..2eb8e94 100644 --- a/utils/config.py +++ b/utils/config.py @@ -12,18 +12,21 @@ api_hash = os.getenv("API_HASH", env.str("API_HASH")) STRINGSESSION = os.getenv("STRINGSESSION", env.str("STRINGSESSION")) +second_session = os.getenv("SECOND_SESSION", env.str("SECOND_SESSION", "")) +music_handler = os.getenv("MUSIC_HANDLER", env.str("MUSIC_HANDLER", "")) + db_type = os.getenv("DATABASE_TYPE", env.str("DATABASE_TYPE")) db_url = os.getenv("DATABASE_URL", env.str("DATABASE_URL", "")) db_name = os.getenv("DATABASE_NAME", env.str("DATABASE_NAME")) apiflash_key = os.getenv("APIFLASH_KEY", env.str("APIFLASH_KEY")) -rmbg_key = os.getenv("RMBG_KEY", env.str("RMBG_KEY")) -vt_key = os.getenv("VT_KEY", env.str("VT_KEY")) -gemini_key = os.getenv("GEMINI_KEY", env.str("GEMINI_KEY")) -vca_api_key = os.getenv("VCA_API_KEY", env.str("VCA_API_KEY")) -cohere_key = os.getenv("COHERE_KEY", env.str("COHERE_KEY")) +rmbg_key = os.getenv("RMBG_KEY", env.str("RMBG_KEY", "")) +vt_key = os.getenv("VT_KEY", env.str("VT_KEY", "")) +gemini_key = os.getenv("GEMINI_KEY", env.str("GEMINI_KEY", "")) +vca_api_key = os.getenv("VCA_API_KEY", env.str("VCA_API_KEY", "")) +cohere_key = os.getenv("COHERE_KEY", env.str("COHERE_KEY", "")) -pm_limit = int(os.getenv("PM_LIMIT", env.int("PM_LIMIT"))) +pm_limit = int(os.getenv("PM_LIMIT", env.int("PM_LIMIT", 4))) test_server = bool(os.getenv("TEST_SERVER", env.bool("TEST_SERVER", False))) modules_repo_branch = os.getenv("MODULES_REPO_BRANCH", env.str("MODULES_REPO_BRANCH", "master"))