mirror of
https://github.com/wiz0u/WTelegramClient.git
synced 2025-12-06 06:52:01 +01:00
Handle CONNECTION_NOT_INITED
This commit is contained in:
parent
1ecd7047ef
commit
0867c044fa
2
.github/workflows/dev.yml
vendored
2
.github/workflows/dev.yml
vendored
|
|
@ -47,7 +47,7 @@ jobs:
|
|||
JSON: |
|
||||
{
|
||||
"status": "success", "complete": true, "commitMessage": ${{ toJSON(github.event.head_commit.message) }},
|
||||
"message": "{ \"commitId\": \"${{ github.event.head_commit.id }}\", \"buildNumber\": \"${{ env.VERSION }}\", \"teamProjectName\": \"${{ github.event.repository.name }}\"}"
|
||||
"message": "{ \"commitId\": \"${{ github.sha }}\", \"buildNumber\": \"${{ env.VERSION }}\", \"repoName\": \"${{ github.repository }}\"}"
|
||||
}
|
||||
run: |
|
||||
curl -X POST -H "Content-Type: application/json" -d "$JSON" ${{ secrets.DEPLOYED_WEBHOOK }}
|
||||
|
|
|
|||
|
|
@ -985,23 +985,7 @@ namespace WTelegram
|
|||
else
|
||||
{
|
||||
if (_dcSession.Layer != 0 && _dcSession.Layer != Layer.Version) _dcSession.Renew();
|
||||
var initParams = JSONValue.FromJsonElement(System.Text.Json.JsonDocument.Parse(Config("init_params")).RootElement);
|
||||
TLConfig = await this.InvokeWithLayer(Layer.Version,
|
||||
new TL.Methods.InitConnection<Config>
|
||||
{
|
||||
flags = TL.Methods.InitConnection<Config>.Flags.has_params,
|
||||
api_id = _session.ApiId,
|
||||
device_model = Config("device_model"),
|
||||
system_version = Config("system_version"),
|
||||
app_version = Config("app_version"),
|
||||
system_lang_code = Config("system_lang_code"),
|
||||
lang_pack = Config("lang_pack"),
|
||||
lang_code = Config("lang_code"),
|
||||
params_ = initParams,
|
||||
query = new TL.Methods.Help_GetConfig()
|
||||
});
|
||||
_dcSession.Layer = Layer.Version;
|
||||
_session.DcOptions = TLConfig.dc_options;
|
||||
await InitConnection();
|
||||
if (_dcSession.DataCenter == null)
|
||||
{
|
||||
_dcSession.DataCenter = _session.DcOptions.Where(dc => dc.id == TLConfig.this_dc)
|
||||
|
|
@ -1022,6 +1006,27 @@ namespace WTelegram
|
|||
Helpers.Log(2, $"Connected to {(TLConfig.test_mode ? "Test DC" : "DC")} {TLConfig.this_dc}... {TLConfig.flags & (Config.Flags)~0x18E00U}");
|
||||
}
|
||||
|
||||
private async Task InitConnection()
|
||||
{
|
||||
var initParams = JSONValue.FromJsonElement(System.Text.Json.JsonDocument.Parse(Config("init_params")).RootElement);
|
||||
TLConfig = await this.InvokeWithLayer(Layer.Version,
|
||||
new TL.Methods.InitConnection<Config>
|
||||
{
|
||||
flags = TL.Methods.InitConnection<Config>.Flags.has_params,
|
||||
api_id = _session.ApiId,
|
||||
device_model = Config("device_model"),
|
||||
system_version = Config("system_version"),
|
||||
app_version = Config("app_version"),
|
||||
system_lang_code = Config("system_lang_code"),
|
||||
lang_pack = Config("lang_pack"),
|
||||
lang_code = Config("lang_code"),
|
||||
params_ = initParams,
|
||||
query = new TL.Methods.Help_GetConfig()
|
||||
});
|
||||
_dcSession.Layer = Layer.Version;
|
||||
_session.DcOptions = TLConfig.dc_options;
|
||||
}
|
||||
|
||||
private async Task KeepAlive(CancellationToken ct)
|
||||
{
|
||||
int ping_id = _random.Next();
|
||||
|
|
@ -1615,6 +1620,11 @@ namespace WTelegram
|
|||
got503 = true;
|
||||
goto retry;
|
||||
}
|
||||
else if (code == 400 && message == "CONNECTION_NOT_INITED")
|
||||
{
|
||||
await InitConnection();
|
||||
goto retry;
|
||||
}
|
||||
else if (code == 500 && message == "AUTH_RESTART")
|
||||
{
|
||||
_session.UserId = 0; // force a full login authorization flow, next time
|
||||
|
|
|
|||
Loading…
Reference in a new issue