constants.py 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. """Constants for the zhuce6 ChatGPT platform."""
  2. from __future__ import annotations
  3. import random
  4. from datetime import datetime
  5. from enum import Enum
  6. class AccountStatus(str, Enum):
  7. ACTIVE = "active"
  8. EXPIRED = "expired"
  9. BANNED = "banned"
  10. FAILED = "failed"
  11. class TaskStatus(str, Enum):
  12. PENDING = "pending"
  13. RUNNING = "running"
  14. COMPLETED = "completed"
  15. FAILED = "failed"
  16. CANCELLED = "cancelled"
  17. APP_NAME = "zhuce6 ChatGPT"
  18. APP_VERSION = "0.1.0"
  19. OPENAI_IMPERSONATE = "chrome120"
  20. OPENAI_USER_AGENT = (
  21. "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
  22. "(KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
  23. )
  24. OPENAI_SEC_CH_UA = '"Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"'
  25. OPENAI_SEC_CH_UA_MOBILE = "?0"
  26. OPENAI_SEC_CH_UA_PLATFORM = '"Windows"'
  27. OAUTH_CLIENT_ID = "app_X8zY6vW2pQ9tR3dE7nK1jL5gH"
  28. OAUTH_AUTH_URL = "https://auth.openai.com/oauth/authorize"
  29. OAUTH_TOKEN_URL = "https://auth.openai.com/oauth/token"
  30. OAUTH_REDIRECT_URI = "https://chatgpt.com/api/auth/callback/openai"
  31. OAUTH_SCOPE = "openid email profile offline_access model.request model.read organization.read organization.write"
  32. CHATGPT_CSRF_URL = "https://chatgpt.com/api/auth/csrf"
  33. CHATGPT_SIGNIN_URL = "https://chatgpt.com/api/auth/signin/openai"
  34. CHATGPT_SESSION_URL = "https://chatgpt.com/api/auth/session"
  35. OPENAI_API_ENDPOINTS = {
  36. "sentinel": "https://sentinel.openai.com/backend-api/sentinel/req",
  37. "signup": "https://auth.openai.com/api/accounts/authorize/continue",
  38. "register": "https://auth.openai.com/api/accounts/user/register",
  39. "password_verify": "https://auth.openai.com/api/accounts/password/verify",
  40. "send_otp": "https://auth.openai.com/api/accounts/email-otp/send",
  41. "validate_otp": "https://auth.openai.com/api/accounts/email-otp/validate",
  42. "create_account": "https://auth.openai.com/api/accounts/create_account",
  43. "select_workspace": "https://auth.openai.com/api/accounts/workspace/select",
  44. "select_organization": "https://auth.openai.com/api/accounts/organization/select",
  45. }
  46. OPENAI_PAGE_TYPES = {
  47. "EMAIL_OTP_VERIFICATION": "email_otp_verification",
  48. "PASSWORD_REGISTRATION": "password",
  49. }
  50. OTP_CODE_PATTERN = r"(?<!\d)(\d{6})(?!\d)"
  51. DEFAULT_PASSWORD_LENGTH = 12
  52. PASSWORD_CHARSET = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%&*"
  53. FIRST_NAMES = [
  54. "James",
  55. "Emma",
  56. "Noah",
  57. "Olivia",
  58. "Liam",
  59. "Sophia",
  60. "Mia",
  61. "Lucas",
  62. "Aria",
  63. "Grace",
  64. ]
  65. ERROR_MESSAGES = {
  66. "unsupported_region": "Unsupported IP location",
  67. "network_error": "Network request failed",
  68. "oauth_error": "OAuth exchange failed",
  69. }
  70. def generate_random_user_info() -> dict[str, str]:
  71. name = random.choice(FIRST_NAMES)
  72. current_year = datetime.now().year
  73. birth_year = random.randint(current_year - 45, current_year - 25)
  74. birth_month = random.randint(1, 12)
  75. if birth_month in {1, 3, 5, 7, 8, 10, 12}:
  76. birth_day = random.randint(1, 31)
  77. elif birth_month in {4, 6, 9, 11}:
  78. birth_day = random.randint(1, 30)
  79. else:
  80. birth_day = random.randint(1, 28)
  81. return {
  82. "name": name,
  83. "birthdate": f"{birth_year}-{birth_month:02d}-{birth_day:02d}",
  84. }