props.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package http
  2. import (
  3. "encoding/base64"
  4. "encoding/json"
  5. "github.com/diamondburned/arikawa/v3/discord"
  6. "github.com/diamondburned/arikawa/v3/gateway"
  7. "github.com/google/uuid"
  8. )
  9. const (
  10. Browser = "Chrome"
  11. BrowserVersion = "140.0.0.0"
  12. BrowserUserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36"
  13. )
  14. var (
  15. Locale = discord.EnglishUS
  16. )
  17. func IdentifyProperties() gateway.IdentifyProperties {
  18. return gateway.IdentifyProperties{
  19. gateway.IdentifyDevice: "",
  20. gateway.IdentifyOS: "Windows",
  21. "os_version": "10",
  22. gateway.IdentifyBrowser: Browser,
  23. "browser_version": BrowserVersion,
  24. "browser_user_agent": BrowserUserAgent,
  25. "client_build_number": 447677,
  26. "client_event_source": nil,
  27. "client_app_state": "focused",
  28. "client_launch_id": uuid.NewString(),
  29. "client_heartbeat_session_id": uuid.NewString(),
  30. "launch_signature": uuid.NewString(),
  31. "system_locale": Locale,
  32. "release_channel": "stable",
  33. "has_client_mods": false,
  34. "referrer": "",
  35. "referrer_current": "",
  36. "referring_domain": "",
  37. "referring_domain_current": "",
  38. // These properties are only sent when identifying with the gateway and are not included in the X-Super-Properties header.
  39. "is_fast_connect": false,
  40. "gateway_connect_reasons": "AppSkeleton",
  41. }
  42. }
  43. func getSuperProps() (string, error) {
  44. props := IdentifyProperties()
  45. delete(props, "is_fast_connect")
  46. delete(props, "gateway_connect_reasons")
  47. raw, err := json.Marshal(props)
  48. if err != nil {
  49. return "", err
  50. }
  51. return base64.StdEncoding.EncodeToString(raw), nil
  52. }