againmusic / Devine /__main__.py
taslim19
Initial commit
80287e2
import asyncio
import importlib
from pyrogram import idle
from pytgcalls.exceptions import NoActiveGroupCall
import config
from Devine import LOGGER, app, userbot
from Devine.core.call import Anony
from Devine.misc import sudo
from Devine.plugins import ALL_MODULES
from Devine.utils.database import get_banned_users, get_gbanned
from config import BANNED_USERS
# Import redeploy command (relative import, considering the repo structure)
import sys
sys.path.append("..") # Add the parent directory to the Python path
from redeploy import redeploy # Now the redeploy.py can be imported
async def init():
if (
not config.STRING1
and not config.STRING2
and not config.STRING3
and not config.STRING4
and not config.STRING5
):
LOGGER(__name__).error("Assistant client variables not defined, exiting...")
return # Changed from exit() to return
await sudo()
try:
users = await get_gbanned()
for user_id in users:
BANNED_USERS.add(user_id)
users = await get_banned_users()
for user_id in users:
BANNED_USERS.add(user_id)
except Exception as e:
LOGGER(__name__).error(f"Error fetching banned users: {e}")
await app.start()
for all_module in ALL_MODULES:
importlib.import_module("Devine.plugins" + all_module)
LOGGER("Devine.plugins").info("Successfully Imported Modules...")
await userbot.start()
await Anony.start()
try:
await Anony.stream_call("https://telegra.ph//file/1df0320b93c2f3353c3e6.mp4")
except NoActiveGroupCall:
LOGGER("Devine").error(
"Please turn on the video chat of your log group/channel.\n\nStopping Bot..."
)
return # Changed from exit() to return
except Exception as e:
LOGGER("Devine").error(f"Error in streaming call: {e}")
await Anony.decorators()
LOGGER("Devine").info(
"Powered by @Devine_network."
)
await idle() # Keeps the bot running
await shutdown() # Proper shutdown sequence
async def shutdown():
LOGGER("Devine").info("Shutting down gracefully...")
try:
await app.stop()
await userbot.stop()
LOGGER("Devine").info("Stopping AnonX Music Bot...")
except Exception as e:
LOGGER("Devine").error(f"Error during shutdown: {e}")
if __name__ == "__main__":
asyncio.get_event_loop().run_until_complete(init())