Spaces:
Running on Zero
Running on Zero
File size: 1,136 Bytes
60e9648 | 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 53 | 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())
|