File size: 2,449 Bytes
80287e2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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())