Upgrade to layer 131

not available as JSON on official website https://core.telegram.org/schema
but found as TL files at https://github.com/telegramdesktop/tdesktop/tree/dev/Telegram/Resources/tl
This commit is contained in:
Wizou 2021-08-20 14:45:39 +02:00
parent 524cb71a65
commit 593463f46b
8 changed files with 3907 additions and 2712 deletions

View file

@ -1,7 +1,7 @@
[![NuGet version](https://img.shields.io/nuget/v/WTelegramClient)](https://www.nuget.org/packages/WTelegramClient/) [![NuGet version](https://img.shields.io/nuget/v/WTelegramClient)](https://www.nuget.org/packages/WTelegramClient/)
[![Dev nuget](https://img.shields.io/badge/dynamic/json?color=ffc040&label=Dev%20nuget&query=%24.versions%5B0%5D&url=https%3A%2F%2Fpkgs.dev.azure.com%2Fwiz0u%2F81bd92b7-0bb9-4701-b426-09090b27e037%2F_packaging%2F46ce0497-7803-4bd4-8c6c-030583e7c371%2Fnuget%2Fv3%2Fflat2%2Fwtelegramclient%2Findex.json)](https://dev.azure.com/wiz0u/WTelegramClient/_packaging?_a=package&feed=WTelegramClient&package=WTelegramClient&protocolType=NuGet) [![Dev nuget](https://img.shields.io/badge/dynamic/json?color=ffc040&label=Dev%20nuget&query=%24.versions%5B0%5D&url=https%3A%2F%2Fpkgs.dev.azure.com%2Fwiz0u%2F81bd92b7-0bb9-4701-b426-09090b27e037%2F_packaging%2F46ce0497-7803-4bd4-8c6c-030583e7c371%2Fnuget%2Fv3%2Fflat2%2Fwtelegramclient%2Findex.json)](https://dev.azure.com/wiz0u/WTelegramClient/_packaging?_a=package&feed=WTelegramClient&package=WTelegramClient&protocolType=NuGet)
[![Build Status](https://img.shields.io/azure-devops/build/wiz0u/WTelegramClient/7)](https://dev.azure.com/wiz0u/WTelegramClient/_build?definitionId=7) [![Build Status](https://img.shields.io/azure-devops/build/wiz0u/WTelegramClient/7)](https://dev.azure.com/wiz0u/WTelegramClient/_build?definitionId=7)
[![API Layer](https://img.shields.io/badge/API_Layer-121-blueviolet)](https://core.telegram.org/api/layers) [![API Layer](https://img.shields.io/badge/API_Layer-131-blueviolet)](https://schema.horner.tj)
[![Support Chat](https://img.shields.io/badge/Chat_with_us-on_Telegram-0088cc)](https://t.me/WTelegramClient) [![Support Chat](https://img.shields.io/badge/Chat_with_us-on_Telegram-0088cc)](https://t.me/WTelegramClient)
# <img src="logo.png" width="32"/> WTelegramClient # <img src="logo.png" width="32"/> WTelegramClient

View file

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Net.Http; using System.Net.Http;
using System.Text;
using System.Text.Json; using System.Text.Json;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -27,23 +28,74 @@ namespace WTelegram
currentLayer = await Task.FromResult(TL.Schema.Layer); currentLayer = await Task.FromResult(TL.Schema.Layer);
#else #else
using var http = new HttpClient(); using var http = new HttpClient();
var html = await http.GetStringAsync("https://core.telegram.org/api/layers"); //var html = await http.GetStringAsync("https://core.telegram.org/api/layers");
currentLayer = int.Parse(Regex.Match(html, @"#layer-(\d+)").Groups[1].Value); //currentLayer = int.Parse(Regex.Match(html, @"#layer-(\d+)").Groups[1].Value);
File.WriteAllBytes("TL.MTProto.json", await http.GetByteArrayAsync("https://core.telegram.org/schema/mtproto-json")); //File.WriteAllBytes("TL.MTProto.json", await http.GetByteArrayAsync("https://core.telegram.org/schema/mtproto-json"));
File.WriteAllBytes("TL.Schema.json", await http.GetByteArrayAsync("https://core.telegram.org/schema/json")); //File.WriteAllBytes("TL.Schema.json", await http.GetByteArrayAsync("https://core.telegram.org/schema/json"));
File.WriteAllBytes("TL.MTProto.tl", await http.GetByteArrayAsync("https://raw.githubusercontent.com/telegramdesktop/tdesktop/dev/Telegram/Resources/tl/mtproto.tl"));
File.WriteAllBytes("TL.Schema.tl", await http.GetByteArrayAsync("https://raw.githubusercontent.com/telegramdesktop/tdesktop/dev/Telegram/Resources/tl/api.tl"));
File.WriteAllBytes("TL.Secret.json", await http.GetByteArrayAsync("https://core.telegram.org/schema/end-to-end-json")); File.WriteAllBytes("TL.Secret.json", await http.GetByteArrayAsync("https://core.telegram.org/schema/end-to-end-json"));
#endif #endif
FromJson("TL.MTProto.json", "TL.MTProto.cs", @"TL.Table.cs"); //FromJson("TL.MTProto.json", "TL.MTProto.cs", @"TL.Table.cs");
FromJson("TL.Schema.json", "TL.Schema.cs", @"TL.Table.cs"); //FromJson("TL.Schema.json", "TL.Schema.cs", @"TL.Table.cs");
FromJson("TL.Secret.json", "TL.Secret.cs", @"TL.Table.cs"); FromTL("TL.MTProto.tl", "TL.MTProto.cs");
FromTL("TL.Schema.tl", "TL.Schema.cs");
FromJson("TL.Secret.json", "TL.Secret.cs");
} }
public void FromJson(string jsonPath, string outputCs, string tableCs = null) private void FromTL(string tlPath, string outputCs)
{
using var sr = new StreamReader(tlPath);
var schema = new SchemaJson { constructors = new(), methods = new() };
string line;
bool inFunctions = false;
while ((line = sr.ReadLine()) != null)
{
line = line.Trim();
if (line == "---functions---")
inFunctions = true;
else if (line == "---types---")
inFunctions = false;
else if (line.StartsWith("// LAYER "))
currentLayer = int.Parse(line[9..]);
else if (line != "" && !line.StartsWith("//"))
{
if (!line.EndsWith(";")) System.Diagnostics.Debugger.Break();
var words = line.Split(' ');
int hash = words[0].IndexOf('#');
if (hash == -1) { Console.WriteLine(line); continue; }
if (words[^2] != "=") { Console.WriteLine(line); continue; }
string name = words[0][0..hash];
int id = int.Parse(words[0][(hash + 1)..], System.Globalization.NumberStyles.HexNumber);
string type = words[^1].TrimEnd(';');
var @params = words[1..^2].Where(word => word != "{X:Type}").Select(word =>
{
int colon = word.IndexOf(':');
string name = word[0..colon];
string type = word[(colon + 1)..];
if (type == "string" && outputCs == "TL.MTProto.cs" && !name.Contains("message")) type = "bytes";
return new Param { name = name, type = type };
}).ToArray();
if (inFunctions)
schema.methods.Add(new Method { id = id.ToString(), method = name, type = type, @params = @params });
else
schema.constructors.Add(new Constructor { id = id.ToString(), predicate = name, type = type, @params = @params });
}
}
FromSchema(schema, outputCs);
}
public void FromJson(string jsonPath, string outputCs)
{ {
Console.WriteLine("Parsing " + jsonPath); Console.WriteLine("Parsing " + jsonPath);
currentJson = Path.GetFileNameWithoutExtension(jsonPath);
var schema = JsonSerializer.Deserialize<SchemaJson>(File.ReadAllText(jsonPath)); var schema = JsonSerializer.Deserialize<SchemaJson>(File.ReadAllText(jsonPath));
using var sw = File.CreateText(outputCs); FromSchema(schema, outputCs);
}
public void FromSchema(SchemaJson schema, string outputCs)
{
currentJson = Path.GetFileNameWithoutExtension(outputCs);
using var sw = new StreamWriter(outputCs, false, Encoding.UTF8);
sw.WriteLine("// This file is (mainly) generated automatically using the Generator class"); sw.WriteLine("// This file is (mainly) generated automatically using the Generator class");
sw.WriteLine("using System;"); sw.WriteLine("using System;");
if (schema.methods.Count != 0) sw.WriteLine("using System.Threading.Tasks;"); if (schema.methods.Count != 0) sw.WriteLine("using System.Threading.Tasks;");
@ -77,7 +129,12 @@ namespace WTelegram
} }
foreach (var (name, typeInfo) in typeInfos) foreach (var (name, typeInfo) in typeInfos)
{ {
if (allTypes.Contains(typeInfo.ReturnName)) { typeInfo.NeedAbstract = -2; continue; } if (allTypes.Contains(typeInfo.ReturnName))
{
if (typeInfosByLayer[0].TryGetValue(typeInfo.ReturnName, out var existingType))
typeInfo.ReturnName = existingType.ReturnName;
typeInfo.NeedAbstract = -2; continue;
}
if (typeInfo.SameName == null) if (typeInfo.SameName == null)
{ {
typeInfo.NeedAbstract = -1; typeInfo.NeedAbstract = -1;
@ -119,7 +176,7 @@ namespace WTelegram
tabIndent = tabIndent[1..]; tabIndent = tabIndent[1..];
} }
} }
if (typeInfosByLayer[0]["Message"].SameName.ID == 0x5BB8E511) typeInfosByLayer[0].Remove("Message"); if (typeInfosByLayer[0].GetValueOrDefault("Message")?.SameName.ID == 0x5BB8E511) typeInfosByLayer[0].Remove("Message");
if (schema.methods.Count != 0) if (schema.methods.Count != 0)
{ {
@ -155,7 +212,7 @@ namespace WTelegram
} }
sw.WriteLine("}"); sw.WriteLine("}");
if (tableCs != null) UpdateTable(tableCs); UpdateTable("TL.Table.cs");
} }
void WriteTypeInfo(StreamWriter sw, TypeInfo typeInfo, string layerPrefix, bool isMethod) void WriteTypeInfo(StreamWriter sw, TypeInfo typeInfo, string layerPrefix, bool isMethod)
@ -300,8 +357,6 @@ namespace WTelegram
return "ITLObject"; return "ITLObject";
else if (type == "!X") else if (type == "!X")
return "ITLFunction"; return "ITLFunction";
else if (typeInfos.TryGetValue(type, out var typeInfo))
return typeInfo.ReturnName;
else if (type == "int") else if (type == "int")
{ {
var name2 = '_' + name + '_'; var name2 = '_' + name + '_';
@ -313,8 +368,17 @@ namespace WTelegram
} }
else if (type == "string") else if (type == "string")
return name.StartsWith("md5") ? "byte[]" : "string"; return name.StartsWith("md5") ? "byte[]" : "string";
else else if (type == "long" || type == "double" || type == "X")
return type; return type;
else if (typeInfos.TryGetValue(type, out var typeInfo))
return typeInfo.ReturnName;
else
{ // try to find type in a lower layer
foreach (var layer in typeInfosByLayer.OrderByDescending(kvp => kvp.Key))
if (layer.Value.TryGetValue(type, out typeInfo))
return layer.Key == 0 ? typeInfo.ReturnName : $"Layer{layer.Key}.{typeInfo.ReturnName}";
return CSharpName(type);
}
} }
private string MapOptionalType(string type, string name) private string MapOptionalType(string type, string name)
@ -464,7 +528,7 @@ namespace WTelegram
var myTag = $"\t\t\t// from {currentJson}:"; var myTag = $"\t\t\t// from {currentJson}:";
var seen_ids = new HashSet<int>(); var seen_ids = new HashSet<int>();
using (var sr = new StreamReader(tableCs)) using (var sr = new StreamReader(tableCs))
using (var sw = new StreamWriter(tableCs + ".new")) using (var sw = new StreamWriter(tableCs + ".new", false, Encoding.UTF8))
{ {
string line; string line;
while ((line = sr.ReadLine()) != null) while ((line = sr.ReadLine()) != null)

View file

@ -108,6 +108,11 @@ namespace TL
partial class PhotoStrippedSize { public override string Type => type; } partial class PhotoStrippedSize { public override string Type => type; }
partial class PhotoSizeProgressive { public override string Type => type; } partial class PhotoSizeProgressive { public override string Type => type; }
partial class PhotoPathSize { public override string Type => type; } partial class PhotoPathSize { public override string Type => type; }
namespace Layer23
{
partial class PhotoSize { public override string Type => type; }
partial class PhotoCachedSize { public override string Type => type; }
}
partial class DocumentBase partial class DocumentBase
{ {

View file

@ -13,7 +13,8 @@ namespace TL
public long[] server_public_key_fingerprints; public long[] server_public_key_fingerprints;
} }
public abstract partial class PQInnerData : ITLObject [TLDef(0x83C95AEC)] //p_q_inner_data#83c95aec pq:bytes p:bytes q:bytes nonce:int128 server_nonce:int128 new_nonce:int256 = P_Q_inner_data
public partial class PQInnerData : ITLObject
{ {
public byte[] pq; public byte[] pq;
public byte[] p; public byte[] p;
@ -21,21 +22,37 @@ namespace TL
public Int128 nonce; public Int128 nonce;
public Int128 server_nonce; public Int128 server_nonce;
public Int256 new_nonce; public Int256 new_nonce;
public int dc;
} }
[TLDef(0xA9F55F95)] //p_q_inner_data_dc#a9f55f95 pq:bytes p:bytes q:bytes nonce:int128 server_nonce:int128 new_nonce:int256 dc:int = P_Q_inner_data [TLDef(0xA9F55F95)] //p_q_inner_data_dc#a9f55f95 pq:bytes p:bytes q:bytes nonce:int128 server_nonce:int128 new_nonce:int256 dc:int = P_Q_inner_data
public partial class PQInnerDataDc : PQInnerData { } public partial class PQInnerDataDc : PQInnerData { public int dc; }
[TLDef(0x3C6A84D4)] //p_q_inner_data_temp#3c6a84d4 pq:bytes p:bytes q:bytes nonce:int128 server_nonce:int128 new_nonce:int256 expires_in:int = P_Q_inner_data
public partial class PQInnerDataTemp : PQInnerData { public int expires_in; }
[TLDef(0x56FDDF88)] //p_q_inner_data_temp_dc#56fddf88 pq:bytes p:bytes q:bytes nonce:int128 server_nonce:int128 new_nonce:int256 dc:int expires_in:int = P_Q_inner_data [TLDef(0x56FDDF88)] //p_q_inner_data_temp_dc#56fddf88 pq:bytes p:bytes q:bytes nonce:int128 server_nonce:int128 new_nonce:int256 dc:int expires_in:int = P_Q_inner_data
public partial class PQInnerDataTempDc : PQInnerData { public int expires_in; } public partial class PQInnerDataTempDc : PQInnerData
{
public int dc;
public int expires_in;
}
public abstract partial class ServerDHParams : ITLObject { } [TLDef(0x75A3F765)] //bind_auth_key_inner#75a3f765 nonce:long temp_auth_key_id:long perm_auth_key_id:long temp_session_id:long expires_at:int = BindAuthKeyInner
[TLDef(0xD0E8075C)] //server_DH_params_ok#d0e8075c nonce:int128 server_nonce:int128 encrypted_answer:bytes = Server_DH_Params public partial class BindAuthKeyInner : ITLObject
public partial class ServerDHParamsOk : ServerDHParams {
public long nonce;
public long temp_auth_key_id;
public long perm_auth_key_id;
public long temp_session_id;
public DateTime expires_at;
}
public abstract partial class ServerDHParams : ITLObject
{ {
public Int128 nonce; public Int128 nonce;
public Int128 server_nonce; public Int128 server_nonce;
public byte[] encrypted_answer;
} }
[TLDef(0x79CB045D)] //server_DH_params_fail#79cb045d nonce:int128 server_nonce:int128 new_nonce_hash:int128 = Server_DH_Params
public partial class ServerDHParamsFail : ServerDHParams { public Int128 new_nonce_hash; }
[TLDef(0xD0E8075C)] //server_DH_params_ok#d0e8075c nonce:int128 server_nonce:int128 encrypted_answer:bytes = Server_DH_Params
public partial class ServerDHParamsOk : ServerDHParams { public byte[] encrypted_answer; }
[TLDef(0xB5890DBA)] //server_DH_inner_data#b5890dba nonce:int128 server_nonce:int128 g:int dh_prime:bytes g_a:bytes server_time:int = Server_DH_inner_data [TLDef(0xB5890DBA)] //server_DH_inner_data#b5890dba nonce:int128 server_nonce:int128 g:int dh_prime:bytes g_a:bytes server_time:int = Server_DH_inner_data
public partial class ServerDHInnerData : ITLObject public partial class ServerDHInnerData : ITLObject
@ -69,23 +86,64 @@ namespace TL
[TLDef(0xA69DAE02)] //dh_gen_fail#a69dae02 nonce:int128 server_nonce:int128 new_nonce_hash3:int128 = Set_client_DH_params_answer [TLDef(0xA69DAE02)] //dh_gen_fail#a69dae02 nonce:int128 server_nonce:int128 new_nonce_hash3:int128 = Set_client_DH_params_answer
public partial class DhGenFail : SetClientDHParamsAnswer { public Int128 new_nonce_hash3; } public partial class DhGenFail : SetClientDHParamsAnswer { public Int128 new_nonce_hash3; }
[TLDef(0x75A3F765)] //bind_auth_key_inner#75a3f765 nonce:long temp_auth_key_id:long perm_auth_key_id:long temp_session_id:long expires_at:int = BindAuthKeyInner public abstract partial class DestroyAuthKeyRes : ITLObject { }
public partial class BindAuthKeyInner : ITLObject [TLDef(0xF660E1D4)] //destroy_auth_key_ok#f660e1d4 = DestroyAuthKeyRes
{ public partial class DestroyAuthKeyOk : DestroyAuthKeyRes { }
public long nonce; [TLDef(0x0A9F2259)] //destroy_auth_key_none#0a9f2259 = DestroyAuthKeyRes
public long temp_auth_key_id; public partial class DestroyAuthKeyNone : DestroyAuthKeyRes { }
public long perm_auth_key_id; [TLDef(0xEA109B13)] //destroy_auth_key_fail#ea109b13 = DestroyAuthKeyRes
public long temp_session_id; public partial class DestroyAuthKeyFail : DestroyAuthKeyRes { }
public DateTime expires_at;
}
[TLDef(0xF35C6D01)] //rpc_result#f35c6d01 req_msg_id:long result:Object = RpcResult [TLDef(0x62D6B459)] //msgs_ack#62d6b459 msg_ids:Vector<long> = MsgsAck
public partial class RpcResult : ITLObject public partial class MsgsAck : ITLObject { public long[] msg_ids; }
[TLDef(0xA7EFF811)] //bad_msg_notification#a7eff811 bad_msg_id:long bad_msg_seqno:int error_code:int = BadMsgNotification
public partial class BadMsgNotification : ITLObject
{
public long bad_msg_id;
public int bad_msg_seqno;
public int error_code;
}
[TLDef(0xEDAB447B)] //bad_server_salt#edab447b bad_msg_id:long bad_msg_seqno:int error_code:int new_server_salt:long = BadMsgNotification
public partial class BadServerSalt : BadMsgNotification { public long new_server_salt; }
[TLDef(0xDA69FB52)] //msgs_state_req#da69fb52 msg_ids:Vector<long> = MsgsStateReq
public partial class MsgsStateReq : ITLObject { public long[] msg_ids; }
[TLDef(0x04DEB57D)] //msgs_state_info#04deb57d req_msg_id:long info:bytes = MsgsStateInfo
public partial class MsgsStateInfo : ITLObject
{ {
public long req_msg_id; public long req_msg_id;
public object result; public byte[] info;
} }
[TLDef(0x8CC0D131)] //msgs_all_info#8cc0d131 msg_ids:Vector<long> info:bytes = MsgsAllInfo
public partial class MsgsAllInfo : ITLObject
{
public long[] msg_ids;
public byte[] info;
}
public abstract partial class MsgDetailedInfoBase : ITLObject { }
[TLDef(0x276D3EC6)] //msg_detailed_info#276d3ec6 msg_id:long answer_msg_id:long bytes:int status:int = MsgDetailedInfo
public partial class MsgDetailedInfo : MsgDetailedInfoBase
{
public long msg_id;
public long answer_msg_id;
public int bytes;
public int status;
}
[TLDef(0x809DB6DF)] //msg_new_detailed_info#809db6df answer_msg_id:long bytes:int status:int = MsgDetailedInfo
public partial class MsgNewDetailedInfo : MsgDetailedInfoBase
{
public long answer_msg_id;
public int bytes;
public int status;
}
[TLDef(0x7D861A08)] //msg_resend_req#7d861a08 msg_ids:Vector<long> = MsgResendReq
public partial class MsgResendReq : ITLObject { public long[] msg_ids; }
[TLDef(0x2144CA19)] //rpc_error#2144ca19 error_code:int error_message:string = RpcError [TLDef(0x2144CA19)] //rpc_error#2144ca19 error_code:int error_message:string = RpcError
public partial class RpcError : ITLObject public partial class RpcError : ITLObject
{ {
@ -144,85 +202,39 @@ namespace TL
public long server_salt; public long server_salt;
} }
public abstract partial class MessageContainer : ITLObject { } [TLDef(0x9299359F)] //http_wait#9299359f max_delay:int wait_after:int max_wait:int = HttpWait
[TLDef(0x73F1F8DC)] //msg_container#73f1f8dc messages:vector<%Message> = MessageContainer public partial class HttpWait : ITLObject
public partial class MsgContainer : MessageContainer { public _Message[] messages; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006")]
[TLDef(0x5BB8E511)] //message#5bb8e511 msg_id:long seqno:int bytes:int body:Object = Message
public partial class _Message
{ {
public long msg_id; public int max_delay;
public int seqno; public int wait_after;
public int bytes; public int max_wait;
public ITLObject body;
} }
public abstract partial class MessageCopy : ITLObject { } [TLDef(0xD433AD73)] //ipPort#d433ad73 ipv4:int port:int = IpPort
[TLDef(0xE06046B2)] //msg_copy#e06046b2 orig_message:Message = MessageCopy public partial class IpPort : ITLObject
public partial class MsgCopy : MessageCopy { public _Message orig_message; }
[TLDef(0x3072CFA1)] //gzip_packed#3072cfa1 packed_data:bytes = Object
public partial class GzipPacked : ITLObject { public byte[] packed_data; }
[TLDef(0x62D6B459)] //msgs_ack#62d6b459 msg_ids:Vector<long> = MsgsAck
public partial class MsgsAck : ITLObject { public long[] msg_ids; }
[TLDef(0xA7EFF811)] //bad_msg_notification#a7eff811 bad_msg_id:long bad_msg_seqno:int error_code:int = BadMsgNotification
public partial class BadMsgNotification : ITLObject
{ {
public long bad_msg_id; public int ipv4;
public int bad_msg_seqno; public int port;
public int error_code;
} }
[TLDef(0xEDAB447B)] //bad_server_salt#edab447b bad_msg_id:long bad_msg_seqno:int error_code:int new_server_salt:long = BadMsgNotification [TLDef(0x37982646)] //ipPortSecret#37982646 ipv4:int port:int secret:bytes = IpPort
public partial class BadServerSalt : BadMsgNotification { public long new_server_salt; } public partial class IpPortSecret : IpPort { public byte[] secret; }
[TLDef(0x7D861A08)] //msg_resend_req#7d861a08 msg_ids:Vector<long> = MsgResendReq [TLDef(0x4679B65F)] //accessPointRule#4679b65f phone_prefix_rules:bytes dc_id:int ips:vector<IpPort> = AccessPointRule
public partial class MsgResendReq : ITLObject { public long[] msg_ids; } public partial class AccessPointRule : ITLObject
[TLDef(0xDA69FB52)] //msgs_state_req#da69fb52 msg_ids:Vector<long> = MsgsStateReq
public partial class MsgsStateReq : ITLObject { public long[] msg_ids; }
[TLDef(0x04DEB57D)] //msgs_state_info#04deb57d req_msg_id:long info:bytes = MsgsStateInfo
public partial class MsgsStateInfo : ITLObject
{ {
public long req_msg_id; public byte[] phone_prefix_rules;
public byte[] info; public int dc_id;
public IpPort[] ips;
} }
[TLDef(0x8CC0D131)] //msgs_all_info#8cc0d131 msg_ids:Vector<long> info:bytes = MsgsAllInfo [TLDef(0x5A592A6C)] //help.configSimple#5a592a6c date:int expires:int rules:vector<AccessPointRule> = help.ConfigSimple
public partial class MsgsAllInfo : ITLObject public partial class Help_ConfigSimple : ITLObject
{ {
public long[] msg_ids; public DateTime date;
public byte[] info; public DateTime expires;
public AccessPointRule[] rules;
} }
public abstract partial class MsgDetailedInfoBase : ITLObject { }
[TLDef(0x276D3EC6)] //msg_detailed_info#276d3ec6 msg_id:long answer_msg_id:long bytes:int status:int = MsgDetailedInfo
public partial class MsgDetailedInfo : MsgDetailedInfoBase
{
public long msg_id;
public long answer_msg_id;
public int bytes;
public int status;
}
[TLDef(0x809DB6DF)] //msg_new_detailed_info#809db6df answer_msg_id:long bytes:int status:int = MsgDetailedInfo
public partial class MsgNewDetailedInfo : MsgDetailedInfoBase
{
public long answer_msg_id;
public int bytes;
public int status;
}
public abstract partial class DestroyAuthKeyRes : ITLObject { }
[TLDef(0xF660E1D4)] //destroy_auth_key_ok#f660e1d4 = DestroyAuthKeyRes
public partial class DestroyAuthKeyOk : DestroyAuthKeyRes { }
[TLDef(0x0A9F2259)] //destroy_auth_key_none#0a9f2259 = DestroyAuthKeyRes
public partial class DestroyAuthKeyNone : DestroyAuthKeyRes { }
[TLDef(0xEA109B13)] //destroy_auth_key_fail#ea109b13 = DestroyAuthKeyRes
public partial class DestroyAuthKeyFail : DestroyAuthKeyRes { }
[TLDef(0x7ABE77EC)] //ping#7abe77ec ping_id:long = Pong [TLDef(0x7ABE77EC)] //ping#7abe77ec ping_id:long = Pong
public partial class Ping : ITLObject { public long ping_id; } public partial class Ping : ITLObject { public long ping_id; }
} }
@ -234,6 +246,15 @@ namespace WTelegram // ---functions---
public partial class Client public partial class Client
{ {
//req_pq#60469778 nonce:int128 = ResPQ
public Task<ResPQ> ReqPq(Int128 nonce)
=> CallBareAsync<ResPQ>(writer =>
{
writer.Write(0x60469778);
writer.Write(nonce);
return "ReqPq";
});
//req_pq_multi#be7e8ef1 nonce:int128 = ResPQ //req_pq_multi#be7e8ef1 nonce:int128 = ResPQ
public Task<ResPQ> ReqPqMulti(Int128 nonce) public Task<ResPQ> ReqPqMulti(Int128 nonce)
=> CallBareAsync<ResPQ>(writer => => CallBareAsync<ResPQ>(writer =>
@ -268,6 +289,14 @@ namespace WTelegram // ---functions---
return "SetClientDHParams"; return "SetClientDHParams";
}); });
//destroy_auth_key#d1435160 = DestroyAuthKeyRes
public Task<DestroyAuthKeyRes> DestroyAuthKey()
=> CallBareAsync<DestroyAuthKeyRes>(writer =>
{
writer.Write(0xD1435160);
return "DestroyAuthKey";
});
//rpc_drop_answer#58e4a740 req_msg_id:long = RpcDropAnswer //rpc_drop_answer#58e4a740 req_msg_id:long = RpcDropAnswer
public Task<RpcDropAnswer> RpcDropAnswer(long req_msg_id) public Task<RpcDropAnswer> RpcDropAnswer(long req_msg_id)
=> CallBareAsync<RpcDropAnswer>(writer => => CallBareAsync<RpcDropAnswer>(writer =>
@ -313,13 +342,5 @@ namespace WTelegram // ---functions---
writer.Write(session_id); writer.Write(session_id);
return "DestroySession"; return "DestroySession";
}); });
//destroy_auth_key#d1435160 = DestroyAuthKeyRes
public Task<DestroyAuthKeyRes> DestroyAuthKey()
=> CallBareAsync<DestroyAuthKeyRes>(writer =>
{
writer.Write(0xD1435160);
return "DestroyAuthKey";
});
} }
} }

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
// This file is (mainly) generated automatically using the Generator class // This file is (mainly) generated automatically using the Generator class
using System; using System;
namespace TL namespace TL
@ -256,9 +256,32 @@ namespace TL
[TLDef(0x051448E5)] [TLDef(0x051448E5)]
public partial class DocumentAttributeAudio : DocumentAttribute { public int duration; } public partial class DocumentAttributeAudio : DocumentAttribute { public int duration; }
///<summary>See <a href="https://core.telegram.org/constructor/photoSize"/></summary>
[TLDef(0x77BFB61B)]
public partial class PhotoSize : PhotoSizeBase
{
public string type;
public FileLocationBase location;
public int w;
public int h;
public int size;
}
///<summary>See <a href="https://core.telegram.org/constructor/photoCachedSize"/></summary>
[TLDef(0xE9A734FA)]
public partial class PhotoCachedSize : PhotoSizeBase
{
public string type;
public FileLocationBase location;
public int w;
public int h;
public byte[] bytes;
}
///<summary>See <a href="https://core.telegram.org/type/FileLocation"/></summary>
public abstract partial class FileLocationBase : ITLObject { }
///<summary>See <a href="https://core.telegram.org/constructor/fileLocationUnavailable"/></summary> ///<summary>See <a href="https://core.telegram.org/constructor/fileLocationUnavailable"/></summary>
[TLDef(0x7C596B46)] [TLDef(0x7C596B46)]
public partial class FileLocationUnavailable : FileLocation public partial class FileLocationUnavailable : FileLocationBase
{ {
public long volume_id; public long volume_id;
public int local_id; public int local_id;
@ -266,7 +289,7 @@ namespace TL
} }
///<summary>See <a href="https://core.telegram.org/constructor/fileLocation"/></summary> ///<summary>See <a href="https://core.telegram.org/constructor/fileLocation"/></summary>
[TLDef(0x53D69076)] [TLDef(0x53D69076)]
public partial class FileLocation_ : FileLocation public partial class FileLocation : FileLocationBase
{ {
public int dc_id; public int dc_id;
public long volume_id; public long volume_id;
@ -285,7 +308,7 @@ namespace TL
public DateTime date; public DateTime date;
public string mime_type; public string mime_type;
public int size; public int size;
public PhotoSize thumb; public PhotoSizeBase thumb;
public int dc_id; public int dc_id;
public DocumentAttribute[] attributes; public DocumentAttribute[] attributes;
} }

File diff suppressed because it is too large Load diff

View file

@ -1,12 +1,10 @@
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.IO.Compression; using System.IO.Compression;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text; using System.Text;
using WTelegram;
namespace TL namespace TL
{ {
@ -236,23 +234,11 @@ namespace TL
#endif #endif
} }
public class RpcException : Exception
{
public readonly int Code;
public RpcException(int code, string message) : base(message) => Code = code;
}
[AttributeUsage(AttributeTargets.Class)] [AttributeUsage(AttributeTargets.Class)]
public class TLDefAttribute : Attribute public class TLDefAttribute : Attribute
{ {
public readonly uint CtorNb; public readonly uint CtorNb;
public TLDefAttribute(uint ctorNb) => CtorNb = ctorNb; public TLDefAttribute(uint ctorNb) => CtorNb = ctorNb;
/*public TLDefAttribute(string def)
{
var hash = def.IndexOfAny(new[] { '#', ' ' });
CtorNb = def[hash] == ' ' ? Force.Crc32.Crc32Algorithm.Compute(System.Text.Encoding.UTF8.GetBytes(def))
: uint.Parse(def[(hash + 1)..def.IndexOf(' ', hash)], System.Globalization.NumberStyles.HexNumber);
}*/
} }
[AttributeUsage(AttributeTargets.Field)] [AttributeUsage(AttributeTargets.Field)]
@ -287,4 +273,37 @@ namespace TL
public override int GetHashCode() => HashCode.Combine(raw[0], raw[1]); public override int GetHashCode() => HashCode.Combine(raw[0], raw[1]);
public static implicit operator byte[](Int256 int256) => int256.raw; public static implicit operator byte[](Int256 int256) => int256.raw;
} }
public class RpcException : Exception
{
public readonly int Code;
public RpcException(int code, string message) : base(message) => Code = code;
}
// Below TL types are commented "parsed manually" from https://github.com/telegramdesktop/tdesktop/blob/dev/Telegram/Resources/tl/mtproto.tl
[TLDef(0xF35C6D01)] //rpc_result#f35c6d01 req_msg_id:long result:Object = RpcResult
public partial class RpcResult : ITLObject
{
public long req_msg_id;
public object result;
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006")]
[TLDef(0x5BB8E511)] //message#5bb8e511 msg_id:long seqno:int bytes:int body:Object = Message
public partial class _Message
{
public long msg_id;
public int seqno;
public int bytes;
public ITLObject body;
}
[TLDef(0x73F1F8DC)] //msg_container#73f1f8dc messages:vector<%Message> = MessageContainer
public partial class MsgContainer : ITLObject { public _Message[] messages; }
[TLDef(0xE06046B2)] //msg_copy#e06046b2 orig_message:Message = MessageCopy
public partial class MsgCopy : ITLObject { public _Message orig_message; }
[TLDef(0x3072CFA1)] //gzip_packed#3072cfa1 packed_data:bytes = Object
public partial class GzipPacked : ITLObject { public byte[] packed_data; }
} }