mirror of
https://github.com/wiz0u/WTelegramClient.git
synced 2025-12-06 06:52:01 +01:00
Support additional connection JSON params with Config("init_params")
This commit is contained in:
parent
96ff52fab8
commit
3861255710
2
.github/dev.yml
vendored
2
.github/dev.yml
vendored
|
|
@ -1,7 +1,7 @@
|
||||||
pr: none
|
pr: none
|
||||||
trigger: [ master ]
|
trigger: [ master ]
|
||||||
|
|
||||||
name: 3.5.9-dev.$(Rev:r)
|
name: 3.5.10-dev.$(Rev:r)
|
||||||
|
|
||||||
pool:
|
pool:
|
||||||
vmImage: ubuntu-latest
|
vmImage: ubuntu-latest
|
||||||
|
|
|
||||||
|
|
@ -143,6 +143,7 @@ namespace WTelegram
|
||||||
"lang_code" => CultureInfo.CurrentUICulture.TwoLetterISOLanguageName,
|
"lang_code" => CultureInfo.CurrentUICulture.TwoLetterISOLanguageName,
|
||||||
"user_id" => "-1",
|
"user_id" => "-1",
|
||||||
"verification_code" or "email_verification_code" or "password" => AskConfig(what),
|
"verification_code" or "email_verification_code" or "password" => AskConfig(what),
|
||||||
|
"init_params" => "{}",
|
||||||
_ => null // api_id api_hash phone_number... it's up to you to reply to these correctly
|
_ => null // api_id api_hash phone_number... it's up to you to reply to these correctly
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -857,9 +858,11 @@ namespace WTelegram
|
||||||
await CreateAuthorizationKey(this, _dcSession);
|
await CreateAuthorizationKey(this, _dcSession);
|
||||||
|
|
||||||
var keepAliveTask = KeepAlive(_cts.Token);
|
var keepAliveTask = KeepAlive(_cts.Token);
|
||||||
|
var initParams = JSONValue.FromJsonElement(System.Text.Json.JsonSerializer.Deserialize<System.Text.Json.JsonElement>(Config("init_params")));
|
||||||
TLConfig = await this.InvokeWithLayer(Layer.Version,
|
TLConfig = await this.InvokeWithLayer(Layer.Version,
|
||||||
new TL.Methods.InitConnection<Config>
|
new TL.Methods.InitConnection<Config>
|
||||||
{
|
{
|
||||||
|
flags = TL.Methods.InitConnection<Config>.Flags.has_params,
|
||||||
api_id = _session.ApiId,
|
api_id = _session.ApiId,
|
||||||
device_model = Config("device_model"),
|
device_model = Config("device_model"),
|
||||||
system_version = Config("system_version"),
|
system_version = Config("system_version"),
|
||||||
|
|
@ -867,6 +870,7 @@ namespace WTelegram
|
||||||
system_lang_code = Config("system_lang_code"),
|
system_lang_code = Config("system_lang_code"),
|
||||||
lang_pack = Config("lang_pack"),
|
lang_pack = Config("lang_pack"),
|
||||||
lang_code = Config("lang_code"),
|
lang_code = Config("lang_code"),
|
||||||
|
params_ = initParams,
|
||||||
query = new TL.Methods.Help_GetConfig()
|
query = new TL.Methods.Help_GetConfig()
|
||||||
});
|
});
|
||||||
_session.DcOptions = TLConfig.dc_options;
|
_session.DcOptions = TLConfig.dc_options;
|
||||||
|
|
|
||||||
|
|
@ -639,7 +639,19 @@ namespace TL
|
||||||
}
|
}
|
||||||
|
|
||||||
partial class JsonObjectValue { public override string ToString() => $"{HttpUtility.JavaScriptStringEncode(key, true)}:{value}"; }
|
partial class JsonObjectValue { public override string ToString() => $"{HttpUtility.JavaScriptStringEncode(key, true)}:{value}"; }
|
||||||
partial class JSONValue { public abstract object ToNative(); }
|
partial class JSONValue { public abstract object ToNative();
|
||||||
|
private static JsonObjectValue FromJsonProperty(System.Text.Json.JsonProperty p) => new() { key = p.Name, value = FromJsonElement(p.Value) };
|
||||||
|
public static JSONValue FromJsonElement(System.Text.Json.JsonElement elem) => elem.ValueKind switch
|
||||||
|
{
|
||||||
|
System.Text.Json.JsonValueKind.True or
|
||||||
|
System.Text.Json.JsonValueKind.False => new JsonBool { value = elem.GetBoolean() },
|
||||||
|
System.Text.Json.JsonValueKind.Object => new JsonObject { value = elem.EnumerateObject().Select(FromJsonProperty).ToArray() },
|
||||||
|
System.Text.Json.JsonValueKind.Array => new JsonArray { value = elem.EnumerateArray().Select(FromJsonElement).ToArray() },
|
||||||
|
System.Text.Json.JsonValueKind.String => new JsonString { value = elem.GetString() },
|
||||||
|
System.Text.Json.JsonValueKind.Number => new JsonNumber { value = elem.GetDouble() },
|
||||||
|
_ => new JsonNull(),
|
||||||
|
};
|
||||||
|
}
|
||||||
partial class JsonNull { public override object ToNative() => null; public override string ToString() => "null"; }
|
partial class JsonNull { public override object ToNative() => null; public override string ToString() => "null"; }
|
||||||
partial class JsonBool { public override object ToNative() => value; public override string ToString() => value ? "true" : "false"; }
|
partial class JsonBool { public override object ToNative() => value; public override string ToString() => value ? "true" : "false"; }
|
||||||
partial class JsonNumber { public override object ToNative() => value; public override string ToString() => value.ToString(CultureInfo.InvariantCulture); }
|
partial class JsonNumber { public override object ToNative() => value; public override string ToString() => value.ToString(CultureInfo.InvariantCulture); }
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue