Spaces:
Running on Zero
Running on Zero
Download main.py from Thaimozhi/File-Store-Bot: direct link, hf CLI and curl.
- Browser
- Download file 1.14 kB
-
https://huggingface.co/spaces/Thaimozhi/File-Store-Bot/resolve/main/main.py
- Command line
-
hf download hf://spaces/Thaimozhi/File-Store-Bot/main.py
-
curl -L -o main.py https://huggingface.co/spaces/Thaimozhi/File-Store-Bot/resolve/main/main.py
1.14 kB
| import asyncio | |
| import logging | |
| from bot import Bot, web_app | |
| from pyrogram import compose | |
| from pyrogram.errors import FloodWait | |
| from config import * | |
| log = logging.getLogger(__name__) | |
| async def main(): | |
| app = [] | |
| app.append( | |
| Bot( | |
| SESSION, | |
| WORKERS, | |
| DB_CHANNEL, | |
| FSUBS, | |
| TOKEN, | |
| ADMINS, | |
| MESSAGES, | |
| AUTO_DEL, | |
| DB_URI, | |
| DB_NAME, | |
| API_ID, | |
| API_HASH, | |
| PROTECT, | |
| DISABLE_BTN | |
| ) | |
| ) | |
| # Handle FloodWait on startup - wait and retry instead of crashing | |
| while True: | |
| try: | |
| await compose(app) | |
| break | |
| except FloodWait as e: | |
| wait = e.value if hasattr(e, 'value') else e.x | |
| log.warning(f"FloodWait on startup! Waiting {wait} seconds before retrying...") | |
| await asyncio.sleep(wait + 10) | |
| except Exception as e: | |
| log.error(f"Startup error: {e}") | |
| raise | |
| async def runner(): | |
| await asyncio.gather( | |
| main(), | |
| web_app() | |
| ) | |
| asyncio.run(runner()) | |