File size: 13,165 Bytes
a8e9b84 |
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 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 |
from pyrogram import filters
from pyrogram.enums import ChatType
from pyrogram.errors import MessageNotModified
from pyrogram.types import (
CallbackQuery,
InlineKeyboardButton,
InlineKeyboardMarkup,
Message,
)
from DragMusic import app
from DragMusic.utils.database import (
add_nonadmin_chat,
get_authuser,
get_authuser_names,
get_playmode,
get_playtype,
get_upvote_count,
is_nonadmin_chat,
is_skipmode,
remove_nonadmin_chat,
set_playmode,
set_playtype,
set_upvotes,
skip_off,
skip_on,
)
from DragMusic.utils.decorators.admins import ActualAdminCB
from DragMusic.utils.decorators.language import language, languageCB
from DragMusic.utils.inline.settings import (
auth_users_markup,
playmode_users_markup,
setting_markup,
vote_mode_markup,
)
from DragMusic.utils.inline.start import private_panel
from config import BANNED_USERS, OWNER_ID
@app.on_message(
filters.command(["settings", "setting"]) & filters.group & ~BANNED_USERS
)
@language
async def settings_mar(client, message: Message, _):
buttons = setting_markup(_)
await message.reply_text(
_["setting_1"].format(app.mention, message.chat.id, message.chat.title),
reply_markup=InlineKeyboardMarkup(buttons),
)
@app.on_callback_query(filters.regex("settings_helper") & ~BANNED_USERS)
@languageCB
async def settings_cb(client, CallbackQuery, _):
try:
await CallbackQuery.answer(_["set_cb_5"])
except:
pass
buttons = setting_markup(_)
return await CallbackQuery.edit_message_text(
_["setting_1"].format(
app.mention,
CallbackQuery.message.chat.id,
CallbackQuery.message.chat.title,
),
reply_markup=InlineKeyboardMarkup(buttons),
)
@app.on_callback_query(filters.regex("settingsback_helper") & ~BANNED_USERS)
@languageCB
async def settings_back_markup(client, CallbackQuery: CallbackQuery, _):
try:
await CallbackQuery.answer()
except:
pass
if CallbackQuery.message.chat.type == ChatType.PRIVATE:
await app.resolve_peer(OWNER_ID)
OWNER = OWNER_ID
buttons = private_panel(_)
return await CallbackQuery.edit_message_text(
_["start_2"].format(CallbackQuery.from_user.mention, app.mention),
reply_markup=InlineKeyboardMarkup(buttons),
)
else:
buttons = setting_markup(_)
return await CallbackQuery.edit_message_reply_markup(
reply_markup=InlineKeyboardMarkup(buttons)
)
@app.on_callback_query(
filters.regex(
pattern=r"^(SEARCHANSWER|PLAYMODEANSWER|PLAYTYPEANSWER|AUTHANSWER|ANSWERVOMODE|VOTEANSWER|PM|AU|VM)$"
)
& ~BANNED_USERS
)
@languageCB
async def without_Admin_rights(client, CallbackQuery, _):
command = CallbackQuery.matches[0].group(1)
if command == "SEARCHANSWER":
try:
return await CallbackQuery.answer(_["setting_2"], show_alert=True)
except:
return
if command == "PLAYMODEANSWER":
try:
return await CallbackQuery.answer(_["setting_5"], show_alert=True)
except:
return
if command == "PLAYTYPEANSWER":
try:
return await CallbackQuery.answer(_["setting_6"], show_alert=True)
except:
return
if command == "AUTHANSWER":
try:
return await CallbackQuery.answer(_["setting_3"], show_alert=True)
except:
return
if command == "VOTEANSWER":
try:
return await CallbackQuery.answer(
_["setting_8"],
show_alert=True,
)
except:
return
if command == "ANSWERVOMODE":
current = await get_upvote_count(CallbackQuery.message.chat.id)
try:
return await CallbackQuery.answer(
_["setting_9"].format(current),
show_alert=True,
)
except:
return
if command == "PM":
try:
await CallbackQuery.answer(_["set_cb_2"], show_alert=True)
except:
pass
playmode = await get_playmode(CallbackQuery.message.chat.id)
if playmode == "Direct":
Direct = True
else:
Direct = None
is_non_admin = await is_nonadmin_chat(CallbackQuery.message.chat.id)
if not is_non_admin:
Group = True
else:
Group = None
playty = await get_playtype(CallbackQuery.message.chat.id)
if playty == "Everyone":
Playtype = None
else:
Playtype = True
buttons = playmode_users_markup(_, Direct, Group, Playtype)
if command == "AU":
try:
await CallbackQuery.answer(_["set_cb_1"], show_alert=True)
except:
pass
is_non_admin = await is_nonadmin_chat(CallbackQuery.message.chat.id)
if not is_non_admin:
buttons = auth_users_markup(_, True)
else:
buttons = auth_users_markup(_)
if command == "VM":
mode = await is_skipmode(CallbackQuery.message.chat.id)
current = await get_upvote_count(CallbackQuery.message.chat.id)
buttons = vote_mode_markup(_, current, mode)
try:
return await CallbackQuery.edit_message_reply_markup(
reply_markup=InlineKeyboardMarkup(buttons)
)
except MessageNotModified:
return
@app.on_callback_query(filters.regex("FERRARIUDTI") & ~BANNED_USERS)
@ActualAdminCB
async def addition(client, CallbackQuery, _):
callback_data = CallbackQuery.data.strip()
mode = callback_data.split(None, 1)[1]
if not await is_skipmode(CallbackQuery.message.chat.id):
return await CallbackQuery.answer(_["setting_10"], show_alert=True)
current = await get_upvote_count(CallbackQuery.message.chat.id)
if mode == "M":
final = current - 2
print(final)
if final == 0:
return await CallbackQuery.answer(
_["setting_11"],
show_alert=True,
)
if final <= 2:
final = 2
await set_upvotes(CallbackQuery.message.chat.id, final)
else:
final = current + 2
print(final)
if final == 17:
return await CallbackQuery.answer(
_["setting_12"],
show_alert=True,
)
if final >= 15:
final = 15
await set_upvotes(CallbackQuery.message.chat.id, final)
buttons = vote_mode_markup(_, final, True)
try:
return await CallbackQuery.edit_message_reply_markup(
reply_markup=InlineKeyboardMarkup(buttons)
)
except MessageNotModified:
return
@app.on_callback_query(
filters.regex(pattern=r"^(MODECHANGE|CHANNELMODECHANGE|PLAYTYPECHANGE)$")
& ~BANNED_USERS
)
@ActualAdminCB
async def playmode_ans(client, CallbackQuery, _):
command = CallbackQuery.matches[0].group(1)
if command == "CHANNELMODECHANGE":
is_non_admin = await is_nonadmin_chat(CallbackQuery.message.chat.id)
if not is_non_admin:
await add_nonadmin_chat(CallbackQuery.message.chat.id)
Group = None
else:
await remove_nonadmin_chat(CallbackQuery.message.chat.id)
Group = True
playmode = await get_playmode(CallbackQuery.message.chat.id)
if playmode == "Direct":
Direct = True
else:
Direct = None
playty = await get_playtype(CallbackQuery.message.chat.id)
if playty == "Everyone":
Playtype = None
else:
Playtype = True
buttons = playmode_users_markup(_, Direct, Group, Playtype)
if command == "MODECHANGE":
try:
await CallbackQuery.answer(_["set_cb_3"], show_alert=True)
except:
pass
playmode = await get_playmode(CallbackQuery.message.chat.id)
if playmode == "Direct":
await set_playmode(CallbackQuery.message.chat.id, "Inline")
Direct = None
else:
await set_playmode(CallbackQuery.message.chat.id, "Direct")
Direct = True
is_non_admin = await is_nonadmin_chat(CallbackQuery.message.chat.id)
if not is_non_admin:
Group = True
else:
Group = None
playty = await get_playtype(CallbackQuery.message.chat.id)
if playty == "Everyone":
Playtype = False
else:
Playtype = True
buttons = playmode_users_markup(_, Direct, Group, Playtype)
if command == "PLAYTYPECHANGE":
try:
await CallbackQuery.answer(_["set_cb_3"], show_alert=True)
except:
pass
playty = await get_playtype(CallbackQuery.message.chat.id)
if playty == "Everyone":
await set_playtype(CallbackQuery.message.chat.id, "Admin")
Playtype = False
else:
await set_playtype(CallbackQuery.message.chat.id, "Everyone")
Playtype = True
playmode = await get_playmode(CallbackQuery.message.chat.id)
if playmode == "Direct":
Direct = True
else:
Direct = None
is_non_admin = await is_nonadmin_chat(CallbackQuery.message.chat.id)
if not is_non_admin:
Group = True
else:
Group = None
buttons = playmode_users_markup(_, Direct, Group, Playtype)
try:
return await CallbackQuery.edit_message_reply_markup(
reply_markup=InlineKeyboardMarkup(buttons)
)
except MessageNotModified:
return
@app.on_callback_query(filters.regex(pattern=r"^(AUTH|AUTHLIST)$") & ~BANNED_USERS)
@ActualAdminCB
async def authusers_mar(client, CallbackQuery, _):
command = CallbackQuery.matches[0].group(1)
if command == "AUTHLIST":
_authusers = await get_authuser_names(CallbackQuery.message.chat.id)
if not _authusers:
try:
return await CallbackQuery.answer(_["setting_4"], show_alert=True)
except:
return
else:
try:
await CallbackQuery.answer(_["set_cb_4"], show_alert=True)
except:
pass
j = 0
await CallbackQuery.edit_message_text(_["auth_6"])
msg = _["auth_7"].format(CallbackQuery.message.chat.title)
for note in _authusers:
_note = await get_authuser(CallbackQuery.message.chat.id, note)
user_id = _note["auth_user_id"]
admin_id = _note["admin_id"]
admin_name = _note["admin_name"]
try:
user = await app.get_users(user_id)
user = user.first_name
j += 1
except:
continue
msg += f"{j}➤ {user}[<code>{user_id}</code>]\n"
msg += f" {_['auth_8']} {admin_name}[<code>{admin_id}</code>]\n\n"
upl = InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
text=_["BACK_BUTTON"], callback_data=f"AU"
),
InlineKeyboardButton(
text=_["CLOSE_BUTTON"],
callback_data=f"close",
),
]
]
)
try:
return await CallbackQuery.edit_message_text(msg, reply_markup=upl)
except MessageNotModified:
return
try:
await CallbackQuery.answer(_["set_cb_3"], show_alert=True)
except:
pass
if command == "AUTH":
is_non_admin = await is_nonadmin_chat(CallbackQuery.message.chat.id)
if not is_non_admin:
await add_nonadmin_chat(CallbackQuery.message.chat.id)
buttons = auth_users_markup(_)
else:
await remove_nonadmin_chat(CallbackQuery.message.chat.id)
buttons = auth_users_markup(_, True)
try:
return await CallbackQuery.edit_message_reply_markup(
reply_markup=InlineKeyboardMarkup(buttons)
)
except MessageNotModified:
return
@app.on_callback_query(filters.regex("VOMODECHANGE") & ~BANNED_USERS)
@ActualAdminCB
async def vote_change(client, CallbackQuery, _):
command = CallbackQuery.matches[0].group(1)
try:
await CallbackQuery.answer(_["set_cb_3"], show_alert=True)
except:
pass
mod = None
if await is_skipmode(CallbackQuery.message.chat.id):
await skip_off(CallbackQuery.message.chat.id)
else:
mod = True
await skip_on(CallbackQuery.message.chat.id)
current = await get_upvote_count(CallbackQuery.message.chat.id)
buttons = vote_mode_markup(_, current, mod)
try:
return await CallbackQuery.edit_message_reply_markup(
reply_markup=InlineKeyboardMarkup(buttons)
)
except MessageNotModified:
return
|