Update plugins/query.py
Browse files- plugins/query.py +5 -50
plugins/query.py
CHANGED
@@ -598,55 +598,9 @@ async def cb_handler(client: Client, query: CallbackQuery):
|
|
598 |
total, used, free = shutil.disk_usage(".")
|
599 |
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))
|
600 |
stats_pic = await make_carbon(stats, True)
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
logger.error(f"Error processing admin panel callback for user {query.from_user.id}: {e}")
|
605 |
-
await query.message.edit_text("An error occurred while processing your request. Please try again later.")
|
606 |
-
|
607 |
-
elif query.data == "openfilter":
|
608 |
-
buttons = [[
|
609 |
-
InlineKeyboardButton('AᴜᴛᴏFɪʟᴛᴇʀ', 'autofilter'),
|
610 |
-
InlineKeyboardButton('MᴀɴᴜᴀʟFɪʟᴛᴇʀ', 'manuelfilter')
|
611 |
-
],[
|
612 |
-
InlineKeyboardButton('GʟᴏʙᴀʟFɪʟᴛᴇʀ', 'globalfilter')
|
613 |
-
],[
|
614 |
-
InlineKeyboardButton('✘ Cʟᴏꜱᴇ', 'close_data'),
|
615 |
-
InlineKeyboardButton('« Bᴀᴄᴋ', 'help')
|
616 |
-
]]
|
617 |
-
await query.edit_message_media(InputMediaPhoto(random.choice(PICS), script.FILTER_TXT, enums.ParseMode.HTML), reply_markup=InlineKeyboardMarkup(buttons))
|
618 |
-
|
619 |
-
elif query.data == "autofilter":
|
620 |
-
buttons = [[
|
621 |
-
InlineKeyboardButton('✘ Cʟᴏꜱᴇ', 'close_data'),
|
622 |
-
InlineKeyboardButton('« Bᴀᴄᴋ', 'openfilter')
|
623 |
-
]]
|
624 |
-
await query.edit_message_media(InputMediaPhoto(random.choice(PICS), script.AUTOFILTER_TXT, enums.ParseMode.HTML), reply_markup=InlineKeyboardMarkup(buttons))
|
625 |
-
|
626 |
-
elif query.data == "manuelfilter":
|
627 |
-
buttons = [[
|
628 |
-
InlineKeyboardButton('Bᴜᴛᴛᴏɴ Fᴏʀᴍᴀᴛ', 'button')
|
629 |
-
],[
|
630 |
-
InlineKeyboardButton('✘ Cʟᴏꜱᴇ', 'close_data'),
|
631 |
-
InlineKeyboardButton('« Bᴀᴄᴋ', 'openfilter')
|
632 |
-
]]
|
633 |
-
await query.edit_message_media(InputMediaPhoto(random.choice(PICS), script.MANUELFILTER_TXT, enums.ParseMode.HTML), reply_markup=InlineKeyboardMarkup(buttons))
|
634 |
-
|
635 |
-
elif query.data == "globalfilter":
|
636 |
-
buttons = [[
|
637 |
-
InlineKeyboardButton('Bᴜᴛᴛᴏɴ Fᴏʀᴍᴀᴛ', 'buttong')
|
638 |
-
],[
|
639 |
-
InlineKeyboardButton('✘ Cʟᴏꜱᴇ', 'close_data'),
|
640 |
-
InlineKeyboardButton('« Bᴀᴄᴋ', 'openfilter')
|
641 |
-
]]
|
642 |
-
if query.from_user.id not in ADMINS:
|
643 |
-
logger.debug(f"User {query.from_user.id} is not an admin")
|
644 |
-
return await query.answer("Sᴏʀʀʏ Tʜɪs Mᴇɴᴜ Oɴʟʏ Fᴏʀ Mʏ Aᴅᴍɪɴs ⚒️", show_alert=True)
|
645 |
-
await query.message.edit_text("Pʀᴏᴄᴇꜱꜱɪɴɢ...")
|
646 |
-
try:
|
647 |
-
total, used, free = shutil.disk_usage(".")
|
648 |
-
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))
|
649 |
-
stats_pic = await make_carbon(stats, True)
|
650 |
await query.edit_message_media(InputMediaPhoto(stats_pic, script.ADMIN_TXT, enums.ParseMode.HTML), reply_markup=InlineKeyboardMarkup(buttons))
|
651 |
logger.debug(f"Admin panel processed successfully for user {query.from_user.id}")
|
652 |
except Exception as e:
|
@@ -777,4 +731,5 @@ async def cb_handler(client: Client, query: CallbackQuery):
|
|
777 |
]]
|
778 |
await query.message.edit_reply_markup(InlineKeyboardMarkup(buttons))
|
779 |
logger.debug(f"Settings updated for user {query.from_user.id} in group {grp_id}")
|
780 |
-
|
|
|
|
598 |
total, used, free = shutil.disk_usage(".")
|
599 |
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))
|
600 |
stats_pic = await make_carbon(stats, True)
|
601 |
+
if isinstance(stats_pic, str):
|
602 |
+
logger.error(f"make_carbon returned a string instead of an image: {stats_pic}")
|
603 |
+
return await query.message.edit_text("An error occurred while generating the stats image. Please try again later.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
604 |
await query.edit_message_media(InputMediaPhoto(stats_pic, script.ADMIN_TXT, enums.ParseMode.HTML), reply_markup=InlineKeyboardMarkup(buttons))
|
605 |
logger.debug(f"Admin panel processed successfully for user {query.from_user.id}")
|
606 |
except Exception as e:
|
|
|
731 |
]]
|
732 |
await query.message.edit_reply_markup(InlineKeyboardMarkup(buttons))
|
733 |
logger.debug(f"Settings updated for user {query.from_user.id} in group {grp_id}")
|
734 |
+
|
735 |
+
|