forked from sultansq/kiu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
admins.py
219 lines (203 loc) · 7.85 KB
/
admins.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
#
# Copyright (C) 2021-2022 by TeamYukki@Github, < https://github.com/TeamYukki >.
#
# This file is part of < https://github.com/TeamYukki/YukkiMusicBot > project,
# and is released under the "GNU v3.0 License Agreement".
# Please see < https://github.com/TeamYukki/YukkiMusicBot/blob/master/LICENSE >
#
# All rights reserved.
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
from config import adminlist
from strings import get_string
from AnonX import app
from AnonX.misc import SUDOERS
from AnonX.utils.database import (get_authuser_names, get_cmode,
get_lang, is_active_chat,
is_commanddelete_on,
is_maintenance,
is_nonadmin_chat)
from ..formatters import int_to_alpha
def AdminRightsCheck(mystic):
async def wrapper(client, message):
if await is_maintenance() is False:
if message.from_user.id not in SUDOERS:
return await message.reply_text(
"Bot is under maintenance. Please wait for some time..."
)
if await is_commanddelete_on(message.chat.id):
try:
await message.delete()
except:
pass
try:
language = await get_lang(message.chat.id)
_ = get_string(language)
except:
_ = get_string("en")
if message.sender_chat:
upl = InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text="How to Fix this? ",
callback_data="AnonymousAdmin",
),
]
]
)
return await message.reply_text(
_["general_4"], reply_markup=upl
)
if message.command[0][0] == "c" or message.command[0][0] == "#":
chat_id = await get_cmode(message.chat.id)
if chat_id is None:
return await message.reply_text(_["setting_12"])
try:
await app.get_chat(chat_id)
except:
return await message.reply_text(_["cplay_4"])
else:
chat_id = message.chat.id
if not await is_active_chat(chat_id):
return await message.reply_text(_["general_6"])
is_non_admin = await is_nonadmin_chat(message.chat.id)
if not is_non_admin:
if message.from_user.id not in SUDOERS:
admins = adminlist.get(message.chat.id)
if not admins:
return await message.reply_text(_["admin_18"])
else:
if message.from_user.id not in admins:
return await message.reply_text(_["admin_19"])
return await mystic(client, message, _, chat_id)
return wrapper
def AdminRightsCheckCB(mystic):
async def wrapper(client, message):
if await is_maintenance() is False:
if message.from_user.id not in SUDOERS:
return await message.reply_text(
"Bot is under maintenance. Please wait for some time..."
)
if await is_commanddelete_on(message.chat.id):
try:
await message.delete()
except:
pass
try:
language = await get_lang(message.chat.id)
_ = get_string(language)
except:
_ = get_string("en")
if message.sender_chat:
print("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@")
print(message)
chat_id = message.chat.id
if chat_id is None:
return await message.reply_text(_["setting_12"])
try:
await app.get_chat(chat_id)
except:
return await message.reply_text(_["cplay_4"])
if message.command[0][0] == "c" or message.command[0][0] == "#":
chat_id = await get_cmode(message.chat.id)
if chat_id is None:
return await message.reply_text(_["setting_12"])
try:
await app.get_chat(chat_id)
except:
return await message.reply_text(_["cplay_4"])
else:
chat_id = message.chat.id
if not await is_active_chat(chat_id):
return await message.reply_text(_["general_6"])
return await mystic(client, message, _, chat_id)
return wrapper
def AdminActual(mystic):
async def wrapper(client, message):
if await is_maintenance() is False:
if message.from_user.id not in SUDOERS:
return await message.reply_text(
"Bot is under maintenance. Please wait for some time..."
)
if await is_commanddelete_on(message.chat.id):
try:
await message.delete()
except:
pass
try:
language = await get_lang(message.chat.id)
_ = get_string(language)
except:
_ = get_string("en")
# if message.sender_chat:
# upl = InlineKeyboardMarkup(
# [
# [
# InlineKeyboardButton(
# text="How to Fix this? ",
# callback_data="AnonymousAdmin",
# ),
# ]
# ]
# )
# return await message.reply_text(
# _["general_4"], reply_markup=upl
# )
if not message.sender_chat:
if message.from_user.id not in SUDOERS:
try:
member = await app.get_chat_member(
message.chat.id, message.from_user.id
)
except:
return
if not member.can_manage_voice_chats:
return await message.reply(_["general_5"])
return await mystic(client, message, _)
return wrapper
def ActualAdminCB(mystic):
async def wrapper(client, CallbackQuery):
if await is_maintenance() is False:
if CallbackQuery.from_user.id not in SUDOERS:
return await CallbackQuery.answer(
"Bot is under maintenance. Please wait for some time...",
show_alert=True,
)
try:
language = await get_lang(CallbackQuery.message.chat.id)
_ = get_string(language)
except:
_ = get_string("en")
if CallbackQuery.message.chat.type == "private":
return await mystic(client, CallbackQuery, _)
is_non_admin = await is_nonadmin_chat(
CallbackQuery.message.chat.id
)
if not is_non_admin:
try:
a = await app.get_chat_member(
CallbackQuery.message.chat.id,
CallbackQuery.from_user.id,
)
except:
return await CallbackQuery.answer(
_["general_5"], show_alert=True
)
if not a.can_manage_voice_chats:
if CallbackQuery.from_user.id not in SUDOERS:
token = await int_to_alpha(
CallbackQuery.from_user.id
)
_check = await get_authuser_names(
CallbackQuery.from_user.id
)
if token not in _check:
try:
return await CallbackQuery.answer(
_["general_5"],
show_alert=True,
)
except:
return
return await mystic(client, CallbackQuery, _)
return wrapper