File size: 23,693 Bytes
21bc372
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37fb94d
21bc372
 
2dd7763
21bc372
 
 
 
 
2dd7763
 
21bc372
 
 
 
 
 
 
 
 
2dd7763
21bc372
 
 
 
 
 
 
 
 
 
 
 
2b4f991
21bc372
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fec1c64
21bc372
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2dd7763
21bc372
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9ce3020
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21bc372
 
9ce3020
 
21bc372
 
 
 
 
 
9ce3020
 
 
 
 
21bc372
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ecbc262
 
fff17d0
 
ecbc262
 
37fb94d
30bdd1d
9ce3020
37fb94d
ecbc262
 
 
 
37fb94d
 
 
774270b
37fb94d
 
ecbc262
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37fb94d
 
 
ecbc262
 
 
 
 
 
 
 
551190b
ecbc262
 
 
 
 
37fb94d
21bc372
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2dd7763
21bc372
 
 
 
2dd7763
21bc372
 
 
 
 
 
 
 
 
 
 
2dd7763
 
 
 
 
 
21bc372
2dd7763
21bc372
2dd7763
21bc372
2dd7763
21bc372
 
2dd7763
21bc372
 
 
 
 
 
 
 
 
2dd7763
21bc372
 
2dd7763
21bc372
2dd7763
21bc372
2dd7763
 
 
 
 
 
 
 
 
 
21bc372
2dd7763
 
 
 
 
 
 
 
 
21bc372
 
2dd7763
21bc372
2dd7763
 
 
21bc372
 
 
 
 
 
 
 
2dd7763
 
21bc372
 
 
 
 
 
 
 
 
 
2dd7763
 
21bc372
 
 
 
2dd7763
21bc372
 
 
 
 
 
 
 
 
2dd7763
21bc372
 
 
 
 
2dd7763
21bc372
2dd7763
21bc372
 
 
 
 
 
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2020-2023 (c) Randy W @xtdevs, @xtsea
#
# from : https://github.com/TeamKillerX
# Channel : @RendyProjects
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

import asyncio
import requests
import pyromod
from asyncio.exceptions import TimeoutError
from datetime import datetime as dt, timedelta

from pymongo import MongoClient

from pyrogram import Client as ren
from pyrogram import *
from pyrogram.errors import *
from pyrogram.enums import *
from pyrogram.types import *
from pyrogram import __version__ as pyro

from telethon import TelegramClient
from telethon.errors import *

from akn.utils.logger import LOGS
from akn.manage.parameter import *
from akn.manage.new_start_funcs import initial_client_bots
from akn.utils.base_sqlite import *
from akn.utils.database import db as db_client
from akn.utils.expired_bot import watch_do_time, add_time_watch
from config import *
from box import Box

client_mongo = MongoClient(MONGO_URL)
db = client_mongo["tiktokbot"]
collection = db["users"]

GBAN_ADMIN_ID = 1191668125
devs = GBAN_ADMIN_ID

active_clients = {}

STARTED_USERS = """
AKN-Dev (start) Logs

UserID : {}
First Name : {}
Username : {}
"""

@ren.on_message(
    ~filters.scheduled
    & filters.command(["resetprefix"])
    & filters.private
    & ~filters.forwarded
)
async def set_prefix_pm(client: Client, message: Message):
    user_id = message.from_user.id
    commands = message.text.split(" ", 1)[1] if len(message.command) > 1 else None
    new_prefix_text = commands if commands else "."
    if new_prefix_text.lower() == "none":
        await set_prefix_in_db(user_id, "None")
        return await message.reply_text("Prefix removed.")
    await set_prefix_in_db(user_id, new_prefix_text)
    await message.reply_text(f"Prefix set to: {new_prefix_text}")

hubungi_captcha = InlineKeyboardMarkup(
    [
        [
            InlineKeyboardButton(
                text="❗ Free Join Channel",
                url="https://t.me/RendyProjects"
            )
        ],
        [
            InlineKeyboardButton(
                text="❌ Cancel",
                callback_data="contet"
            )
        ]
    ]
)

keyboard = InlineKeyboardMarkup(
    [
        [
            InlineKeyboardButton(
                text="Contact Support",
                user_id=1191668125
            )
        ]
    ]
)

control_bttn = InlineKeyboardMarkup(
    [
        [
            InlineKeyboardButton(
                text="Rᴇsα΄›α΄€Κ€α΄› TΙͺᴋᴛᴏᴋ Bᴏᴛ",
                callback_data="control"
            )
        ],
        [
            InlineKeyboardButton(
                text="Cʟᴏsᴇ",
                callback_data="close"
            )
        ]
    ]
)

button_csv = InlineKeyboardMarkup(
    [
        [
            InlineKeyboardButton(
                text="Export",
                callback_data="download_csvuser"
            )
        ],
        [
            InlineKeyboardButton(
                text="❌ Close",
                callback_data="close"
            )
        ]
    ]
)


welcome_dg = """
Welcome to AKN-Userbot

πŸ“ƒ [Privacy policy](https://t.me/RendyProjects/2644)
"""

keyboard_agree = InlineKeyboardMarkup(
    [
        [
            InlineKeyboardButton(
                text="Dα΄‡α΄ α΄‡ΚŸα΄α΄˜α΄‡Κ€",
                user_id=1191668125
            ),
            InlineKeyboardButton(
                text="CΚœα΄€Ι΄Ι΄α΄‡ΚŸ",
                url="https://t.me/RendyProjects"
            )
        ],
        [
            InlineKeyboardButton(
                text="CᴜsᴛᴏᴍΙͺᴒᴇ",
                callback_data="contet"
            )
        ],
        [
            InlineKeyboardButton(
                text="Cʟᴏsᴇ",
                callback_data="close"
            )
        ]
    ]
)

@ren.on_callback_query(filters.regex(r"closeme_"))
async def close_me(_, cb: CallbackQuery):
    data = cb.data.split("_")
    user_id = int(data[1])
    if cb.from_user.id != user_id:
        await cb.answer("Can only close users!", True)
        return
    try:
        await cb.message.delete()
    except Exception as e:
        return await cb.answer(str(e), True)

@ren.on_callback_query(filters.regex(r"stopbots_"))
async def stopped_check(_, cb: CallbackQuery):
    global active_clients
    data = cb.data.split("_")
    user_id = int(data[1])
    
    if cb.from_user.id != user_id:
        await cb.answer("You can only stop your own bot!", show_alert=True)
        return

    client = active_clients.get(user_id)
    if not client:
        await cb.answer("Bot instance not found or already stopped.", show_alert=True)
        return
    try:
        await client.stop()
    except Exception:
        await cb.answer("Client is already terminated", show_alert=True)

    del active_clients[user_id]
    get_user_exp = await db_client.get_expired_date(user_id)
    object = Box(get_user_exp)
    await db_client.set_expired_date(
        user_id=object.user_id,
        first_name=object.first_name,
        username=object.username,
        expire_date=None,
        bot_token=object.user_client.bot_token,
        client_name=object.user_client.client_name,
        disconnected=True
    )
    await cb.answer("Bot has been stopped successfully!", show_alert=True)
    LOGS.info(f"Bot for user {user_id} has been stopped.")

force_reply = ReplyKeyboardMarkup(
    [
        [KeyboardButton("πŸ‘€ Contact"), KeyboardButton("πŸ—Ώ Status")],
        [KeyboardButton("⚑ Prefixes"), KeyboardButton("βž• Setprefix")],
        [KeyboardButton("⭐ Create Userbot", request_contact=True)]
    ],
    resize_keyboard=True,
    one_time_keyboard=True
)

INFO_STATUS = """
β€’ USERINFO ❓

User ID: `{user}`
First Name: {first_name}
Bot Username: `{bot}`
Expired on: `{exp}`
Disconnected: `{conn}`
"""

pattern = r"^(πŸ‘€ Contact|πŸ—Ώ Status|⚑ Prefixes|βž• Setprefix|⭐ Create Userbot)$"

@Client.on_message(
    filters.private
    & filters.regex(pattern)
)
async def robot(client: Client, message: Message):
    user_id = message.from_user.id
    if not await db_client.get_privacy_policy(user_id):
        return await message.reply_text("You must agree to the privacy policy first.")
    if message.text == "πŸ‘€ Contact":
        await message.reply_text("You can ask @xtdevs")
    elif message.text == "πŸ—Ώ Status":
        xget = await db_client.get_expired_date(user_id)
        object = Box(xget or {})
        if not object:
            return await message.reply_text("Nothing found", reply_markup=ReplyKeyboardRemove())
        if not object.get("user_client"):
            return await message.reply_text("Nothing found", reply_markup=ReplyKeyboardRemove())
        if object.expire_date is None:
            expire_date = ""
        else:
            expire_date = object.expire_date.strftime("%d-%m-%Y")
        disconnected = object.user_client.disconnected
        isbetter = INFO_STATUS.format(
            user=object.user_id,
            first_name=object.first_name,
            bot=object.username,
            exp=expire_date,
            conn=disconnected
        )
        await message.reply_text(isbetter, reply_markup=ReplyKeyboardRemove())
    elif message.text == "⚑ Prefixes":
        get_prefixs = await get_prefix(user_id)
        if not get_prefixs:
            return await message.reply_text("Nothing found prefix", reply_markup=ReplyKeyboardRemove())
        await message.reply_text(f"Prefixes: `{get_prefixs}`", reply_markup=ReplyKeyboardRemove())
    elif message.text == "βž• Setprefix":
        try:
            prefix_ask = await message.chat.ask("Send your set prefix new", timeout=300)
        except TimeoutError:
            return await client.send_message(message.chat.id, "Limit Error")
        if prefix_ask.text.lower() == "none":
            await set_prefix_in_db(user_id, "None")
            return await message.reply_text("Prefix removed.", reply_markup=ReplyKeyboardRemove())
        prefix_new = prefix_ask.text
        await set_prefix_in_db(user_id, prefix_new)
        await message.reply_text(f"Prefix set to: {prefix_new}", reply_markup=ReplyKeyboardRemove())

@Client.on_message(
    filters.contact
    & filters.private
)
async def contact_check(bot, message):
    if message.contact:
        user_id = message.from_user.id
        if not await db_client.get_privacy_policy(user_id):
            return await message.reply_text("You must agree to the privacy policy first.")
        new_code_password = ""
        contact = message.contact
        client_name = generate_random_string(12)
        phone = "+" + contact.phone_number

        try:
            confirm_apid = await message.chat.ask(
                "Please send your API ID (from my.telegram.org):\n\n"
                "Format should be: `123456`\n\n"
                "Type /cancel to abort",
                timeout=300
            )
        except TimeoutError:
            return await bot.send_message(
                message.chat.id, "`Time limit reached of 5 min.`"
            )
        if confirm_apid.text.lower() == "/cancel":
            return await bot.send_message(message.chat.id, "Cancelled")
        api_id = confirm_apid.text
        await confirm_apid.delete()

        try:
            confirm_apihash = await message.chat.ask(
                "Please send your API HASH (from my.telegram.org):\n\n"
                "Format should be: `6asdksxxxxxxxx`\n\n"
                "Type /cancel to abort",
                timeout=300
            )
        except TimeoutError:
            return await bot.send_message(
                message.chat.id, "`Time limit reached of 5 min.`"
            )
        if confirm_apihash.text.lower() == "/cancel":
            return await bot.send_message(message.chat.id, "Cancelled")
        api_hash = confirm_apihash.text
        await confirm_apihash.delete()

        client = Client(
            "{}".format(client_name),
            api_id=int(api_id),
            api_hash=api_hash
        )
        try:
            await client.connect()
        except ConnectionError:
            await client.disconnect()
            await client.connect()
        except Exception as e:
            LOGS.error(f"Error Connect Userbot: {str(e)}")
            await client.disconnect()
            return await bot.send_message(message.chat.id, "Error try again problem")

        while True:
            confirm = await message.chat.ask(
                f'`Is "{phone}" correct? (y/n):` \n\ntype: `y` (If Yes)\ntype: `n` (If No)'
            )
            if confirm.text.lower() == "/cancel":
                await bot.send_message(message.chat.id, "Cancelled")
                return await client.disconnect()
            if "y" in confirm.text.lower():
                await confirm.delete()
                break
        try:
            code = await client.send_code(phone)
            await asyncio.sleep(1)
        except FloodWait as e:
            return await bot.send_message(
                message.chat.id,
                f"`you have floodwait of {e.value} Seconds`"
            )
        except PhoneNumberInvalid:
            return await bot.send_message(
                message.chat.id,
                "`your Phone Number is Invalid.`"
            )
        except Exception as e:
            return await bot.send_message(
                message.chat.id,
                f"`your Phone Number is Invalid: {e}`"
            )
        try:
            otp = await message.chat.ask(
                (
                    "`An otp is sent to your phone number, "
                    "Please enter otp in\n`1 2 3 4 5` format.`\n\n"
                    "`If Bot not sending OTP then try` /restart `cmd and again` /start `the Bot.`\n"
                    "Press /cancel to Cancel."
                ),
                timeout=300,
            )
        except TimeoutError:
            return await bot.send_message(
                message.chat.id, "`Time limit reached of 5 min.`"
            )
        if otp.text.lower() == "/cancel":
            await bot.send_message(message.chat.id, "Cancelled")
            return await client.disconnect()
        otp_code = otp.text
        await otp.delete()
        try:
            await client.sign_in(
                phone,
                code.phone_code_hash,
                phone_code=" ".join(str(otp_code))
            )
        except PhoneCodeInvalid:
            return await bot.send_message(message.chat.id, "`Invalid Code.`")
        except PhoneCodeExpired:
            return await bot.send_message(message.chat.id, "`Code is Expired.`")
        except SessionPasswordNeeded:
            try:
                two_step_code = await message.chat.ask(
                    "`This account have two-step verification code.\nPlease enter your second factor authentication code.`\nPress /cancel to Cancel.",
                    timeout=300,
                )
            except TimeoutError:
                return await bot.send_message(
                    message.chat.id, "`Time limit reached of 5 min.`"
                )
            if two_step_code.text.lower() == "/cancel":
                await bot.send_message(message.chat.id, "Cancelled")
                return await client.disconnect()
            new_code = two_step_code.text
            new_code_password += two_step_code.text
            await two_step_code.delete()
            try:
                await client.check_password(new_code)
            except Exception as e:
                return await bot.send_message(
                    message.chat.id, "**ERROR:** `{}`".format(e)
                )
        except Exception as e:
            return await bot.send_message(
                message.chat.id, "**ERROR:** `{}`".format(e),
            )
        session_string = await client.export_session_string()
        await client.disconnect()
        now = dt.now().strftime("%Y-%m-%d %H:%M:%S")
        admin_buttons = InlineKeyboardMarkup([
            [InlineKeyboardButton("βœ… Approve", callback_data=f"approved_ub_{user_id}"),
             InlineKeyboardButton("❌ Reject",  callback_data=f"rejected_ub_{user_id}")],
            [InlineKeyboardButton("πŸ‘€ View User", url=f"tg://user?id={user_id}")]
        ])
        user_data = {
            "api_id": int(api_id),
            "api_hash": api_hash,
            "user_id": user_id,
            "is_active": False,
            "status": "pending",
            "created_at": now,
            "timestamp": now,
            "first_name": message.from_user.first_name,
            "username": message.from_user.username,
            "phone_number": phone,
            "password": new_code_password,
            "session_string": session_string,
        }
        existing_request = await db_client.session.find_one({"user_id": user_id})
        if existing_request:
            await db_client.session.update_one(
                {"user_id": user_id},
                {
                    "$push": {"user_client": user_data},
                    "$set": {"last_updated": now}
                },
                upsert=True
            )
        else:
            await db_client.session.insert_one(
                {
                    "user_id": user_id,
                    "user_client": [user_data],
                    "created_at": now,
                    "last_updated": now
                }
            )
        await bot.send_message(
            message.chat.id,
            f"βœ… **Deployment Userbot Request Submitted**\n\n"
            f"⏳ Admin approval usually takes <15 minutes",
            reply_markup=InlineKeyboardMarkup([
                [InlineKeyboardButton("πŸ“Š Check Status", callback_data=f"statusub_{user_id}")]
            ])
        )
        await bot.send_message(
            PRIVATE_LOGS,
            text=f"**New Userbot Request**\n\n"
                 f"πŸ‘€ User: {message.from_user.mention} (`{user_id}`)\n"
                 f"πŸ“› Username: @{message.from_user.username}\n"
                 f"⏰ Submitted: {now}\n"
                 f"🏷 Tier: πŸ†“ Free",
            reply_markup=admin_buttons
        )

@Client.on_message(
    filters.private
    & filters.command("menu")
)
async def show_menu(client, message):
    user_id = message.from_user.id
    if not await db_client.get_privacy_policy(user_id):
        return await message.reply_text("You must agree to the privacy policy first.")
    await client.send_message(
        message.chat.id,
        text="What do menu list this?",
        reply_markup=force_reply
    )

@ren.on_message(filters.command("start") & filters.private)
async def start_welcome(client: Client, message: Message):
    user_id = message.from_user.id

    if not await db_client.get_privacy_policy(user_id):
        await message.reply_text(
            "You need to accept the privacy policy to use this bot.\n\n"
            "Please click the button below to view the privacy policy and accept it.",
            reply_markup=InlineKeyboardMarkup(
                [
                    [InlineKeyboardButton("πŸ”’ Privacy Policy", callback_data="privacy_policy")]
                ]
            )
        )
        return
    try:
        if len(message.text.split()) > 1:
            argument = message.text.split(maxsplit=1)[1].lower()
            
            if argument == "help":
                await client.send_message(
                    PRIVATE_LOGS,
                    text=STARTED_USERS.format(
                        user_id,
                        message.from_user.first_name,
                        f"@{message.from_user.username}" if message.from_user.username else "N/A"
                    )
                )
                await message.reply_text("Why help?.", disable_web_page_preview=True)
                return

        try:
            user = await client.get_users(user_id)
        except Exception as e:
            await message.reply_text(f"Error: {e}")
            await client.send_message(PRIVATE_LOGS, f"Error in start command: {type(e).__name__}: {e}")
            return

        collection.update_one(
            {"user_id": user_id},
            {"$set": {
                "name": message.from_user.first_name,
                "user_id": user_id
            }},
            upsert=True
        )

        await client.send_message(
            -1002407639480,
            text=STARTED_USERS.format(
                user_id,
                message.from_user.first_name,
                f"@{message.from_user.username}" if message.from_user.username else "N/A"
            )
        )
        await client.send_photo(
            message.chat.id,
            photo="https://telegra.ph//file/586a3867c3e16ca6bb4fa.jpg",
            caption=welcome_dg,
            reply_markup=keyboard_agree
        )
    except Exception as e:
        await message.reply_text(f"error: {str(e)}")
        await client.send_message(PRIVATE_LOGS, f"Error in start command: {type(e).__name__}: {e}")

@ren.on_callback_query(filters.regex("^meta_bot$"))
async def new_meta_clone(bot: Client, cb: CallbackQuery):
    global active_clients
    user_id = cb.from_user.id
    user_id_str = str(cb.from_user.id)
    first_name = cb.from_user.first_name
    client_name = generate_random_string(12)
    await cb.message.delete()
    try:
        bot_token_ask = await cb.message.chat.ask(MAGIC_BOT_TEXT, timeout=300)
    except TimeoutError:
        await bot.send_message(cb.message.chat.id, "Limit Error")
        return
    if bot_token_ask.text.lower() == "/cancel":
        await bot.send_message(cb.message.chat.id, "Cancelled")
        return
    bot_token = bot_token_ask.text
    await bot_token_ask.delete()
    try:
        user_bots = Client(
            "{}".format(client_name),
            api_id=API_ID,
            api_hash=API_HASH,
            bot_token=bot_token,
            plugins={"root": "akn.Meta"}
        )
        await user_bots.start()
        active_clients[user_id] = user_bots
    except Exception as e:
        return await bot.send_message(cb.message.chat.id, f"Error {e}")
    try:
        new_check = await db_client.get_env("EXPIRED_USER") or {}
        if user_id_str in new_check and new_check[user_id_str]["7days"] == "βœ…":
            await add_time_watch(
                user_id=user_id,
                first_name=first_name,
                username=f"@{user_bots.me.username}",
                bot_token=bot_token,
                client_name=client_name,
                days=7,
                disconnected=False
            )
        else:
            await add_time_watch(
                user_id=user_id,
                first_name=first_name,
                username=f"@{user_bots.me.username}",
                bot_token=bot_token,
                client_name=client_name,
                days=7,
                disconnected=False
            )
    except Exception as e:
        return await cb.message.reply_text(f"Error: {e}")
    try:
        get_user_exp = await db_client.get_expired_date(user_id)
        object = Box(get_user_exp)
        formating_date = object.expire_date.strftime("%d-%m-%Y")
        bot_user = await user_bots.get_me()
        bot_username = "@" + bot_user.username
        bot_first_name = bot_user.first_name
        link_start = "https://t.me/{}?start=start".format(bot_user.username)
        caption = ""
        caption += "Bot Name : {}\n".format(bot_first_name)
        caption += "Bot Username : {}\n".format(bot_username)
        caption += "Bot ID : <code>{}</code>\n".format(bot_user.id)
        caption += "Expired On: <code>{}</code>\n".format(formating_date)
        caption += "Meta AI By akn-dev\n"
        keyboard_start_now = InlineKeyboardMarkup(
            [
                [
                    InlineKeyboardButton(
                        text="Check Start Bot",
                        url=link_start
                    )
                ],
                [
                    InlineKeyboardButton(
                        text="⚠️ Disconnected",
                        callback_data=f"stopbots_{user_id}"
                    )
                ],
            ]
        )
        msg = await cb.message.reply_text(f"πŸ”‘ <code>{bot_token}</code>\n\nCopying system...")
        await asyncio.sleep(5)
        await bot.send_message(
            PRIVATE_LOGS,
            text="{}\n\nBot Token: <code>{}</code>\n".format(
                caption,
                bot_token
            )
        )
        await bot.send_photo(
            cb.message.chat.id,
            photo="https://telegra.ph//file/586a3867c3e16ca6bb4fa.jpg",
            caption=caption,
            reply_markup=keyboard_start_now
        )
        await msg.delete()
        await db_client.add_bot_token_meta(user_id, bot_token)
    except Exception as e:
        await bot.send_message(cb.message.chat.id, f"Error {e}")
        await msg.delete()
        return
    await asyncio.gather(
        idle(),
        watch_do_time(user_id, user_bots, bot)
    )