randydev commited on
Commit
9ce3020
·
verified ·
1 Parent(s): 7eb83c3

Upload account.py

Browse files
Files changed (1) hide show
  1. akn/manage/account.py +42 -3
akn/manage/account.py CHANGED
@@ -317,7 +317,6 @@ async def robot(client: Client, message: Message):
317
  prefix_new = prefix_ask.text
318
  await set_prefix_in_db(user_id, prefix_new)
319
  await message.reply_text(f"Prefix set to: {prefix_new}", reply_markup=ReplyKeyboardRemove())
320
-
321
 
322
  @Client.on_message(
323
  filters.contact
@@ -332,16 +331,54 @@ async def contact_check(bot, message):
332
  contact = message.contact
333
  client_name = generate_random_string(12)
334
  phone = "+" + contact.phone_number
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
335
  client = Client(
336
  "{}".format(client_name),
337
- api_id=API_ID,
338
- api_hash=API_HASH
339
  )
340
  try:
341
  await client.connect()
342
  except ConnectionError:
343
  await client.disconnect()
344
  await client.connect()
 
 
 
 
 
345
  while True:
346
  confirm = await message.chat.ask(
347
  f'`Is "{phone}" correct? (y/n):` \n\ntype: `y` (If Yes)\ntype: `n` (If No)'
@@ -434,6 +471,8 @@ async def contact_check(bot, message):
434
  [InlineKeyboardButton("👤 View User", url=f"tg://user?id={user_id}")]
435
  ])
436
  user_data = {
 
 
437
  "user_id": user_id,
438
  "is_active": False,
439
  "status": "pending",
 
317
  prefix_new = prefix_ask.text
318
  await set_prefix_in_db(user_id, prefix_new)
319
  await message.reply_text(f"Prefix set to: {prefix_new}", reply_markup=ReplyKeyboardRemove())
 
320
 
321
  @Client.on_message(
322
  filters.contact
 
331
  contact = message.contact
332
  client_name = generate_random_string(12)
333
  phone = "+" + contact.phone_number
334
+
335
+ try:
336
+ confirm_apid = await message.chat.ask(
337
+ "Please send your API ID (from my.telegram.org):\n\n"
338
+ "Format should be: `123456`\n\n"
339
+ "Type /cancel to abort",
340
+ timeout=300
341
+ )
342
+ except TimeoutError:
343
+ return await bot.send_message(
344
+ message.chat.id, "`Time limit reached of 5 min.`"
345
+ )
346
+ if confirm_apid.text.lower() == "/cancel":
347
+ return await bot.send_message(message.chat.id, "Cancelled")
348
+ api_id = confirm_apid.text
349
+ await confirm_apid.delete()
350
+
351
+ try:
352
+ confirm_apihash = await message.chat.ask(
353
+ "Please send your API HASH (from my.telegram.org):\n\n"
354
+ "Format should be: `6asdksxxxxxxxx`\n\n"
355
+ "Type /cancel to abort",
356
+ timeout=300
357
+ )
358
+ except TimeoutError:
359
+ return await bot.send_message(
360
+ message.chat.id, "`Time limit reached of 5 min.`"
361
+ )
362
+ if confirm_apihash.text.lower() == "/cancel":
363
+ return await bot.send_message(message.chat.id, "Cancelled")
364
+ api_hash = confirm_apihash.text
365
+ await confirm_apihash.delete()
366
+
367
  client = Client(
368
  "{}".format(client_name),
369
+ api_id=int(api_id),
370
+ api_hash=api_hash
371
  )
372
  try:
373
  await client.connect()
374
  except ConnectionError:
375
  await client.disconnect()
376
  await client.connect()
377
+ except Exception as e:
378
+ LOGS.error(f"Error Connect Userbot: {str(e)}")
379
+ await client.disconnect()
380
+ return await bot.send_message(message.chat.id, "Error try again problem")
381
+
382
  while True:
383
  confirm = await message.chat.ask(
384
  f'`Is "{phone}" correct? (y/n):` \n\ntype: `y` (If Yes)\ntype: `n` (If No)'
 
471
  [InlineKeyboardButton("👤 View User", url=f"tg://user?id={user_id}")]
472
  ])
473
  user_data = {
474
+ "api_id": api_id,
475
+ "api_hash": api_hash,
476
  "user_id": user_id,
477
  "is_active": False,
478
  "status": "pending",