add_account.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. from settings import DATABASE_FILE, SESSIONS_FOLDER, SEP
  2. import sqlite3
  3. from telethon import TelegramClient
  4. from database import create_new_main_db, add_account
  5. def add_new_account():
  6. phone = input("Phone: ")
  7. password = input("Password (Telegram): ")
  8. safelogin = input("SafeUMlogin (Not necessary): ")
  9. password_2 = input("Password(SafeUM) (Not necessary): ")
  10. api_id = input("Api_id: ")
  11. api_hash = input("Api_hash: ")
  12. is_working = int(input("Is active(0, 1): "))
  13. wallet = input("Wallet: ")
  14. wallet_pass = input("Wallet password (Coinomi) (Not necessary): ")
  15. recover_phrase = input("Wallet recover phrase (Not necessary): ")
  16. try:
  17. db = sqlite3.connect(DATABASE_FILE)
  18. db.close()
  19. except Exception as e:
  20. create_new_main_db()
  21. add_account(phone, password, api_id, api_hash, is_working, wallet, wallet_pass,
  22. recover_phrase, safelogin, password_2)
  23. def add_new_information():
  24. phone = input("Phone: ")
  25. telegram_pass = input("Telegram password: ")
  26. api_id = input("Api_id: ")
  27. api_hash = input("Api_hash: ")
  28. is_working = int(input("is_working(0, 1)"))
  29. db = sqlite3.connect(DATABASE_FILE)
  30. cur = db.cursor()
  31. new_id = cur.execute("SELECT ID FROM Account WHERE PHONE = {}".format(phone)).fetchall()
  32. session = SESSIONS_FOLDER + SEP + "anon" + str(new_id[0]) + '.session'
  33. client = TelegramClient(session, int(api_id), api_hash)
  34. client.start()
  35. cur.execute("UPDATE Account "
  36. "SET API_ID = {}, API_HASH = {}, IS_ACTIVE = {}, SESSION = {}, PASS = {} "
  37. "WHERE phone = {}".format(api_id, api_hash, is_working, session, telegram_pass, phone))
  38. db.commit()
  39. def add_proxy():
  40. db = sqlite3.connect(DATABASE_FILE)
  41. cur = db.cursor()
  42. proxy_ip = input("ip: ")
  43. protocol = input("protocol: ")
  44. port = input("port: ")
  45. cur.execute("""INSERT INTO Proxy(IP, PROTOCOL, PORT) VALUES (?, ?, ?);""", (proxy_ip, protocol, port))
  46. db.commit()
  47. while True:
  48. mode = input("New account (1) \nUpdate information (2)")
  49. if mode == '1':
  50. add_new_account()
  51. elif mode == '2':
  52. add_new_information()
  53. res = input("Continue? Y/n \n")
  54. if res == 'n':
  55. print("Exiting...")
  56. break