File size: 44,506 Bytes
bc96bf6
e831922
 
 
5684062
e831922
 
 
 
 
bc96bf6
 
e831922
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bc96bf6
 
 
 
aadc025
e831922
bc96bf6
 
aadc025
bc96bf6
aadc025
bc96bf6
 
 
 
 
 
aadc025
bc96bf6
 
 
 
 
 
aadc025
 
bc96bf6
 
aadc025
bc96bf6
 
 
 
aadc025
 
 
bc96bf6
aadc025
 
 
 
 
 
bc96bf6
 
 
 
 
aadc025
bc96bf6
 
 
 
 
 
aadc025
bc96bf6
 
 
aadc025
 
 
bc96bf6
 
 
 
aadc025
 
 
 
 
 
bc96bf6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
aadc025
 
 
 
 
 
bc96bf6
aadc025
 
 
 
 
 
 
 
 
 
 
bc96bf6
 
 
aadc025
 
 
 
 
 
bc96bf6
aadc025
 
 
 
 
 
 
 
 
 
 
bc96bf6
 
 
 
aadc025
 
 
 
 
 
 
 
 
 
 
bc96bf6
 
 
aadc025
 
 
 
 
bc96bf6
 
 
 
 
 
 
 
 
 
aadc025
 
 
 
 
 
bc96bf6
 
 
 
 
aadc025
 
 
 
 
 
 
 
 
 
bc96bf6
 
 
 
aadc025
 
 
 
 
 
 
 
 
 
bc96bf6
 
 
aadc025
 
 
 
 
 
 
 
bc96bf6
 
 
aadc025
bc96bf6
aadc025
 
 
 
bc96bf6
 
aadc025
bc96bf6
 
aadc025
bc96bf6
 
aadc025
 
bc96bf6
 
 
 
 
aadc025
bc96bf6
aadc025
 
 
 
 
 
 
 
bc96bf6
 
 
aadc025
bc96bf6
 
aadc025
 
 
 
bc96bf6
 
aadc025
bc96bf6
 
aadc025
bc96bf6
 
aadc025
bc96bf6
 
 
aadc025
bc96bf6
 
aadc025
bc96bf6
 
aadc025
bc96bf6
 
 
 
aadc025
 
bc96bf6
aadc025
 
 
 
 
 
 
 
bc96bf6
 
 
aadc025
bc96bf6
aadc025
 
 
 
 
 
 
 
 
 
 
 
 
 
bc96bf6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
aadc025
bc96bf6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
aadc025
bc96bf6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
aadc025
bc96bf6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e831922
bc96bf6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
aadc025
 
 
 
 
bc96bf6
 
 
 
 
 
 
 
 
 
 
e831922
bc96bf6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e831922
bc96bf6
 
 
 
 
 
 
 
e831922
bc96bf6
 
 
 
 
 
 
e831922
bc96bf6
 
 
 
 
 
 
aadc025
bc96bf6
aadc025
 
 
 
 
1524b72
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
aadc025
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bc96bf6
e831922
bc96bf6
 
 
 
 
 
e831922
bc96bf6
 
 
 
 
 
e831922
bc96bf6
 
 
 
 
 
e831922
bc96bf6
 
 
 
 
 
aadc025
bc96bf6
 
 
 
 
 
e831922
bc96bf6
 
 
 
 
 
aadc025
 
 
 
 
 
 
 
 
 
 
 
 
 
bc96bf6
 
 
 
 
aadc025
bc96bf6
aadc025
 
 
 
 
 
bc96bf6
 
 
aadc025
bc96bf6
aadc025
bc96bf6
aadc025
bc96bf6
aadc025
bc96bf6
aadc025
bc96bf6
aadc025
bc96bf6
aadc025
 
b296de0
 
 
 
1524b72
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
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
import asyncio, re, ast, time, math, logging, random, pyrogram, shutil, psutil 

# Pyrogram Functions
from pyrogram.errors.exceptions.bad_request_400 import MediaEmpty, PhotoInvalidDimensions, WebpageMediaEmpty
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, CallbackQuery, InputMediaPhoto
from pyrogram import Client, filters, enums 
from pyrogram.errors import FloodWait, UserIsBlocked, MessageNotModified, PeerIdInvalid

# Helper Function
from Script import script
from utils import get_size, is_subscribed, get_poster, search_gagala, temp, get_settings, save_group_settings, get_shortlink, get_time, humanbytes 
from .ExtraMods.carbon import make_carbon

# Database Function 
from database.connections_mdb import active_connection, all_connections, delete_connection, if_active, make_active, make_inactive
from database.ia_filterdb import Media, get_file_details, get_search_results
from database.filters_mdb import del_all, find_filter, get_filters
from database.gfilters_mdb import find_gfilter, get_gfilters
from database.users_chats_db import db

# Image Editor Function
from image.edit_1 import bright, mix, black_white, g_blur, normal_blur, box_blur
from image.edit_2 import circle_with_bg, circle_without_bg, sticker, edge_curved, contrast, sepia_mode, pencil, cartoon                             
from image.edit_3 import green_border, blue_border, black_border, red_border
from image.edit_4 import rotate_90, rotate_180, rotate_270, inverted, round_sticker, removebg_white, removebg_plain, removebg_sticker
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

# Configuration
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, \
    SPELL_CHECK_REPLY, IMDB_TEMPLATE, IMDB_DELET_TIME, START_MESSAGE, PMFILTER, G_FILTER, BUTTON_LOCK, BUTTON_LOCK_TEXT, SHORT_URL, SHORT_API

logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)

@Client.on_callback_query()
async def cb_handler(client: Client, query: CallbackQuery):
    logger.debug(f"Callback query received: {query.data} from user {query.from_user.id}")
    if query.data == "close_data":
        logger.debug(f"Closing message for user {query.from_user.id}")
        await query.message.delete()
        
    elif query.data == "delallconfirm":
        userid = query.from_user.id
        chat_type = query.message.chat.type
        if chat_type == enums.ChatType.PRIVATE:
            logger.debug(f"Checking active connection for user {userid}")
            grpid = await active_connection(str(userid))
            if grpid is not None:
                grp_id = grpid
                try:
                    chat = await client.get_chat(grpid)
                    title = chat.title
                except Exception as e:
                    logger.error(f"Error fetching chat {grpid}: {e}")
                    return await query.message.edit_text("Make Sure I'm Present In Your Group!!", quote=True)
            else:
                logger.debug(f"No active connection found for user {userid}")
                return await query.message.edit_text("I'm Not Connected To Any Groups!\ncheck /Connections Or Connect To Any Groups", quote=True)
        elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:
            grp_id = query.message.chat.id
            title = query.message.chat.title
        else: 
            logger.debug(f"Unsupported chat type: {chat_type}")
            return
        st = await client.get_chat_member(grp_id, userid)
        if (st.status == enums.ChatMemberStatus.OWNER) or (str(userid) in ADMINS): 
            logger.debug(f"Deleting all filters for group {grp_id}")
            await del_all(query.message, grp_id, title)
        else: 
            logger.debug(f"User {userid} is not authorized to delete all filters in group {grp_id}")
            await query.answer("You Need To Be Group Owner Or An Auth User To Do That!", show_alert=True)
        
    elif query.data == "delallcancel":
        userid = query.from_user.id
        chat_type = query.message.chat.type
        if chat_type == enums.ChatType.PRIVATE:
            logger.debug(f"Cancelling delall operation for user {userid}")
            await query.message.reply_to_message.delete()
            await query.message.delete()
        elif chat_type in [enums.ChatType.GROUP, enums.ChatType.SUPERGROUP]:
            grp_id = query.message.chat.id
            st = await client.get_chat_member(grp_id, userid)
            if (st.status == enums.ChatMemberStatus.OWNER) or (str(userid) in ADMINS):
                logger.debug(f"Cancelling delall operation for user {userid} in group {grp_id}")
                await query.message.delete()
                try: await query.message.reply_to_message.delete()
                except: pass
            else: 
                logger.debug(f"User {userid} is not authorized to cancel delall in group {grp_id}")
                await query.answer("Buddy Don't Touch Others Property 😁", show_alert=True)
            
    elif "groupcb" in query.data:
        group_id = query.data.split(":")[1]
        act = query.data.split(":")[2]
        try:
            hr = await client.get_chat(int(group_id))
            title = hr.title
        except Exception as e:
            logger.error(f"Error fetching chat {group_id}: {e}")
            return await query.message.edit_text("Error fetching chat details", parse_mode=enums.ParseMode.MARKDOWN)
        user_id = query.from_user.id
        if act == "":
            stat = "Connect"
            cb = "connectcb"
        else:
            stat = "Disconnect"
            cb = "disconnect"
        keyboard = InlineKeyboardMarkup([[
            InlineKeyboardButton(f"{stat}", callback_data=f"{cb}:{group_id}"),
            InlineKeyboardButton("Delete", callback_data=f"deletecb:{group_id}")
            ],[
            InlineKeyboardButton("Back", callback_data="backcb")]
        ])
        await query.message.edit_text(f"Group Name:- **{title}**\nGroup Id:- `{group_id}`", reply_markup=keyboard, parse_mode=enums.ParseMode.MARKDOWN)
      
    elif "connectcb" in query.data:
        group_id = query.data.split(":")[1]
        try:
            hr = await client.get_chat(int(group_id))
            title = hr.title
        except Exception as e:
            logger.error(f"Error fetching chat {group_id}: {e}")
            return await query.message.edit_text("Error fetching chat details", parse_mode=enums.ParseMode.MARKDOWN)
        user_id = query.from_user.id
        try:
            mkact = await make_active(str(user_id), str(group_id))
            if mkact: 
                logger.debug(f"User {user_id} connected to group {group_id}")
                await query.message.edit_text(f"Connected To: **{title}**", parse_mode=enums.ParseMode.MARKDOWN,)
            else: 
                logger.debug(f"Failed to connect user {user_id} to group {group_id}")
                await query.message.edit_text('Some Error Occurred!!', parse_mode="md")
        except Exception as e:
            logger.error(f"Error connecting user {user_id} to group {group_id}: {e}")
            await query.message.edit_text('Some Error Occurred!!', parse_mode="md")
       
    elif "disconnect" in query.data:
        group_id = query.data.split(":")[1]
        try:
            hr = await client.get_chat(int(group_id))
            title = hr.title
        except Exception as e:
            logger.error(f"Error fetching chat {group_id}: {e}")
            return await query.message.edit_text("Error fetching chat details", parse_mode=enums.ParseMode.MARKDOWN)
        user_id = query.from_user.id
        try:
            mkinact = await make_inactive(str(user_id))
            if mkinact: 
                logger.debug(f"User {user_id} disconnected from group {group_id}")
                await query.message.edit_text(f"Disconnected From **{title}**", parse_mode=enums.ParseMode.MARKDOWN)
            else: 
                logger.debug(f"Failed to disconnect user {user_id} from group {group_id}")
                await query.message.edit_text(f"Some Error Occurred!!", parse_mode=enums.ParseMode.MARKDOWN)
        except Exception as e:
            logger.error(f"Error disconnecting user {user_id} from group {group_id}: {e}")
            await query.message.edit_text(f"Some Error Occurred!!", parse_mode=enums.ParseMode.MARKDOWN)
      
    elif "deletecb" in query.data:
        user_id = query.from_user.id
        group_id = query.data.split(":")[1]
        try:
            delcon = await delete_connection(str(user_id), str(group_id))
            if delcon: 
                logger.debug(f"Connection deleted for user {user_id} from group {group_id}")
                await query.message.edit_text("Successfully Deleted Connection")
            else: 
                logger.debug(f"Failed to delete connection for user {user_id} from group {group_id}")
                await query.message.edit_text(f"Some Error Occurred!!", parse_mode=enums.ParseMode.MARKDOWN)
        except Exception as e:
            logger.error(f"Error deleting connection for user {user_id} from group {group_id}: {e}")
            await query.message.edit_text(f"Some Error Occurred!!", parse_mode=enums.ParseMode.MARKDOWN)
       
    elif query.data == "backcb":
        userid = query.from_user.id
        try:
            groupids = await all_connections(str(userid))
        except Exception as e:
            logger.error(f"Error fetching all connections for user {userid}: {e}")
            return await query.message.edit_text("Error fetching connections")
        if groupids is None:
            return await query.message.edit_text("There Are No Active Connections!! Connect To Some Groups First.")
        buttons = []
        for groupid in groupids:
            try:
                ttl = await client.get_chat(int(groupid))
                title = ttl.title
                active = await if_active(str(userid), str(groupid))
                act = " - ACTIVE" if active else ""
                buttons.append([InlineKeyboardButton(f"{title}{act}", callback_data=f"groupcb:{groupid}:{act}")])
            except Exception as e:
                logger.error(f"Error fetching chat {groupid}: {e}")
                pass
        if buttons: 
            logger.debug(f"Editing message with connections for user {userid}")
            await query.message.edit_text("Your Connected Group Details ;\n\n", reply_markup=InlineKeyboardMarkup(buttons))
            
    elif "alertmessage" in query.data:
        grp_id = query.message.chat.id
        i = query.data.split(":")[1]
        keyword = query.data.split(":")[2]        
        try:
            reply_text, btn, alerts, fileid = await find_filter(grp_id, keyword)       
            if alerts is not None:
                alerts = ast.literal_eval(alerts)
                alert = alerts[int(i)]
                alert = alert.replace("\\n", "\n").replace("\\t", "\t")
                await query.answer(alert, show_alert=True)
        except Exception as e:
            logger.error(f"Error fetching alert message for keyword {keyword} in group {grp_id}: {e}")
            await query.answer("Error fetching alert message", show_alert=True)
            
    elif "galert" in query.data:
        i = query.data.split(":")[1]
        keyword = query.data.split(":")[2]             
        try:
            reply_text, btn, alerts, fileid = await find_gfilter("gfilters", keyword)
            if alerts is not None:
                alerts = ast.literal_eval(alerts)
                alert = alerts[int(i)]
                alert = alert.replace("\\n", "\n").replace("\\t", "\t")
                await query.answer(alert, show_alert=True)
        except Exception as e:
            logger.error(f"Error fetching global alert message for keyword {keyword}: {e}")
            await query.answer("Error fetching global alert message", show_alert=True)
    
    if query.data.startswith("pmfile"):
        ident, file_id = query.data.split("#")
        try:
            files_ = await get_file_details(file_id)
        except Exception as e:
            logger.error(f"Error fetching file details for file_id {file_id}: {e}")
            return await query.answer('No Such File Exist.', show_alert=True)
        if not files_: 
            logger.debug(f"No file details found for file_id {file_id}")
            return await query.answer('No Such File Exist.', show_alert=True)
        files = files_[0]
        title = files.file_name
        size = get_size(files.file_size)
        f_caption = f"{title}"
        if CUSTOM_FILE_CAPTION:
            try: 
                f_caption = CUSTOM_FILE_CAPTION.format(mention=query.from_user.mention, file_name='' if title is None else title, file_size='' if size is None else size, file_caption='' if f_caption is None else f_caption)                                                                                                      
            except Exception as e: 
                logger.error(f"Error formatting custom file caption: {e}")
        try:                  
            if AUTH_CHANNEL and not await is_subscribed(client, query):
                logger.debug(f"User {query.from_user.id} is not subscribed to AUTH_CHANNEL")
                return await query.answer(url=f"https://t.me/{temp.U_NAME}?start={ident}_{file_id}")
            else:
                logger.debug(f"Sending file {file_id} to user {query.from_user.id}")
                await client.send_cached_media(chat_id=query.from_user.id, file_id=file_id, caption=f_caption, protect_content=True if ident == "pmfilep" else False)                       
        except Exception as e:
            logger.error(f"Error sending file {file_id} to user {query.from_user.id}: {e}")
            await query.answer(f"⚠️ Error {e}", show_alert=True)
        
    if query.data.startswith("file"):        
        ident, req, file_id = query.data.split("#")
        if BUTTON_LOCK:
            if int(req) not in [query.from_user.id, 0]:
                logger.debug(f"Button lock triggered for user {query.from_user.id}")
                return await query.answer(BUTTON_LOCK_TEXT.format(query=query.from_user.first_name), show_alert=True)
        try:
            files_ = await get_file_details(file_id)
        except Exception as e:
            logger.error(f"Error fetching file details for file_id {file_id}: {e}")
            return await query.answer('No Such File Exist.', show_alert=True)
        if not files_: 
            logger.debug(f"No file details found for file_id {file_id}")
            return await query.answer('No Such File Exist.', show_alert=True)
        files = files_[0]
        title = files.file_name
        size = get_size(files.file_size)
        f_caption = f"{title}"
        settings = await get_settings(query.message.chat.id)
        if CUSTOM_FILE_CAPTION:
            try: 
                f_caption = CUSTOM_FILE_CAPTION.format(mention=query.from_user.mention, file_name='' if title is None else title, file_size='' if size is None else size, file_caption='' if f_caption is None else f_caption)                               
            except Exception as e: 
                logger.error(f"Error formatting custom file caption: {e}")
        try:
            if AUTH_CHANNEL and not await is_subscribed(client, query):
                logger.debug(f"User {query.from_user.id} is not subscribed to AUTH_CHANNEL")
                return await query.answer(url=f"https://t.me/{temp.U_NAME}?start={ident}_{file_id}")
            elif settings['botpm']:
                logger.debug(f"Redirecting user {query.from_user.id} to PM for file {file_id}")
                return await query.answer(url=f"https://t.me/{temp.U_NAME}?start={ident}_{file_id}")
            else:
                logger.debug(f"Sending file {file_id} to user {query.from_user.id}")
                await client.send_cached_media(chat_id=query.from_user.id, file_id=file_id, caption=f_caption, protect_content=True if ident == "filep" else False)
                await query.answer('CΚœα΄‡α΄„α΄‹ PM, I Hᴀᴠᴇ Sᴇɴᴛ FΙͺΚŸα΄‡s IΙ΄ Pᴍ', show_alert=True)
        except UserIsBlocked:
            logger.debug(f"User {query.from_user.id} has blocked the bot")
            await query.answer('UΙ΄Κ™ΚŸα΄α΄„α΄‹ TΚœα΄‡ Bᴏᴛ Mα΄€ΚœΙ΄ !', show_alert=True)
        except PeerIdInvalid:
            logger.debug(f"Invalid peer ID for user {query.from_user.id}")
            await query.answer(url=f"https://t.me/{temp.U_NAME}?start={ident}_{file_id}")
        except Exception as e:
            logger.error(f"Error sending file {file_id} to user {query.from_user.id}: {e}")
            await query.answer(url=f"https://t.me/{temp.U_NAME}?start={ident}_{file_id}")
     
    elif query.data.startswith("checksub"):
        if AUTH_CHANNEL and not await is_subscribed(client, query):
            logger.debug(f"User {query.from_user.id} is not subscribed to AUTH_CHANNEL")
            return await query.answer("I LΙͺᴋᴇ Yα΄α΄œΚ€ Sα΄α΄€Κ€α΄›Ι΄α΄‡κœ±κœ±, Bα΄œα΄› Dᴏɴ'α΄› Bᴇ Oα΄ α΄‡Κ€κœ±α΄α΄€Κ€α΄› Oᴋᴀʏ 😏", show_alert=True)
        ident, file_id = query.data.split("#")
        try:
            files_ = await get_file_details(file_id)
        except Exception as e:
            logger.error(f"Error fetching file details for file_id {file_id}: {e}")
            return await query.answer('NO SUCH FILE EXIST....', show_alert=True)
        if not files_: 
            logger.debug(f"No file details found for file_id {file_id}")
            return await query.answer('NO SUCH FILE EXIST....', show_alert=True)
        files = files_[0]
        title = files.file_name
        size = get_size(files.file_size)
        f_caption = f"{title}"
        if CUSTOM_FILE_CAPTION:
            try: 
                f_caption = CUSTOM_FILE_CAPTION.format(mention=query.from_user.mention, file_name='' if title is None else title, file_size='' if size is None else size, file_caption='' if f_caption is None else f_caption)  
            except Exception as e: 
                logger.error(f"Error formatting custom file caption: {e}")
        try:
            if AUTH_CHANNEL and not await is_subscribed(client, query):
                logger.debug(f"User {query.from_user.id} is not subscribed to AUTH_CHANNEL")
                return await query.answer(url=f"https://t.me/{temp.U_NAME}?start={ident}_{file_id}")
            else:
                logger.debug(f"Sending file {file_id} to user {query.from_user.id}")
                await client.send_cached_media(chat_id=query.from_user.id, file_id=file_id, caption=f_caption, protect_content=True if ident == 'checksubp' else False)
        except Exception as e:
            logger.error(f"Error sending file {file_id} to user {query.from_user.id}: {e}")
            await query.answer(f"⚠️ Error {e}", show_alert=True)

    elif query.data == "removebg":
        buttons = [[
            InlineKeyboardButton(text="𝖢𝗂𝗍𝗁 𝖢𝗁𝗂𝗍𝖾 𝖑𝖦", callback_data="rmbgwhite"),
            InlineKeyboardButton(text="π–Άπ—‚π—π—π—ˆπ—Žπ— 𝖑𝖦", callback_data="rmbgplain"),
            ],[
            InlineKeyboardButton(text="𝖲𝗍𝗂𝖼𝗄𝖾𝗋", callback_data="rmbgsticker"),
            ],[
            InlineKeyboardButton('𝙱𝙰𝙲𝙺', callback_data='photo')
        ]]
        await query.message.edit_text("**Select Required Mode**", reply_markup=InlineKeyboardMarkup(buttons))
            
    elif query.data == "stick":
        buttons = [[
            InlineKeyboardButton(text="π–­π—ˆπ—‹π—†π–Ίπ—…", callback_data="stkr"),
            InlineKeyboardButton(text="𝖀𝖽𝗀𝖾 π–’π—Žπ—‹π—π–Ύπ–½", callback_data="cur_ved"),
            ],[                    
            InlineKeyboardButton(text="𝖒𝗂𝗋𝖼𝗅𝖾", callback_data="circle_sticker")
            ],[
            InlineKeyboardButton('𝙱𝙰𝙲𝙺', callback_data='photo')
        ]]              
        await query.message.edit_text("**Select A Type**", reply_markup=InlineKeyboardMarkup(buttons))          
            
    elif query.data == "rotate":
        buttons = [[
            InlineKeyboardButton(text="180", callback_data="180"),
            InlineKeyboardButton(text="90", callback_data="90")
            ],[
            InlineKeyboardButton(text="270", callback_data="270")
            ],[
            InlineKeyboardButton('𝙱𝙰𝙲𝙺', callback_data='photo')
        ]]
        await query.message.edit_text("**Select The Degree**", reply_markup=InlineKeyboardMarkup(buttons))
            
    elif query.data == "glitch":
        buttons = [[
            InlineKeyboardButton(text="π–­π—ˆπ—‹π—†π–Ίπ—…", callback_data="normalglitch"),
            InlineKeyboardButton(text="𝖲𝖼𝖺𝗇 π–«π–Ίπ—‚π—‡π—Œ", callback_data="scanlineglitch")
            ],[
            InlineKeyboardButton('𝙱𝙰𝙲𝙺', callback_data='photo')
        ]]
        await query.message.edit_text("**Select Required Mode**", reply_markup=InlineKeyboardMarkup(buttons))
            
    elif query.data == "normalglitch":
        buttons = [[
            InlineKeyboardButton(text="1", callback_data="normalglitch1"),
            InlineKeyboardButton(text="2", callback_data="normalglitch2"),
            InlineKeyboardButton(text="3", callback_data="normalglitch3"),
            ],[
            InlineKeyboardButton(text="4", callback_data="normalglitch4"),
            InlineKeyboardButton(text="5", callback_data="normalglitch5"),
            ],[
            InlineKeyboardButton('𝙱𝙰𝙲𝙺', callback_data='glitch')
            ]]
        await query.message.edit_text(text="**Select Glitch Power Level**", reply_markup=InlineKeyboardMarkup(buttons))
           
    elif query.data == "scanlineglitch":
        buttons = [[
            InlineKeyboardButton(text="1", callback_data="scanlineglitch1"),
            InlineKeyboardButton(text="2", callback_data="scanlineglitch2"),
            InlineKeyboardButton(text="3", callback_data="scanlineglitch3"),
            ],[
            InlineKeyboardButton(text="4", callback_data="scanlineglitch4"),
            InlineKeyboardButton(text="5", callback_data="scanlineglitch5"),
            ],[
            InlineKeyboardButton('𝙱𝙰𝙲𝙺', callback_data='glitch')
        ]]
        await query.message.edit_text("**Select Glitch Power Level**", reply_markup=InlineKeyboardMarkup(buttons))
            
    elif query.data == "blur":
        buttons = [[
            InlineKeyboardButton(text="π–‘π—ˆπ—‘", callback_data="box"),
            InlineKeyboardButton(text="π–­π—ˆπ—‹π—†π–Ίπ—…", callback_data="normal"),
            ],[
            InlineKeyboardButton(text="π–¦π–Ίπ—Žπ—Œπ—Œπ—‚π–Ίπ—‡", callback_data="gas")
            ],[
            InlineKeyboardButton('𝙱𝙰𝙲𝙺', callback_data='photo')
        ]]
        await query.message.edit_text("**Select A Type**", reply_markup=InlineKeyboardMarkup(buttons))
            
    elif query.data == "circle":
        buttons = [[
            InlineKeyboardButton(text="𝖢𝗂𝗍𝗁 𝖑𝖦", callback_data="circlewithbg"),
            InlineKeyboardButton(text="π–Άπ—‚π—π—π—ˆπ—Žπ— 𝖑𝖦", callback_data="circlewithoutbg"),
            ],[
            InlineKeyboardButton('𝙱𝙰𝙲𝙺', callback_data='photo')
        ]]
        await query.message.edit_text("**Select Required Mode**", reply_markup=InlineKeyboardMarkup(buttons))
            
    elif query.data == "border":
        buttons = [[
            InlineKeyboardButton(text="𝖱𝖾𝖽", callback_data="red"),
            InlineKeyboardButton(text="𝖦𝗋𝖾𝖾𝗇", callback_data="green"),
            ],[
            InlineKeyboardButton(text="𝖑𝗅𝖺𝖼𝗄", callback_data="black"),
            InlineKeyboardButton(text="π–‘π—…π—Žπ–Ύ", callback_data="blue"),
            ],[                    
            InlineKeyboardButton('𝙱𝙰𝙲𝙺', callback_data='photo')   
        ]]           
        await query.message.edit_text("**Select Border**", reply_markup=InlineKeyboardMarkup(buttons))
   
    elif query.data == "photo":
        buttons = [[
            InlineKeyboardButton(text="𝖑𝗋𝗂𝗀𝗍𝗁", callback_data="bright"),
            InlineKeyboardButton(text="𝖬𝗂𝗑𝖾𝖽", callback_data="mix"),
            InlineKeyboardButton(text="𝖑 & 𝖢", callback_data="b|w"),
            ],[
            InlineKeyboardButton(text="𝖒𝗂𝗋𝖼𝗅𝖾", callback_data="circle"),
            InlineKeyboardButton(text="π–‘π—…π—Žπ—‹", callback_data="blur"),
            InlineKeyboardButton(text="π–‘π—ˆπ—‹π–½π–Ύπ—‹", callback_data="border"),
            ],[
            InlineKeyboardButton(text="𝖲𝗍𝗂𝖼𝗄𝖾𝗋", callback_data="stick"),
            InlineKeyboardButton(text="π–±π—ˆπ—π–Ίπ—π–Ύ", callback_data="rotate"),
            InlineKeyboardButton(text="π–’π—ˆπ—‡π—π—‹π–Ίπ—Œπ—", callback_data="contrast"),
            ],[
            InlineKeyboardButton(text="𝖲𝖾𝗉𝗂𝖺", callback_data="sepia"),
            InlineKeyboardButton(text="𝖯𝖾𝗇𝖼𝗂𝗅", callback_data="pencil"),
            InlineKeyboardButton(text="π–’π–Ίπ—‹π—π—ˆπ—ˆπ—‡", callback_data="cartoon"),
            ],[
            InlineKeyboardButton(text="𝖨𝗇𝗏𝖾𝗋𝗍", callback_data="inverted"),
            InlineKeyboardButton(text="𝖦𝗅𝗂𝗍𝖼𝗁", callback_data="glitch"),
            InlineKeyboardButton(text="π–±π–Ύπ—†π—ˆπ—π–Ύ 𝖑𝖦", callback_data="removebg")
            ],[
            InlineKeyboardButton(text="π–’π—…π—ˆπ—Œπ–Ύ", callback_data="close_data")
        ]]
        await query.message.edit_text("Sα΄‡ΚŸα΄‡α΄„α΄› Yα΄α΄œΚ€ Rα΄‡Η«α΄œΙͺʀᴇᴅ Mᴏᴅᴇ Fʀᴏᴍ Bα΄‡ΚŸα΄α΄‘!", reply_markup=InlineKeyboardMarkup(buttons))
               
    elif query.data == "bright":
        await bright(client, query.message)
    elif query.data == "mix":
        await mix(client, query.message)
    elif query.data == "b|w":
        await black_white(client, query.message)
    elif query.data == "circlewithbg":
        await circle_with_bg(client, query.message)
    elif query.data == "circlewithoutbg":
        await circle_without_bg(client, query.message)
    elif query.data == "green":
        await green_border(client, query.message)
    elif query.data == "blue":
        await blue_border(client, query.message)
    elif query.data == "red":
        await red_border(client, query.message)
    elif query.data == "black":
        await black_border(client, query.message)
    elif query.data == "circle_sticker":
        await round_sticker(client, query.message)
    elif query.data == "inverted":
        await inverted(client, query.message)
    elif query.data == "stkr":
        await sticker(client, query.message)
    elif query.data == "cur_ved":
        await edge_curved(client, query.message)
    elif query.data == "90":
        await rotate_90(client, query.message)
    elif query.data == "180":
        await rotate_180(client, query.message)
    elif query.data == "270":
        await rotate_270(client, query.message)
    elif query.data == "contrast":
        await contrast(client, query.message)
    elif query.data == "box":
        await box_blur(client, query.message)
    elif query.data == "gas":
        await g_blur(client, query.message)
    elif query.data == "normal":
        await normal_blur(client, query.message)
    elif query.data == "sepia":
        await sepia_mode(client, query.message)
    elif query.data == "pencil":
        await pencil(client, query.message)
    elif query.data == "cartoon":
        await cartoon(client, query.message)
    elif query.data == "normalglitch1":
        await normalglitch_1(client, query.message)
    elif query.data == "normalglitch2":
        await normalglitch_2(client, query.message)
    elif query.data == "normalglitch3":
        await normalglitch_3(client, query.message)
    elif query.data == "normalglitch4":
        await normalglitch_4(client, query.message)
    elif query.data == "normalglitch5":
        await normalglitch_5(client, query.message)
    elif query.data == "scanlineglitch1":
        await scanlineglitch_1(client, query.message)
    elif query.data == "scanlineglitch2":
        await scanlineglitch_2(client, query.message)
    elif query.data == "scanlineglitch3":
        await scanlineglitch_3(client, query.message)
    elif query.data == "scanlineglitch4":
        await scanlineglitch_4(client, query.message)
    elif query.data == "scanlineglitch5":
        await scanlineglitch_5(client, query.message)
    elif query.data == "rmbgwhite":
        await removebg_white(client, query.message)
    elif query.data == "rmbgplain":
        await removebg_plain(client, query.message)
    elif query.data == "rmbgsticker":
        await removebg_sticker(client, query.message)
    elif query.data == "pages":
        await query.answer("🀨 Cα΄œΚ€ΙͺᴏsΙͺᴛʏ Is A LΙͺα΄›α΄›ΚŸα΄‡ Mᴏʀᴇ, IsΙ΄'α΄› Iα΄›? 😁", show_alert=True)
    elif query.data == "howdl":
        try: 
            await query.answer(script.HOW_TO_DOWNLOAD.format(query.from_user.first_name), show_alert=True)
        except Exception as e:
            logger.error(f"Error answering howdl callback: {e}")
            await query.message.edit_text(script.HOW_TO_DOWNLOAD.format(query.from_user.first_name))

    elif query.data == "start":                        
        buttons = [[
            InlineKeyboardButton("βž•οΈ Aα΄…α΄… Mᴇ Tᴏ Yα΄α΄œΚ€ CΚœα΄€α΄› βž•", url=f"http://t.me/{temp.U_NAME}?startgroup=true")
            ],[
            InlineKeyboardButton("Sα΄‡α΄€Κ€α΄„Κœ πŸ”Ž", switch_inline_query_current_chat=''), 
            InlineKeyboardButton("CΚœα΄€Ι΄Ι΄α΄‡ΚŸ πŸ”ˆ", url="https://t.me/mkn_bots_updates")
            ],[      
            InlineKeyboardButton("Hα΄‡ΚŸα΄© πŸ•ΈοΈ", callback_data="help"),
            InlineKeyboardButton("AΚ™α΄α΄œα΄› ✨", callback_data="about")
        ]]
        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))
       
    elif query.data == "help":
        buttons = [[
            InlineKeyboardButton('βš™οΈ AᴅᴍΙͺΙ΄ Pα΄€Ι΄α΄‡ΚŸ βš™οΈ', 'admin')            
            ],[
            InlineKeyboardButton('FΙͺΚŸα΄›α΄‡Κ€κœ±', 'openfilter'),
            InlineKeyboardButton('Cᴏɴɴᴇᴄᴛ', 'coct')
            ],[                       
            InlineKeyboardButton('FΙͺΚŸα΄‡ Sᴛᴏʀᴇ', 'newdata'),
            InlineKeyboardButton('Exα΄›Κ€α΄€ Mᴏᴅᴇ', 'extmod')
            ],[           
            InlineKeyboardButton('GΚ€α΄α΄œα΄© Mᴀɴᴀɒᴇʀ', 'gpmanager'), 
            InlineKeyboardButton('Bᴏᴛ Sα΄›α΄€α΄›α΄œκœ± ❄️', 'stats')
            ],[
            InlineKeyboardButton('✘ CΚŸα΄κœ±α΄‡', 'close_data'),
            InlineKeyboardButton('Β« Bα΄€α΄„α΄‹', 'start')           
        ]]
        await query.edit_message_media(InputMediaPhoto(random.choice(PICS), script.HELP_TXT.format(query.from_user.mention), enums.ParseMode.HTML), reply_markup=InlineKeyboardMarkup(buttons))     
        
    elif query.data == "about":
        buttons= [[
            InlineKeyboardButton('Sα΄α΄œΚ€α΄„α΄‡ Cᴏᴅᴇ πŸ“œ', 'source')
            ],[
            InlineKeyboardButton('✘ CΚŸα΄κœ±α΄‡', 'close_data'),
            InlineKeyboardButton('Β« Bα΄€α΄„α΄‹', 'start')          
        ]]
        await query.edit_message_media(InputMediaPhoto(random.choice(PICS), script.ABOUT_TXT.format(temp.B_NAME), enums.ParseMode.HTML), reply_markup=InlineKeyboardMarkup(buttons))
        
    elif query.data == "source":
        buttons = [[
            InlineKeyboardButton('κœ±α΄α΄œΚ€α΄„α΄‡ ᴄᴏᴅᴇ', url='https://github.com/MrMKN/PROFESSOR-BOT')
            ],[
            InlineKeyboardButton('β€Ή Bα΄€α΄„α΄‹', 'about')
        ]]
        await query.edit_message_media(InputMediaPhoto(random.choice(PICS), script.SOURCE_TXT, enums.ParseMode.HTML), reply_markup=InlineKeyboardMarkup(buttons))
      
    elif query.data == "admin":
        buttons = [[
            InlineKeyboardButton('✘ CΚŸα΄κœ±α΄‡', 'close_data'),
            InlineKeyboardButton('Β« Bα΄€α΄„α΄‹', 'help')           
        ]]
        if query.from_user.id not in ADMINS:
            logger.debug(f"User {query.from_user.id} is not an admin")
            return await query.answer("Sᴏʀʀʏ TʜΙͺs Mα΄‡Ι΄α΄œ Oɴʟʏ Fᴏʀ Mʏ AᴅᴍΙͺΙ΄s βš’οΈ", show_alert=True)
        await query.message.edit_text("PΚ€α΄α΄„α΄‡κœ±κœ±ΙͺΙ΄Ι’...")
        try:
            total, used, free = shutil.disk_usage(".")
            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))            
            stats_pic = await make_carbon(stats, True)
            await query.edit_message_media(InputMediaPhoto(stats_pic, script.ADMIN_TXT, enums.ParseMode.HTML), reply_markup=InlineKeyboardMarkup(buttons))
            logger.debug(f"Admin panel processed successfully for user {query.from_user.id}")
        except Exception as e:
            logger.error(f"Error processing admin panel callback for user {query.from_user.id}: {e}")
            await query.message.edit_text("An error occurred while processing your request. Please try again later.")
        
    elif query.data == "openfilter":
        buttons = [[
            InlineKeyboardButton('Aα΄œα΄›α΄FΙͺΚŸα΄›α΄‡Κ€', 'autofilter'),
            InlineKeyboardButton('Mα΄€Ι΄α΄œα΄€ΚŸFΙͺΚŸα΄›α΄‡Κ€', 'manuelfilter')
            ],[
            InlineKeyboardButton('GΚŸα΄Κ™α΄€ΚŸFΙͺΚŸα΄›α΄‡Κ€', 'globalfilter')
            ],[
            InlineKeyboardButton('✘ CΚŸα΄κœ±α΄‡', 'close_data'),
            InlineKeyboardButton('Β« Bα΄€α΄„α΄‹', 'help')           
        ]]
        await query.edit_message_media(InputMediaPhoto(random.choice(PICS), script.FILTER_TXT, enums.ParseMode.HTML), reply_markup=InlineKeyboardMarkup(buttons))
        
    elif query.data == "autofilter":
        buttons = [[
            InlineKeyboardButton('✘ CΚŸα΄κœ±α΄‡', 'close_data'),
            InlineKeyboardButton('Β« Bα΄€α΄„α΄‹', 'openfilter')           
        ]]
        await query.edit_message_media(InputMediaPhoto(random.choice(PICS), script.AUTOFILTER_TXT, enums.ParseMode.HTML), reply_markup=InlineKeyboardMarkup(buttons))
        
    elif query.data == "manuelfilter":
        buttons = [[
            InlineKeyboardButton('Bα΄œα΄›α΄›α΄Ι΄ Fᴏʀᴍᴀᴛ', 'button')
            ],[
            InlineKeyboardButton('✘ CΚŸα΄κœ±α΄‡', 'close_data'),
            InlineKeyboardButton('Β« Bα΄€α΄„α΄‹', 'openfilter')           
        ]]
        await query.edit_message_media(InputMediaPhoto(random.choice(PICS), script.MANUELFILTER_TXT, enums.ParseMode.HTML), reply_markup=InlineKeyboardMarkup(buttons))
        
    elif query.data == "globalfilter":
        buttons = [[
            InlineKeyboardButton('Bα΄œα΄›α΄›α΄Ι΄ Fᴏʀᴍᴀᴛ', 'buttong')
            ],[
            InlineKeyboardButton('✘ CΚŸα΄κœ±α΄‡', 'close_data'),
            InlineKeyboardButton('Β« Bα΄€α΄„α΄‹', 'openfilter')           
        ]]
        if query.from_user.id not in ADMINS:
            logger.debug(f"User {query.from_user.id} is not an admin")
            return await query.answer("Sᴏʀʀʏ TʜΙͺs Mα΄‡Ι΄α΄œ Oɴʟʏ Fᴏʀ Mʏ AᴅᴍΙͺΙ΄s βš’οΈ", show_alert=True)
        await query.message.edit_text("PΚ€α΄α΄„α΄‡κœ±κœ±ΙͺΙ΄Ι’...")
        try:
            total, used, free = shutil.disk_usage(".")
            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))            
            stats_pic = await make_carbon(stats, True)
            await query.edit_message_media(InputMediaPhoto(stats_pic, script.ADMIN_TXT, enums.ParseMode.HTML), reply_markup=InlineKeyboardMarkup(buttons))
            logger.debug(f"Admin panel processed successfully for user {query.from_user.id}")
        except Exception as e:
            logger.error(f"Error processing admin panel callback for user {query.from_user.id}: {e}")
            await query.message.edit_text("An error occurred while processing your request. Please try again later.")
        
    elif query.data == "openfilter":
        buttons = [[
            InlineKeyboardButton('Aα΄œα΄›α΄FΙͺΚŸα΄›α΄‡Κ€', 'autofilter'),
            InlineKeyboardButton('Mα΄€Ι΄α΄œα΄€ΚŸFΙͺΚŸα΄›α΄‡Κ€', 'manuelfilter')
            ],[
            InlineKeyboardButton('GΚŸα΄Κ™α΄€ΚŸFΙͺΚŸα΄›α΄‡Κ€', 'globalfilter')
            ],[
            InlineKeyboardButton('✘ CΚŸα΄κœ±α΄‡', 'close_data'),
            InlineKeyboardButton('Β« Bα΄€α΄„α΄‹', 'help')           
        ]]
        await query.edit_message_media(InputMediaPhoto(random.choice(PICS), script.FILTER_TXT, enums.ParseMode.HTML), reply_markup=InlineKeyboardMarkup(buttons))
        
    elif query.data == "autofilter":
        buttons = [[
            InlineKeyboardButton('✘ CΚŸα΄κœ±α΄‡', 'close_data'),
            InlineKeyboardButton('Β« Bα΄€α΄„α΄‹', 'openfilter')           
        ]]
        await query.edit_message_media(InputMediaPhoto(random.choice(PICS), script.AUTOFILTER_TXT, enums.ParseMode.HTML), reply_markup=InlineKeyboardMarkup(buttons))
        
    elif query.data == "manuelfilter":
        buttons = [[
            InlineKeyboardButton('Bα΄œα΄›α΄›α΄Ι΄ Fᴏʀᴍᴀᴛ', 'button')
            ],[
            InlineKeyboardButton('✘ CΚŸα΄κœ±α΄‡', 'close_data'),
            InlineKeyboardButton('Β« Bα΄€α΄„α΄‹', 'openfilter')           
        ]]
        await query.edit_message_media(InputMediaPhoto(random.choice(PICS), script.MANUELFILTER_TXT, enums.ParseMode.HTML), reply_markup=InlineKeyboardMarkup(buttons))
        
    elif query.data == "globalfilter":
        buttons = [[
            InlineKeyboardButton('Bα΄œα΄›α΄›α΄Ι΄ Fᴏʀᴍᴀᴛ', 'buttong')
            ],[
            InlineKeyboardButton('✘ CΚŸα΄κœ±α΄‡', 'close_data'),
            InlineKeyboardButton('Β« Bα΄€α΄„α΄‹', 'openfilter')           
        ]]
        if query.from_user.id not in ADMINS:
            logger.debug(f"User {query.from_user.id} is not an admin")
            return await query.answer("Sᴏʀʀʏ TʜΙͺs Mα΄‡Ι΄α΄œ Oɴʟʏ Fᴏʀ Mʏ AᴅᴍΙͺΙ΄s βš’οΈ", show_alert=True)
        await query.edit_message_media(InputMediaPhoto(random.choice(PICS), script.GLOBALFILTER_TXT, enums.ParseMode.HTML), reply_markup=InlineKeyboardMarkup(buttons))
        
    elif query.data.startswith("button"):
        buttons = [[
            InlineKeyboardButton('✘ CΚŸα΄κœ±α΄‡', 'close_data'),
            InlineKeyboardButton('Β« Bα΄€α΄„α΄‹', f"{'manuelfilter' if query.data == 'button' else 'globalfilter'}")           
        ]]
        await query.edit_message_media(InputMediaPhoto(random.choice(PICS), script.BUTTON_TXT, enums.ParseMode.HTML), reply_markup=InlineKeyboardMarkup(buttons))
   
    elif query.data == "coct":
        buttons = [[
            InlineKeyboardButton('✘ CΚŸα΄κœ±α΄‡', 'close_data'),
            InlineKeyboardButton('Β« Bα΄€α΄„α΄‹', 'help')           
        ]]
        await query.edit_message_media(InputMediaPhoto(random.choice(PICS), script.CONNECTION_TXT, enums.ParseMode.HTML), reply_markup=InlineKeyboardMarkup(buttons))
         
    elif query.data == "newdata":
        buttons = [[
            InlineKeyboardButton('✘ CΚŸα΄κœ±α΄‡', 'close_data'),
            InlineKeyboardButton('Β« Bα΄€α΄„α΄‹', 'help')           
        ]]
        await query.edit_message_media(InputMediaPhoto(random.choice(PICS), script.FILE_TXT, enums.ParseMode.HTML), reply_markup=InlineKeyboardMarkup(buttons))
        
    elif query.data == "extmod":
        buttons = [[
            InlineKeyboardButton('✘ CΚŸα΄κœ±α΄‡', 'close_data'),
            InlineKeyboardButton('Β« Bα΄€α΄„α΄‹', 'help')           
        ]]
        await query.edit_message_media(InputMediaPhoto(random.choice(PICS), script.EXTRAMOD_TXT, enums.ParseMode.HTML), reply_markup=InlineKeyboardMarkup(buttons))
        
    elif query.data == "gpmanager":
        buttons = [[
            InlineKeyboardButton('✘ CΚŸα΄κœ±α΄‡', 'close_data'),
            InlineKeyboardButton('Β« Bα΄€α΄„α΄‹', 'help')           
        ]]
        await query.edit_message_media(InputMediaPhoto(random.choice(PICS), script.GROUPMANAGER_TXT, enums.ParseMode.HTML), reply_markup=InlineKeyboardMarkup(buttons))           
        
    elif query.data == "stats":
        buttons = [[
            InlineKeyboardButton('⟳ Rα΄‡κœ°Κ€α΄‡κœ±Κœ', 'stats'),
            InlineKeyboardButton('Β« Bα΄€α΄„α΄‹', 'help')           
        ]]
        try:
            total = await Media.count_documents()
            users = await db.total_users_count()
            chats = await db.total_chat_count()
            monsize = await db.get_db_size()
            free = 536870912 - monsize
            monsize = get_size(monsize)
            free = get_size(free)
            await query.message.edit('ΚŸα΄α΄€α΄…ΙͺΙ΄Ι’....')
            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))
            logger.debug(f"Stats refreshed for user {query.from_user.id}")
        except Exception as e:
            logger.error(f"Error refreshing stats for user {query.from_user.id}: {e}")
            await query.message.edit_text("An error occurred while refreshing stats. Please try again later.")
    
    elif query.data.startswith("setgs"):
        ident, set_type, status, grp_id = query.data.split("#")
        grpid = await active_connection(str(query.from_user.id))
        if str(grp_id) != str(grpid):
            logger.debug(f"Active connection mismatch for user {query.from_user.id}")
            return await query.message.edit("Yα΄α΄œΚ€ Aα΄„α΄›Ιͺᴠᴇ CᴏɴɴᴇᴄᴛΙͺᴏɴ Hα΄€s Bᴇᴇɴ CΚœα΄€Ι΄Ι’α΄‡α΄…. Gᴏ Tᴏ /settings")
        if status == "True": 
            logger.debug(f"Setting {set_type} to False for group {grp_id}")
            await save_group_settings(grpid, set_type, False)
        else: 
            logger.debug(f"Setting {set_type} to True for group {grp_id}")
            await save_group_settings(grpid, set_type, True)
        settings = await get_settings(grpid)
        if settings is not None:
            buttons = [[
                InlineKeyboardButton(f"ꜰΙͺΚŸα΄›α΄‡Κ€ Κ™α΄œα΄›α΄›α΄Ι΄ : {'sΙͺΙ΄Ι’ΚŸα΄‡' if settings['button'] else 'α΄…α΄α΄œΚ™ΚŸα΄‡'}", f'setgs#button#{settings["button"]}#{str(grpid)}')
                ],[
                InlineKeyboardButton(f"ꜰΙͺΚŸα΄‡ ΙͺΙ΄ ᴩᴍ κœ±α΄›α΄€Κ€α΄›: {'ᴏɴ' if settings['botpm'] else 'ᴏꜰꜰ'}", f'setgs#botpm#{settings["botpm"]}#{str(grpid)}')
                ],[                
                InlineKeyboardButton(f"Κ€α΄‡κœ±α΄›Κ€Ιͺα΄„α΄› ᴄᴏɴᴛᴇɴᴛ : {'ᴏɴ' if settings['file_secure'] else 'ᴏꜰꜰ'}", f'setgs#file_secure#{settings["file_secure"]}#{str(grpid)}')
                ],[
                InlineKeyboardButton(f"Ιͺᴍᴅʙ ΙͺΙ΄ ꜰΙͺΚŸα΄›α΄‡Κ€ : {'ᴏɴ' if settings['imdb'] else 'ᴏꜰꜰ'}", f'setgs#imdb#{settings["imdb"]}#{str(grpid)}')
                ],[
                InlineKeyboardButton(f"κœ±α΄©α΄‡ΚŸΚŸΙͺΙ΄Ι’ α΄„Κœα΄‡α΄„α΄‹ : {'ᴏɴ' if settings['spell_check'] else 'ᴏꜰꜰ'}", f'setgs#spell_check#{settings["spell_check"]}#{str(grpid)}')
                ],[
                InlineKeyboardButton(f"α΄‘α΄‡ΚŸα΄„α΄α΄α΄‡ α΄α΄‡κœ±κœ±α΄€Ι’α΄‡ : {'ᴏɴ' if settings['welcome'] else 'ᴏꜰꜰ'}", f'setgs#welcome#{settings["welcome"]}#{str(grpid)}')
            ]]
            await query.message.edit_reply_markup(InlineKeyboardMarkup(buttons))
            logger.debug(f"Settings updated for user {query.from_user.id} in group {grp_id}")