forked from KabusZamanEltac/Zaid-Vc-Player
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
66 lines (56 loc) · 1.95 KB
/
main.py
File metadata and controls
66 lines (56 loc) · 1.95 KB
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
import asyncio
import time
import uvloop
import importlib
from pyrogram import Client
from Music.config import API_ID, API_HASH, BOT_TOKEN, MONGO_DB_URI, SUDO_USERS, LOG_GROUP_ID
from Music import BOT_NAME, ASSNAME, app, client
from Music.MusicUtilities.database.functions import clean_restart_stage
from Music.MusicUtilities.database.queue import (get_active_chats, remove_active_chat)
from Music.MusicUtilities.tgcallsrun import run
from pytgcalls import idle
from motor.motor_asyncio import AsyncIOMotorClient as MongoClient
import time
Client(
':Music:',
API_ID,
API_HASH,
bot_token=BOT_TOKEN,
plugins={'root': 'Music.Plugins'},
).start()
print(f"[INFO]: BOT STARTED AS {BOT_NAME}!")
print(f"[INFO]: ASSISTANT STARTED AS {ASSNAME}!")
async def load_start():
restart_data = await clean_restart_stage()
if restart_data:
print("[INFO]: SENDING RESTART STATUS TO ZAID SERVER")
try:
await app.edit_message_text(
restart_data["chat_id"],
restart_data["message_id"],
"**Restarted the Bot Successfully.**",
)
except Exception:
pass
served_chats = []
try:
chats = await get_active_chats()
for chat in chats:
served_chats.append(int(chat["chat_id"]))
except Exception as e:
print("Error came while clearing db")
for served_chat in served_chats:
try:
await remove_active_chat(served_chat)
except Exception as e:
print("Error came while clearing db")
pass
await app.send_message(LOG_GROUP_ID, "Music Bot Started")
await client.send_message(LOG_GROUP_ID, "Assistant Of Zaid Music Started")
print("[INFO]: STARTED THE ZAID BOT AND SENDING THE INFO TO ZAID SERVER")
loop = asyncio.get_event_loop()
loop.run_until_complete(load_start())
run()
idle()
loop.close()
print("[LOG] CLOSING MUSIC BOT")