Update plugins/query.py
Browse files- plugins/query.py +55 -26
plugins/query.py
CHANGED
@@ -1,14 +1,40 @@
|
|
1 |
import asyncio, re, ast, time, math, logging, random, pyrogram, shutil, psutil
|
2 |
-
|
|
|
|
|
3 |
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, CallbackQuery, InputMediaPhoto
|
|
|
|
|
|
|
|
|
|
|
4 |
from utils import get_size, is_subscribed, get_poster, search_gagala, temp, get_settings, save_group_settings, get_shortlink, get_time, humanbytes
|
5 |
from .ExtraMods.carbon import make_carbon
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
from info import ADMINS, AUTH_CHANNEL, AUTH_USERS, CUSTOM_FILE_CAPTION, AUTH_GROUPS, P_TTI_SHOW_OFF, PICS, IMDB, PM_IMDB, SINGLE_BUTTON, PROTECT_CONTENT, \
|
7 |
SPELL_CHECK_REPLY, IMDB_TEMPLATE, IMDB_DELET_TIME, START_MESSAGE, PMFILTER, G_FILTER, BUTTON_LOCK, BUTTON_LOCK_TEXT, SHORT_URL, SHORT_API
|
8 |
|
|
|
9 |
logger = logging.getLogger(__name__)
|
10 |
logger.setLevel(logging.ERROR)
|
11 |
|
|
|
|
|
12 |
@Client.on_callback_query()
|
13 |
async def cb_handler(client: Client, query: CallbackQuery):
|
14 |
if query.data == "close_data":
|
@@ -184,7 +210,7 @@ async def cb_handler(client: Client, query: CallbackQuery):
|
|
184 |
|
185 |
elif query.data.startswith("checksub"):
|
186 |
if AUTH_CHANNEL and not await is_subscribed(client, query):
|
187 |
-
return await query.answer("I Lɪᴋᴇ Yᴏᴜʀ S
|
188 |
ident, file_id = query.data.split("#")
|
189 |
files_ = await get_file_details(file_id)
|
190 |
if not files_: return await query.answer('NO SUCH FILE EXIST....')
|
@@ -321,7 +347,7 @@ async def cb_handler(client: Client, query: CallbackQuery):
|
|
321 |
],[
|
322 |
InlineKeyboardButton(text="𝖢𝗅𝗈𝗌𝖾", callback_data="close_data")
|
323 |
]]
|
324 |
-
await query.message.edit_text("Sᴇʟᴇᴄᴛ Yᴏᴜʀ R
|
325 |
|
326 |
elif query.data == "bright":
|
327 |
await bright(client, query.message)
|
@@ -411,7 +437,7 @@ async def cb_handler(client: Client, query: CallbackQuery):
|
|
411 |
InlineKeyboardButton("Hᴇʟᴩ 🕸️", callback_data="help"),
|
412 |
InlineKeyboardButton("Aʙᴏᴜᴛ ✨", callback_data="about")
|
413 |
]]
|
414 |
-
await query.
|
415 |
|
416 |
elif query.data == "help":
|
417 |
buttons = [[
|
@@ -429,7 +455,7 @@ async def cb_handler(client: Client, query: CallbackQuery):
|
|
429 |
InlineKeyboardButton('✘ Cʟᴏꜱᴇ', 'close_data'),
|
430 |
InlineKeyboardButton('« Bᴀᴄᴋ', 'start')
|
431 |
]]
|
432 |
-
await query.
|
433 |
|
434 |
elif query.data == "about":
|
435 |
buttons= [[
|
@@ -438,7 +464,7 @@ async def cb_handler(client: Client, query: CallbackQuery):
|
|
438 |
InlineKeyboardButton('✘ Cʟᴏꜱᴇ', 'close_data'),
|
439 |
InlineKeyboardButton('« Bᴀᴄᴋ', 'start')
|
440 |
]]
|
441 |
-
await query.
|
442 |
|
443 |
elif query.data == "source":
|
444 |
buttons = [[
|
@@ -446,7 +472,7 @@ async def cb_handler(client: Client, query: CallbackQuery):
|
|
446 |
],[
|
447 |
InlineKeyboardButton('‹ Bᴀᴄᴋ', 'about')
|
448 |
]]
|
449 |
-
await query.
|
450 |
|
451 |
elif query.data == "admin":
|
452 |
buttons = [[
|
@@ -456,14 +482,10 @@ async def cb_handler(client: Client, query: CallbackQuery):
|
|
456 |
if query.from_user.id not in ADMINS:
|
457 |
return await query.answer("Sᴏʀʀʏ Tʜɪs Mᴇɴᴜ Oɴʟʏ Fᴏʀ Mʏ Aᴅᴍɪɴs ⚒️", show_alert=True)
|
458 |
await query.message.edit("Pʀᴏᴄᴇꜱꜱɪɴɢ Wᴀɪᴛ Fᴏʀ 15 ꜱᴇᴄ...")
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
await query.edit_message_media(InputMediaPhoto(stats_pic, script.ADMIN_TXT, enums.ParseMode.HTML), reply_markup=InlineKeyboardMarkup(buttons))
|
464 |
-
except Exception as e:
|
465 |
-
logger.error(f"Error processing admin panel request: {e}", exc_info=True)
|
466 |
-
await query.message.edit(f"An error occurred while processing your request. Please try again later.\nError: {str(e)}")
|
467 |
|
468 |
elif query.data == "openfilter":
|
469 |
buttons = [[
|
@@ -475,14 +497,14 @@ async def cb_handler(client: Client, query: CallbackQuery):
|
|
475 |
InlineKeyboardButton('✘ Cʟᴏꜱᴇ', 'close_data'),
|
476 |
InlineKeyboardButton('« Bᴀᴄᴋ', 'help')
|
477 |
]]
|
478 |
-
await query.
|
479 |
|
480 |
elif query.data == "autofilter":
|
481 |
buttons = [[
|
482 |
InlineKeyboardButton('✘ Cʟᴏꜱᴇ', 'close_data'),
|
483 |
InlineKeyboardButton('« Bᴀᴄᴋ', 'openfilter')
|
484 |
]]
|
485 |
-
await query.
|
486 |
|
487 |
elif query.data == "manuelfilter":
|
488 |
buttons = [[
|
@@ -491,7 +513,7 @@ async def cb_handler(client: Client, query: CallbackQuery):
|
|
491 |
InlineKeyboardButton('✘ Cʟᴏꜱᴇ', 'close_data'),
|
492 |
InlineKeyboardButton('« Bᴀᴄᴋ', 'openfilter')
|
493 |
]]
|
494 |
-
await query.
|
495 |
|
496 |
elif query.data == "globalfilter":
|
497 |
buttons = [[
|
@@ -502,42 +524,42 @@ async def cb_handler(client: Client, query: CallbackQuery):
|
|
502 |
]]
|
503 |
if query.from_user.id not in ADMINS:
|
504 |
return await query.answer("Sᴏʀʀʏ Tʜɪs Mᴇɴᴜ Oɴʟʏ Fᴏʀ Mʏ Aᴅᴍɪɴs ⚒️", show_alert=True)
|
505 |
-
await query.
|
506 |
|
507 |
elif query.data.startswith("button"):
|
508 |
buttons = [[
|
509 |
InlineKeyboardButton('✘ Cʟᴏꜱᴇ', 'close_data'),
|
510 |
InlineKeyboardButton('« Bᴀᴄᴋ', f"{'manuelfilter' if query.data == 'button' else 'globalfilter'}")
|
511 |
]]
|
512 |
-
await query.
|
513 |
|
514 |
elif query.data == "coct":
|
515 |
buttons = [[
|
516 |
InlineKeyboardButton('✘ Cʟᴏꜱᴇ', 'close_data'),
|
517 |
InlineKeyboardButton('« Bᴀᴄᴋ', 'help')
|
518 |
]]
|
519 |
-
await query.
|
520 |
|
521 |
elif query.data == "newdata":
|
522 |
buttons = [[
|
523 |
InlineKeyboardButton('✘ Cʟᴏꜱᴇ', 'close_data'),
|
524 |
InlineKeyboardButton('« Bᴀᴄᴋ', 'help')
|
525 |
]]
|
526 |
-
await query.
|
527 |
|
528 |
elif query.data == "extmod":
|
529 |
buttons = [[
|
530 |
InlineKeyboardButton('✘ Cʟᴏꜱᴇ', 'close_data'),
|
531 |
InlineKeyboardButton('« Bᴀᴄᴋ', 'help')
|
532 |
]]
|
533 |
-
await query.
|
534 |
|
535 |
elif query.data == "gpmanager":
|
536 |
buttons = [[
|
537 |
InlineKeyboardButton('✘ Cʟᴏꜱᴇ', 'close_data'),
|
538 |
InlineKeyboardButton('« Bᴀᴄᴋ', 'help')
|
539 |
]]
|
540 |
-
await query.
|
541 |
|
542 |
elif query.data == "stats":
|
543 |
buttons = [[
|
@@ -552,7 +574,7 @@ async def cb_handler(client: Client, query: CallbackQuery):
|
|
552 |
monsize = get_size(monsize)
|
553 |
free = get_size(free)
|
554 |
await query.message.edit('ʟᴏᴀᴅɪɴɢ....')
|
555 |
-
await query.
|
556 |
|
557 |
elif query.data.startswith("setgs"):
|
558 |
ident, set_type, status, grp_id = query.data.split("#")
|
@@ -576,4 +598,11 @@ async def cb_handler(client: Client, query: CallbackQuery):
|
|
576 |
],[
|
577 |
InlineKeyboardButton(f"ᴡᴇʟᴄᴏᴍᴇ ᴍᴇꜱꜱᴀɢᴇ : {'ᴏɴ' if settings['welcome'] else 'ᴏꜰꜰ'}", f'setgs#welcome#{settings["welcome"]}#{str(grp_id)}')
|
578 |
]]
|
579 |
-
await query.message.edit_reply_markup(InlineKeyboardMarkup(buttons))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import asyncio, re, ast, time, math, logging, random, pyrogram, shutil, psutil
|
2 |
+
|
3 |
+
# Pyrogram Functions
|
4 |
+
from pyrogram.errors.exceptions.bad_request_400 import MediaEmpty, PhotoInvalidDimensions, WebpageMediaEmpty
|
5 |
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, CallbackQuery, InputMediaPhoto
|
6 |
+
from pyrogram import Client, filters, enums
|
7 |
+
from pyrogram.errors import FloodWait, UserIsBlocked, MessageNotModified, PeerIdInvalid
|
8 |
+
|
9 |
+
# Helper Function
|
10 |
+
from Script import script
|
11 |
from utils import get_size, is_subscribed, get_poster, search_gagala, temp, get_settings, save_group_settings, get_shortlink, get_time, humanbytes
|
12 |
from .ExtraMods.carbon import make_carbon
|
13 |
+
|
14 |
+
# Database Function
|
15 |
+
from database.connections_mdb import active_connection, all_connections, delete_connection, if_active, make_active, make_inactive
|
16 |
+
from database.ia_filterdb import Media, get_file_details, get_search_results
|
17 |
+
from database.filters_mdb import del_all, find_filter, get_filters
|
18 |
+
from database.gfilters_mdb import find_gfilter, get_gfilters
|
19 |
+
from database.users_chats_db import db
|
20 |
+
|
21 |
+
# Image Editor Function
|
22 |
+
from image.edit_1 import bright, mix, black_white, g_blur, normal_blur, box_blur
|
23 |
+
from image.edit_2 import circle_with_bg, circle_without_bg, sticker, edge_curved, contrast, sepia_mode, pencil, cartoon
|
24 |
+
from image.edit_3 import green_border, blue_border, black_border, red_border
|
25 |
+
from image.edit_4 import rotate_90, rotate_180, rotate_270, inverted, round_sticker, removebg_white, removebg_plain, removebg_sticker
|
26 |
+
from image.edit_5 import normalglitch_1, normalglitch_2, normalglitch_3, normalglitch_4, normalglitch_5, scanlineglitch_1, scanlineglitch_2, scanlineglitch_3, scanlineglitch_4, scanlineglitch_5
|
27 |
+
|
28 |
+
# Configuration
|
29 |
from info import ADMINS, AUTH_CHANNEL, AUTH_USERS, CUSTOM_FILE_CAPTION, AUTH_GROUPS, P_TTI_SHOW_OFF, PICS, IMDB, PM_IMDB, SINGLE_BUTTON, PROTECT_CONTENT, \
|
30 |
SPELL_CHECK_REPLY, IMDB_TEMPLATE, IMDB_DELET_TIME, START_MESSAGE, PMFILTER, G_FILTER, BUTTON_LOCK, BUTTON_LOCK_TEXT, SHORT_URL, SHORT_API
|
31 |
|
32 |
+
|
33 |
logger = logging.getLogger(__name__)
|
34 |
logger.setLevel(logging.ERROR)
|
35 |
|
36 |
+
|
37 |
+
|
38 |
@Client.on_callback_query()
|
39 |
async def cb_handler(client: Client, query: CallbackQuery):
|
40 |
if query.data == "close_data":
|
|
|
210 |
|
211 |
elif query.data.startswith("checksub"):
|
212 |
if AUTH_CHANNEL and not await is_subscribed(client, query):
|
213 |
+
return await query.answer("I Lɪᴋᴇ Yᴏᴜʀ Sᴍᴀʀᴛɴᴇss, Bᴜᴛ Dᴏɴ'ᴛ Bᴇ Oᴠᴇʀsᴍᴀʀᴛ Oᴋᴀʏ 😏", show_alert=True)
|
214 |
ident, file_id = query.data.split("#")
|
215 |
files_ = await get_file_details(file_id)
|
216 |
if not files_: return await query.answer('NO SUCH FILE EXIST....')
|
|
|
347 |
],[
|
348 |
InlineKeyboardButton(text="𝖢𝗅𝗈𝗌𝖾", callback_data="close_data")
|
349 |
]]
|
350 |
+
await query.message.edit_text("Sᴇʟᴇᴄᴛ Yᴏᴜʀ Rᴇǫᴜɪʀᴇᴅ Mᴏᴅᴇ Fʀᴏᴍ Bᴇʟᴏᴡ!", reply_markup=InlineKeyboardMarkup(buttons))
|
351 |
|
352 |
elif query.data == "bright":
|
353 |
await bright(client, query.message)
|
|
|
437 |
InlineKeyboardButton("Hᴇʟᴩ 🕸️", callback_data="help"),
|
438 |
InlineKeyboardButton("Aʙᴏᴜᴛ ✨", callback_data="about")
|
439 |
]]
|
440 |
+
await query.edit_message_media(InputMediaPhoto(random.choice(PICS), START_MESSAGE.format(user=query.from_user.mention, bot=client.mention), enums.ParseMode.HTML), reply_markup=InlineKeyboardMarkup(buttons))
|
441 |
|
442 |
elif query.data == "help":
|
443 |
buttons = [[
|
|
|
455 |
InlineKeyboardButton('✘ Cʟᴏꜱᴇ', 'close_data'),
|
456 |
InlineKeyboardButton('« Bᴀᴄᴋ', 'start')
|
457 |
]]
|
458 |
+
await query.edit_message_media(InputMediaPhoto(random.choice(PICS), script.HELP_TXT.format(query.from_user.mention), enums.ParseMode.HTML), reply_markup=InlineKeyboardMarkup(buttons))
|
459 |
|
460 |
elif query.data == "about":
|
461 |
buttons= [[
|
|
|
464 |
InlineKeyboardButton('✘ Cʟᴏꜱᴇ', 'close_data'),
|
465 |
InlineKeyboardButton('« Bᴀᴄᴋ', 'start')
|
466 |
]]
|
467 |
+
await query.edit_message_media(InputMediaPhoto(random.choice(PICS), script.ABOUT_TXT.format(temp.B_NAME), enums.ParseMode.HTML), reply_markup=InlineKeyboardMarkup(buttons))
|
468 |
|
469 |
elif query.data == "source":
|
470 |
buttons = [[
|
|
|
472 |
],[
|
473 |
InlineKeyboardButton('‹ Bᴀᴄᴋ', 'about')
|
474 |
]]
|
475 |
+
await query.edit_message_media(InputMediaPhoto(random.choice(PICS), script.SOURCE_TXT, enums.ParseMode.HTML), reply_markup=InlineKeyboardMarkup(buttons))
|
476 |
|
477 |
elif query.data == "admin":
|
478 |
buttons = [[
|
|
|
482 |
if query.from_user.id not in ADMINS:
|
483 |
return await query.answer("Sᴏʀʀʏ Tʜɪs Mᴇɴᴜ Oɴʟʏ Fᴏʀ Mʏ Aᴅᴍɪɴs ⚒️", show_alert=True)
|
484 |
await query.message.edit("Pʀᴏᴄᴇꜱꜱɪɴɢ Wᴀɪᴛ Fᴏʀ 15 ꜱᴇᴄ...")
|
485 |
+
total, used, free = shutil.disk_usage(".")
|
486 |
+
stats = script.SERVER_STATS.format(get_time(time.time() - client.uptime), psutil.cpu_percent(), psutil.virtual_memory().percent, humanbytes(total), humanbytes(used), psutil.disk_usage('/').percent, humanbytes(free))
|
487 |
+
stats_pic = await make_carbon(stats, True)
|
488 |
+
await query.edit_message_media(InputMediaPhoto(stats_pic, script.ADMIN_TXT, enums.ParseMode.HTML), reply_markup=InlineKeyboardMarkup(buttons))
|
|
|
|
|
|
|
|
|
489 |
|
490 |
elif query.data == "openfilter":
|
491 |
buttons = [[
|
|
|
497 |
InlineKeyboardButton('✘ Cʟᴏꜱᴇ', 'close_data'),
|
498 |
InlineKeyboardButton('« Bᴀᴄᴋ', 'help')
|
499 |
]]
|
500 |
+
await query.edit_message_media(InputMediaPhoto(random.choice(PICS), script.FILTER_TXT, enums.ParseMode.HTML), reply_markup=InlineKeyboardMarkup(buttons))
|
501 |
|
502 |
elif query.data == "autofilter":
|
503 |
buttons = [[
|
504 |
InlineKeyboardButton('✘ Cʟᴏꜱᴇ', 'close_data'),
|
505 |
InlineKeyboardButton('« Bᴀᴄᴋ', 'openfilter')
|
506 |
]]
|
507 |
+
await query.edit_message_media(InputMediaPhoto(random.choice(PICS), script.AUTOFILTER_TXT, enums.ParseMode.HTML), reply_markup=InlineKeyboardMarkup(buttons))
|
508 |
|
509 |
elif query.data == "manuelfilter":
|
510 |
buttons = [[
|
|
|
513 |
InlineKeyboardButton('✘ Cʟᴏꜱᴇ', 'close_data'),
|
514 |
InlineKeyboardButton('« Bᴀᴄᴋ', 'openfilter')
|
515 |
]]
|
516 |
+
await query.edit_message_media(InputMediaPhoto(random.choice(PICS), script.MANUELFILTER_TXT, enums.ParseMode.HTML), reply_markup=InlineKeyboardMarkup(buttons))
|
517 |
|
518 |
elif query.data == "globalfilter":
|
519 |
buttons = [[
|
|
|
524 |
]]
|
525 |
if query.from_user.id not in ADMINS:
|
526 |
return await query.answer("Sᴏʀʀʏ Tʜɪs Mᴇɴᴜ Oɴʟʏ Fᴏʀ Mʏ Aᴅᴍɪɴs ⚒️", show_alert=True)
|
527 |
+
await query.edit_message_media(InputMediaPhoto(random.choice(PICS), script.GLOBALFILTER_TXT, enums.ParseMode.HTML), reply_markup=InlineKeyboardMarkup(buttons))
|
528 |
|
529 |
elif query.data.startswith("button"):
|
530 |
buttons = [[
|
531 |
InlineKeyboardButton('✘ Cʟᴏꜱᴇ', 'close_data'),
|
532 |
InlineKeyboardButton('« Bᴀᴄᴋ', f"{'manuelfilter' if query.data == 'button' else 'globalfilter'}")
|
533 |
]]
|
534 |
+
await query.edit_message_media(InputMediaPhoto(random.choice(PICS), script.BUTTON_TXT, enums.ParseMode.HTML), reply_markup=InlineKeyboardMarkup(buttons))
|
535 |
|
536 |
elif query.data == "coct":
|
537 |
buttons = [[
|
538 |
InlineKeyboardButton('✘ Cʟᴏꜱᴇ', 'close_data'),
|
539 |
InlineKeyboardButton('« Bᴀᴄᴋ', 'help')
|
540 |
]]
|
541 |
+
await query.edit_message_media(InputMediaPhoto(random.choice(PICS), script.CONNECTION_TXT, enums.ParseMode.HTML), reply_markup=InlineKeyboardMarkup(buttons))
|
542 |
|
543 |
elif query.data == "newdata":
|
544 |
buttons = [[
|
545 |
InlineKeyboardButton('✘ Cʟᴏꜱᴇ', 'close_data'),
|
546 |
InlineKeyboardButton('« Bᴀᴄᴋ', 'help')
|
547 |
]]
|
548 |
+
await query.edit_message_media(InputMediaPhoto(random.choice(PICS), script.FILE_TXT, enums.ParseMode.HTML), reply_markup=InlineKeyboardMarkup(buttons))
|
549 |
|
550 |
elif query.data == "extmod":
|
551 |
buttons = [[
|
552 |
InlineKeyboardButton('✘ Cʟᴏꜱᴇ', 'close_data'),
|
553 |
InlineKeyboardButton('« Bᴀᴄᴋ', 'help')
|
554 |
]]
|
555 |
+
await query.edit_message_media(InputMediaPhoto(random.choice(PICS), script.EXTRAMOD_TXT, enums.ParseMode.HTML), reply_markup=InlineKeyboardMarkup(buttons))
|
556 |
|
557 |
elif query.data == "gpmanager":
|
558 |
buttons = [[
|
559 |
InlineKeyboardButton('✘ Cʟᴏꜱᴇ', 'close_data'),
|
560 |
InlineKeyboardButton('« Bᴀᴄᴋ', 'help')
|
561 |
]]
|
562 |
+
await query.edit_message_media(InputMediaPhoto(random.choice(PICS), script.GROUPMANAGER_TXT, enums.ParseMode.HTML), reply_markup=InlineKeyboardMarkup(buttons))
|
563 |
|
564 |
elif query.data == "stats":
|
565 |
buttons = [[
|
|
|
574 |
monsize = get_size(monsize)
|
575 |
free = get_size(free)
|
576 |
await query.message.edit('ʟᴏᴀᴅɪɴɢ....')
|
577 |
+
await query.edit_message_media(InputMediaPhoto(random.choice(PICS), script.STATUS_TXT.format(total, users, chats, monsize, free), enums.ParseMode.HTML), reply_markup=InlineKeyboardMarkup(buttons))
|
578 |
|
579 |
elif query.data.startswith("setgs"):
|
580 |
ident, set_type, status, grp_id = query.data.split("#")
|
|
|
598 |
],[
|
599 |
InlineKeyboardButton(f"ᴡᴇʟᴄᴏᴍᴇ ᴍᴇꜱꜱᴀɢᴇ : {'ᴏɴ' if settings['welcome'] else 'ᴏꜰꜰ'}", f'setgs#welcome#{settings["welcome"]}#{str(grp_id)}')
|
600 |
]]
|
601 |
+
await query.message.edit_reply_markup(InlineKeyboardMarkup(buttons))
|
602 |
+
|
603 |
+
|
604 |
+
|
605 |
+
|
606 |
+
|
607 |
+
|
608 |
+
|