Add MAIN_BOT_SESSION config to support mainbot.session file
Browse files- README.md +1 -0
- SETUP_SUMMARY.txt +5 -2
- config.py +5 -0
- sample.env +7 -1
- utils/bot_mode.py +1 -1
README.md
CHANGED
|
@@ -59,6 +59,7 @@ Welcome to TGDrive! This web application replicates Google Drive's functionaliti
|
|
| 59 |
| `DATABASE_BACKUP_TIME` | integer (in seconds) | 60 | Interval in seconds for database backups to the storage channel |
|
| 60 |
| `MAX_FILE_SIZE` | float (in GBs) | 1.98 (3.98 if `STRING_SESSIONS` are added) | Maximum file size (in GBs) allowed for uploading to Telegram |
|
| 61 |
| `WEBSITE_URL` | string | None | Website URL (with https/http) to auto-ping to keep the website active |
|
|
|
|
| 62 |
| `MAIN_BOT_TOKEN` | string | None | Your Main Bot Token to use [TG Drive's Bot Mode](#tg-drives-bot-mode) |
|
| 63 |
| `TELEGRAM_ADMIN_IDS` | string | None | List of Telegram User IDs of admins who can access the [bot mode](#tg-drives-bot-mode), separated by commas |
|
| 64 |
|
|
|
|
| 59 |
| `DATABASE_BACKUP_TIME` | integer (in seconds) | 60 | Interval in seconds for database backups to the storage channel |
|
| 60 |
| `MAX_FILE_SIZE` | float (in GBs) | 1.98 (3.98 if `STRING_SESSIONS` are added) | Maximum file size (in GBs) allowed for uploading to Telegram |
|
| 61 |
| `WEBSITE_URL` | string | None | Website URL (with https/http) to auto-ping to keep the website active |
|
| 62 |
+
| `MAIN_BOT_SESSION` | string | mainbot.session | Main Bot Session file name for [TG Drive's Bot Mode](#tg-drives-bot-mode). Place session file in cache/ directory. |
|
| 63 |
| `MAIN_BOT_TOKEN` | string | None | Your Main Bot Token to use [TG Drive's Bot Mode](#tg-drives-bot-mode) |
|
| 64 |
| `TELEGRAM_ADMIN_IDS` | string | None | List of Telegram User IDs of admins who can access the [bot mode](#tg-drives-bot-mode), separated by commas |
|
| 65 |
|
SETUP_SUMMARY.txt
CHANGED
|
@@ -15,11 +15,14 @@ NOTE: You need to upload cache/bot.session file to your Hugging Face Space
|
|
| 15 |
|
| 16 |
OPTIONAL - For Bot Mode (users can upload files via Telegram bot):
|
| 17 |
-------------------------------------------------------------------
|
|
|
|
| 18 |
MAIN_BOT_TOKEN=your_main_bot_token
|
| 19 |
TELEGRAM_ADMIN_IDS=123456789,987654321
|
| 20 |
|
| 21 |
-
NOTE:
|
| 22 |
-
|
|
|
|
|
|
|
| 23 |
|
| 24 |
OPTIONAL - For Premium (files > 2GB):
|
| 25 |
-------------------------------------
|
|
|
|
| 15 |
|
| 16 |
OPTIONAL - For Bot Mode (users can upload files via Telegram bot):
|
| 17 |
-------------------------------------------------------------------
|
| 18 |
+
MAIN_BOT_SESSION=mainbot.session # Default: mainbot.session
|
| 19 |
MAIN_BOT_TOKEN=your_main_bot_token
|
| 20 |
TELEGRAM_ADMIN_IDS=123456789,987654321
|
| 21 |
|
| 22 |
+
NOTE: MAIN_BOT_SESSION defaults to "mainbot.session"
|
| 23 |
+
- If session file exists in cache/, it will be used (faster connection)
|
| 24 |
+
- If session file doesn't exist, MAIN_BOT_TOKEN will create it
|
| 25 |
+
- You can upload cache/mainbot.session file to your Hugging Face Space
|
| 26 |
|
| 27 |
OPTIONAL - For Premium (files > 2GB):
|
| 28 |
-------------------------------------
|
config.py
CHANGED
|
@@ -79,7 +79,12 @@ WEBSITE_URL = os.getenv("WEBSITE_URL", None)
|
|
| 79 |
|
| 80 |
# For Using TG Drive's Bot Mode
|
| 81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
# Main Bot Token for TG Drive's Bot Mode
|
|
|
|
| 83 |
MAIN_BOT_TOKEN = os.getenv("MAIN_BOT_TOKEN", "")
|
| 84 |
if MAIN_BOT_TOKEN.strip() == "":
|
| 85 |
MAIN_BOT_TOKEN = None
|
|
|
|
| 79 |
|
| 80 |
# For Using TG Drive's Bot Mode
|
| 81 |
|
| 82 |
+
# Main Bot Session file name for TG Drive's Bot Mode (e.g., "mainbot.session")
|
| 83 |
+
# Session file should be in cache directory. Pyrogram will use it if it exists.
|
| 84 |
+
MAIN_BOT_SESSION = os.getenv("MAIN_BOT_SESSION", "mainbot.session").strip()
|
| 85 |
+
|
| 86 |
# Main Bot Token for TG Drive's Bot Mode
|
| 87 |
+
# Used with session file (if session file doesn't exist, token creates it)
|
| 88 |
MAIN_BOT_TOKEN = os.getenv("MAIN_BOT_TOKEN", "")
|
| 89 |
if MAIN_BOT_TOKEN.strip() == "":
|
| 90 |
MAIN_BOT_TOKEN = None
|
sample.env
CHANGED
|
@@ -13,8 +13,14 @@ DATABASE_BACKUP_MSG_ID=123
|
|
| 13 |
# Optional: String sessions for Premium accounts (files > 2GB)
|
| 14 |
# STRING_SESSIONS=1BVtsOMwBu5...your_session_string_here...
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
# Note:
|
| 17 |
# - BOT_TOKENS is required (Pyrogram needs token for bot clients)
|
| 18 |
# - BOT_SESSIONS is optional - if provided, Pyrogram will use those session file names
|
| 19 |
# - If session file exists, it will be used (faster connection)
|
| 20 |
-
# - If session file doesn't exist, Pyrogram will create it
|
|
|
|
|
|
| 13 |
# Optional: String sessions for Premium accounts (files > 2GB)
|
| 14 |
# STRING_SESSIONS=1BVtsOMwBu5...your_session_string_here...
|
| 15 |
|
| 16 |
+
# Optional: For TG Drive's Bot Mode
|
| 17 |
+
# MAIN_BOT_SESSION=mainbot.session # Session file name (default: mainbot.session)
|
| 18 |
+
# MAIN_BOT_TOKEN=your_main_bot_token # Bot token (required for bot mode)
|
| 19 |
+
# TELEGRAM_ADMIN_IDS=123456789,987654321 # Admin user IDs
|
| 20 |
+
|
| 21 |
# Note:
|
| 22 |
# - BOT_TOKENS is required (Pyrogram needs token for bot clients)
|
| 23 |
# - BOT_SESSIONS is optional - if provided, Pyrogram will use those session file names
|
| 24 |
# - If session file exists, it will be used (faster connection)
|
| 25 |
+
# - If session file doesn't exist, Pyrogram will create it
|
| 26 |
+
# - MAIN_BOT_SESSION defaults to "mainbot.session" - place it in cache/ directory
|
utils/bot_mode.py
CHANGED
|
@@ -28,7 +28,7 @@ session_cache_path = Path(f"./cache")
|
|
| 28 |
session_cache_path.parent.mkdir(parents=True, exist_ok=True)
|
| 29 |
|
| 30 |
main_bot = Client(
|
| 31 |
-
name="
|
| 32 |
api_id=config.API_ID,
|
| 33 |
api_hash=config.API_HASH,
|
| 34 |
bot_token=config.MAIN_BOT_TOKEN,
|
|
|
|
| 28 |
session_cache_path.parent.mkdir(parents=True, exist_ok=True)
|
| 29 |
|
| 30 |
main_bot = Client(
|
| 31 |
+
name=config.MAIN_BOT_SESSION.replace(".session", ""), # Remove .session extension for name
|
| 32 |
api_id=config.API_ID,
|
| 33 |
api_hash=config.API_HASH,
|
| 34 |
bot_token=config.MAIN_BOT_TOKEN,
|