forked from sultansq/kiu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reload.py
133 lines (121 loc) · 4.34 KB
/
reload.py
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import asyncio
from pyrogram import filters
from pyrogram.types import CallbackQuery, Message
from strings.filters import command
from config import BANNED_USERS, MUSIC_BOT_NAME, adminlist, lyrical
from strings import get_command
from AnonX import app
from AnonX.core.call import Anon
from AnonX.misc import db
from AnonX.utils.database import get_authuser_names, get_cmode
from AnonX.utils.decorators import (ActualAdminCB, AdminActual,
language)
from AnonX.utils.formatters import alpha_to_int
### Multi-Lang Commands
RELOAD_COMMAND = get_command("RELOAD_COMMAND")
RESTART_COMMAND = get_command("RESTART_COMMAND")
@app.on_message(
command(RELOAD_COMMAND)
& filters.group
& ~BANNED_USERS
)
@language
async def reload_admin_cache(client, message: Message, _):
try:
chat_id = message.chat.id
admins = await app.get_chat_members(
chat_id, filter="administrators"
)
authusers = await get_authuser_names(chat_id)
adminlist[chat_id] = []
for user in admins:
if user.can_manage_voice_chats:
adminlist[chat_id].append(user.user.id)
for user in authusers:
user_id = await alpha_to_int(user)
adminlist[chat_id].append(user_id)
await message.reply_text(_["admin_20"])
except:
await message.reply_text(
"ғᴀɪʟᴇᴅ ᴛᴏ ʀᴇғʀᴇsʜ ᴀᴅᴍɪɴs ʟɪsᴛ, ᴍᴀᴋᴇ sᴜʀᴇ ʏᴏᴜ ᴩʀᴏᴍᴏᴛᴇᴅ ᴛʜᴇ ʙᴏᴛ."
)
@app.on_message(
command(RESTART_COMMAND)
& filters.group
& ~BANNED_USERS
)
@AdminActual
async def restartbot(client, message: Message, _):
mystic = await message.reply_text(
f"ᴩʟᴇᴀsᴇ ᴡᴀɪᴛ ʀᴇʙᴏᴏᴛɪɴɢ {MUSIC_BOT_NAME} ғᴏʀ ʏᴏᴜʀ ᴄʜᴀᴛ."
)
await asyncio.sleep(1)
try:
db[message.chat.id] = []
await Anon.stop_stream(message.chat.id)
except:
pass
chat_id = await get_cmode(message.chat.id)
if chat_id:
try:
await app.get_chat(chat_id)
except:
pass
try:
db[chat_id] = []
await Anon.stop_stream(chat_id)
except:
pass
return await mystic.edit_text(
f"sᴜᴄᴄᴇssғᴜʟʟʏ ʀᴇʙᴏᴏᴛᴇᴅ {MUSIC_BOT_NAME} ғᴏʀ ʏᴏᴜʀ ᴄʜᴀᴛ, ɴᴏᴡ ʏᴏᴜ ᴄᴀɴ sᴛᴀʀᴛ ᴩʟᴀʏɪɴɢ ᴀɢᴀɪɴ..."
)
@app.on_callback_query(filters.regex("close") & ~BANNED_USERS)
async def close_menu(_, CallbackQuery):
try:
await CallbackQuery.message.delete()
await CallbackQuery.answer()
except:
return
@app.on_callback_query(filters.regex("close") & ~BANNED_USERS)
async def close_menu(_, CallbackQuery):
try:
await CallbackQuery.message.delete()
await CallbackQuery.answer()
except:
return
@app.on_callback_query(
filters.regex("stop_downloading") & ~BANNED_USERS
)
@ActualAdminCB
async def stop_download(client, CallbackQuery: CallbackQuery, _):
message_id = CallbackQuery.message.message_id
task = lyrical.get(message_id)
if not task:
return await CallbackQuery.answer(
"ᴅᴏᴡɴʟᴏᴀᴅ ᴀʟʀᴇᴀᴅʏ ᴄᴏᴍᴩʟᴇᴛᴇᴅ.", show_alert=True
)
if task.done() or task.cancelled():
return await CallbackQuery.answer(
"ᴅᴏᴡɴʟᴏᴀᴅɪɴɢ ᴀʟʀᴇᴀᴅʏ ᴄᴏᴍᴩʟᴇᴛᴇᴅ ᴏʀ ᴄᴀɴᴄᴇʟʟᴇᴅ.",
show_alert=True,
)
if not task.done():
try:
task.cancel()
try:
lyrical.pop(message_id)
except:
pass
await CallbackQuery.answer(
"ᴅᴏᴡɴʟᴏᴀᴅɪɢ ᴄᴀɴᴄᴇʟʟᴇᴅ.", show_alert=True
)
return await CallbackQuery.edit_message_text(
f"ᴅᴏᴡɴʟᴏᴀᴅɪɴɢ ᴩʀᴏᴄᴇss ᴄᴀɴᴄᴇʟʟᴇᴅ ʙʏ {CallbackQuery.from_user.mention}"
)
except:
return await CallbackQuery.answer(
"ғᴀɪʟᴇᴅ ᴛᴏ ᴄᴀɴᴄᴇʟ ᴅᴏᴡɴʟᴏᴀᴅɪɴɢ...", show_alert=True
)
await CallbackQuery.answer(
"ғᴀɪʟᴇᴅ ᴛᴏ ʀᴇᴄᴏɢɴɪᴢᴇ ᴛʜᴇ ᴏɴɢᴏɪɴɢ ᴛᴀsᴋ.", show_alert=True
)