props.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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_launch_id": uuid.NewString(),
  28. "client_app_state": "focused",
  29. "launch_signature": uuid.NewString(),
  30. "system_locale": Locale,
  31. "release_channel": "stable",
  32. "has_client_mods": false,
  33. "referrer": "",
  34. "referrer_current": "",
  35. "referring_domain": "",
  36. "referring_domain_current": "",
  37. // These properties are only sent when identifying with the gateway and are not included in the X-Super-Properties header.
  38. "is_fast_connect": false,
  39. "gateway_connect_reasons": "AppSkeleton",
  40. }
  41. }
  42. func superProps() (string, error) {
  43. props := IdentifyProperties()
  44. delete(props, "is_fast_connect")
  45. delete(props, "gateway_connect_reasons")
  46. raw, err := json.Marshal(props)
  47. if err != nil {
  48. return "", err
  49. }
  50. return base64.StdEncoding.EncodeToString(raw), nil
  51. }