Wewordle.py 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. from __future__ import annotations
  2. import random, string, time
  3. from aiohttp import ClientSession
  4. from ..base_provider import AsyncProvider
  5. class Wewordle(AsyncProvider):
  6. url = "https://wewordle.org"
  7. working = False
  8. supports_gpt_35_turbo = True
  9. @classmethod
  10. async def create_async(
  11. cls,
  12. model: str,
  13. messages: list[dict[str, str]],
  14. proxy: str = None,
  15. **kwargs
  16. ) -> str:
  17. headers = {
  18. "accept" : "*/*",
  19. "pragma" : "no-cache",
  20. "Content-Type" : "application/json",
  21. "Connection" : "keep-alive"
  22. }
  23. _user_id = "".join(random.choices(f"{string.ascii_lowercase}{string.digits}", k=16))
  24. _app_id = "".join(random.choices(f"{string.ascii_lowercase}{string.digits}", k=31))
  25. _request_date = time.strftime("%Y-%m-%dT%H:%M:%S.000Z", time.gmtime())
  26. data = {
  27. "user" : _user_id,
  28. "messages" : messages,
  29. "subscriber": {
  30. "originalPurchaseDate" : None,
  31. "originalApplicationVersion" : None,
  32. "allPurchaseDatesMillis" : {},
  33. "entitlements" : {"active": {}, "all": {}},
  34. "allPurchaseDates" : {},
  35. "allExpirationDatesMillis" : {},
  36. "allExpirationDates" : {},
  37. "originalAppUserId" : f"$RCAnonymousID:{_app_id}",
  38. "latestExpirationDate" : None,
  39. "requestDate" : _request_date,
  40. "latestExpirationDateMillis" : None,
  41. "nonSubscriptionTransactions" : [],
  42. "originalPurchaseDateMillis" : None,
  43. "managementURL" : None,
  44. "allPurchasedProductIdentifiers": [],
  45. "firstSeen" : _request_date,
  46. "activeSubscriptions" : [],
  47. }
  48. }
  49. async with ClientSession(
  50. headers=headers
  51. ) as session:
  52. async with session.post(f"{cls.url}/gptapi/v1/android/turbo", proxy=proxy, json=data) as response:
  53. response.raise_for_status()
  54. content = (await response.json())["message"]["content"]
  55. if content:
  56. return content