Skip to content

Commit b9c90aa

Browse files
authored
Refactor login method with updated properties
Updated the login payload to include new properties and capabilities.
1 parent 27c4010 commit b9c90aa

1 file changed

Lines changed: 42 additions & 32 deletions

File tree

src/Discord.php

Lines changed: 42 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public function createWss()
141141
}
142142
$ws = new AsyncTcpConnection("$gateway?encoding=json&v=9&compress=zlib-stream");
143143
$ws->headers = [
144-
'Accept-Encoding' => 'gzip, deflate, br',
144+
'Accept-Encoding' => 'gzip, deflate, br, zstd',
145145
'Accept-Language' => 'zh-CN,zh;q=0.9,en;q=0.8',
146146
'Cache-Control' => 'no-cache',
147147
'Pragma' => 'no-cache',
@@ -549,7 +549,7 @@ protected function handleHello($data)
549549

550550
protected function send($data)
551551
{
552-
$data = json_encode($data, true);
552+
$data = json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
553553
$this->gatewayConnection->send($data);
554554
}
555555

@@ -558,39 +558,49 @@ public function login()
558558
$agent = new Agent();
559559
$agent->setUserAgent($this->useragent);
560560
$platform = $agent->platform() === 'OS X' ? 'Mac OS X' : $agent->platform();
561+
561562
$data = [
562563
'op' => Discord::MESSAGE_OPTION_IDENTIFY,
563-
'd' => [
564-
'token' => $this->token,
565-
'capabilities' => 16381,
566-
'properties' => [
567-
'os' => $platform,
568-
'browser' => $agent->browser(),
569-
'device' => '',
570-
'system_locale' => 'zh-CN',
571-
'browser_user_agent' => $this->useragent,
572-
'browser_version' => $agent->version($agent->browser()),
573-
'os_version' => $agent->version($platform),
574-
'referrer' => 'https://www.midjourney.com',
575-
'referring_domain' => 'www.midjourney.com',
576-
'referrer_current' => '',
577-
'referring_domain_current' => '',
578-
'release_channel' => 'stable',
579-
'client_build_number' => 268600,
580-
'client_event_source' => null,
564+
'd' =>
565+
[
566+
'token' => $this->token,
567+
'capabilities' => 1734653,
568+
'properties' =>
569+
[
570+
'os' => $platform,
571+
'browser' => $agent->browser(),
572+
'device' => '',
573+
'system_locale' => 'zh-CN',
574+
'browser_user_agent' => $this->useragent,
575+
'browser_version' => $agent->version($agent->browser()),
576+
'os_version' => $agent->version($platform),
577+
'referrer' => '',
578+
'referring_domain' => '',
579+
'referrer_current' => '',
580+
'referring_domain_current' => '',
581+
'release_channel' => 'stable',
582+
'client_build_number' => 471091,
583+
'client_event_source' => NULL,
584+
'has_client_mods' => false,
585+
'client_launch_id' => 'fb49c6ec-a502-442e-bba3-4c6d1a56930c',
586+
'launch_signature' => 'f10465eb-1101-4087-931a-ed3ed084e578',
587+
'client_app_state' => 'focused',
588+
'is_fast_connect' => false,
589+
'gateway_connect_reasons' => 'AppSkeleton',
590+
],
591+
'presence' =>
592+
[
593+
'status' => 'unknown',
594+
'since' => 0,
595+
'activities' => [],
596+
'afk' => false,
597+
],
598+
'compress' => false,
599+
'client_state' =>
600+
[
601+
'guild_versions' => (object)[]
602+
],
581603
],
582-
'presence' => [
583-
'status' => 'online',
584-
'since' => 0,
585-
'activities' => [],
586-
'afk' => false,
587-
],
588-
'compress' => false,
589-
'client_state' => [
590-
'guild_versions' => [],
591-
'api_code_version' => 0,
592-
],
593-
],
594604
];
595605
Log::info("DISCORD:{$this->id()} WSS Send Identify");
596606
Log::debug("DISCORD:{$this->id()} WSS Send Identify\n" . json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));

0 commit comments

Comments
 (0)