mirror of
https://github.com/wiz0u/WTelegramClient.git
synced 2025-12-06 06:52:01 +01:00
renamed ITLObject to IObject
This commit is contained in:
parent
fd9ec2eaed
commit
dbcb6814ff
|
|
@ -19,7 +19,7 @@ namespace WTelegramClientTest
|
||||||
client.Update += Client_Update;
|
client.Update += Client_Update;
|
||||||
Console.ReadKey();
|
Console.ReadKey();
|
||||||
|
|
||||||
async void Client_Update(ITLObject arg)
|
async void Client_Update(IObject arg)
|
||||||
{
|
{
|
||||||
if (arg is not Updates { updates: var updates }) return;
|
if (arg is not Updates { updates: var updates }) return;
|
||||||
foreach (var update in updates)
|
foreach (var update in updates)
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ namespace WTelegramClientTest
|
||||||
private static string APeer(Peer peer) => peer is null ? null : peer is PeerUser user ? AUser(user.user_id)
|
private static string APeer(Peer peer) => peer is null ? null : peer is PeerUser user ? AUser(user.user_id)
|
||||||
: peer is PeerChat chat ? AChat(chat.chat_id) : peer is PeerChannel channel ? AChat(channel.channel_id) : $"Peer {peer.ID}";
|
: peer is PeerChat chat ? AChat(chat.chat_id) : peer is PeerChannel channel ? AChat(channel.channel_id) : $"Peer {peer.ID}";
|
||||||
|
|
||||||
private static void Client_Update(ITLObject arg)
|
private static void Client_Update(IObject arg)
|
||||||
{
|
{
|
||||||
switch (arg)
|
switch (arg)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ namespace WTelegram
|
||||||
{
|
{
|
||||||
/// <summary>This event will be called when an unsollicited update/message is sent by Telegram servers</summary>
|
/// <summary>This event will be called when an unsollicited update/message is sent by Telegram servers</summary>
|
||||||
/// <remarks>See <see href="https://github.com/wiz0u/WTelegramClient/tree/master/Examples/Program_ListenUpdate.cs">Examples/Program_ListenUpdate.cs</see> for how to use this</remarks>
|
/// <remarks>See <see href="https://github.com/wiz0u/WTelegramClient/tree/master/Examples/Program_ListenUpdate.cs">Examples/Program_ListenUpdate.cs</see> for how to use this</remarks>
|
||||||
public event Action<ITLObject> Update;
|
public event Action<IObject> Update;
|
||||||
public delegate Task<TcpClient> TcpFactory(string address, int port);
|
public delegate Task<TcpClient> TcpFactory(string address, int port);
|
||||||
/// <summary>Used to create a TcpClient connected to the given address/port, or throw an exception on failure</summary>
|
/// <summary>Used to create a TcpClient connected to the given address/port, or throw an exception on failure</summary>
|
||||||
public TcpFactory TcpHandler = DefaultTcpHandler;
|
public TcpFactory TcpHandler = DefaultTcpHandler;
|
||||||
|
|
@ -44,7 +44,7 @@ namespace WTelegram
|
||||||
private static readonly byte[] IntermediateHeader = new byte[4] { 0xee, 0xee, 0xee, 0xee };
|
private static readonly byte[] IntermediateHeader = new byte[4] { 0xee, 0xee, 0xee, 0xee };
|
||||||
private TcpClient _tcpClient;
|
private TcpClient _tcpClient;
|
||||||
private NetworkStream _networkStream;
|
private NetworkStream _networkStream;
|
||||||
private ITLObject _lastSentMsg;
|
private IObject _lastSentMsg;
|
||||||
private long _lastRecvMsgId;
|
private long _lastRecvMsgId;
|
||||||
private readonly List<long> _msgsToAck = new();
|
private readonly List<long> _msgsToAck = new();
|
||||||
private readonly Random _random = new();
|
private readonly Random _random = new();
|
||||||
|
|
@ -382,7 +382,7 @@ namespace WTelegram
|
||||||
var data = new byte[MinBufferSize];
|
var data = new byte[MinBufferSize];
|
||||||
while (!cts.IsCancellationRequested)
|
while (!cts.IsCancellationRequested)
|
||||||
{
|
{
|
||||||
ITLObject obj = null;
|
IObject obj = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (await FullReadAsync(stream, data, 4, cts.Token) != 4)
|
if (await FullReadAsync(stream, data, 4, cts.Token) != 4)
|
||||||
|
|
@ -449,7 +449,7 @@ namespace WTelegram
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal ITLObject ReadFrame(byte[] data, int dataLen)
|
internal IObject ReadFrame(byte[] data, int dataLen)
|
||||||
{
|
{
|
||||||
if (dataLen == 4 && data[3] == 0xFF)
|
if (dataLen == 4 && data[3] == 0xFF)
|
||||||
{
|
{
|
||||||
|
|
@ -554,7 +554,7 @@ namespace WTelegram
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<long> SendAsync(ITLObject msg, bool isContent)
|
private async Task<long> SendAsync(IObject msg, bool isContent)
|
||||||
{
|
{
|
||||||
if (_dcSession.AuthKeyID != 0 && isContent && CheckMsgsToAck() is MsgsAck msgsAck)
|
if (_dcSession.AuthKeyID != 0 && isContent && CheckMsgsToAck() is MsgsAck msgsAck)
|
||||||
{
|
{
|
||||||
|
|
@ -723,7 +723,7 @@ namespace WTelegram
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal async Task<X> CallBareAsync<X>(ITLMethod<X> request)
|
internal async Task<X> CallBareAsync<X>(IMethod<X> request)
|
||||||
{
|
{
|
||||||
if (_bareRequest != 0) throw new ApplicationException("A bare request is already undergoing");
|
if (_bareRequest != 0) throw new ApplicationException("A bare request is already undergoing");
|
||||||
var msgId = await SendAsync(request, false);
|
var msgId = await SendAsync(request, false);
|
||||||
|
|
@ -738,7 +738,7 @@ namespace WTelegram
|
||||||
/// <typeparam name="X">Expected type of the returned object</typeparam>
|
/// <typeparam name="X">Expected type of the returned object</typeparam>
|
||||||
/// <param name="request">TL method object</param>
|
/// <param name="request">TL method object</param>
|
||||||
/// <returns>Wait for the reply and return the resulting object, or throws an RpcException if an error was replied</returns>
|
/// <returns>Wait for the reply and return the resulting object, or throws an RpcException if an error was replied</returns>
|
||||||
public async Task<X> CallAsync<X>(ITLMethod<X> request)
|
public async Task<X> CallAsync<X>(IMethod<X> request)
|
||||||
{
|
{
|
||||||
retry:
|
retry:
|
||||||
var msgId = await SendAsync(request, true);
|
var msgId = await SendAsync(request, true);
|
||||||
|
|
@ -802,7 +802,7 @@ namespace WTelegram
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static MsgContainer MakeContainer(params (ITLObject obj, (long msgId, int seqno))[] msgs)
|
private static MsgContainer MakeContainer(params (IObject obj, (long msgId, int seqno))[] msgs)
|
||||||
=> new()
|
=> new()
|
||||||
{
|
{
|
||||||
messages = msgs.Select(msg => new _Message
|
messages = msgs.Select(msg => new _Message
|
||||||
|
|
@ -813,7 +813,7 @@ namespace WTelegram
|
||||||
}).ToArray()
|
}).ToArray()
|
||||||
};
|
};
|
||||||
|
|
||||||
private async Task HandleMessageAsync(ITLObject obj)
|
private async Task HandleMessageAsync(IObject obj)
|
||||||
{
|
{
|
||||||
switch (obj)
|
switch (obj)
|
||||||
{
|
{
|
||||||
|
|
@ -890,7 +890,7 @@ namespace WTelegram
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnUpdate(ITLObject obj)
|
private void OnUpdate(IObject obj)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -1256,18 +1256,18 @@ namespace WTelegram
|
||||||
/// <summary>Enable the collection of id/access_hash pairs (experimental)</summary>
|
/// <summary>Enable the collection of id/access_hash pairs (experimental)</summary>
|
||||||
public bool CollectAccessHash { get; set; }
|
public bool CollectAccessHash { get; set; }
|
||||||
readonly Dictionary<Type, Dictionary<long, long>> _accessHashes = new();
|
readonly Dictionary<Type, Dictionary<long, long>> _accessHashes = new();
|
||||||
public IEnumerable<KeyValuePair<long, long>> AllAccessHashesFor<T>() where T : ITLObject
|
public IEnumerable<KeyValuePair<long, long>> AllAccessHashesFor<T>() where T : IObject
|
||||||
=> _accessHashes.GetValueOrDefault(typeof(T));
|
=> _accessHashes.GetValueOrDefault(typeof(T));
|
||||||
/// <summary>Retrieve the access_hash associated with this id (for a TL class) if it was collected</summary>
|
/// <summary>Retrieve the access_hash associated with this id (for a TL class) if it was collected</summary>
|
||||||
/// <remarks>This requires <see cref="CollectAccessHash"/> to be set to <see langword="true"/> first.
|
/// <remarks>This requires <see cref="CollectAccessHash"/> to be set to <see langword="true"/> first.
|
||||||
/// <br/>See <see href="https://github.com/wiz0u/WTelegramClient/tree/master/Examples/Program_CollectAccessHash.cs">Examples/Program_CollectAccessHash.cs</see> for how to use this</remarks>
|
/// <br/>See <see href="https://github.com/wiz0u/WTelegramClient/tree/master/Examples/Program_CollectAccessHash.cs">Examples/Program_CollectAccessHash.cs</see> for how to use this</remarks>
|
||||||
/// <typeparam name="T">a TL object class. For example User, Channel or Photo</typeparam>
|
/// <typeparam name="T">a TL object class. For example User, Channel or Photo</typeparam>
|
||||||
public long GetAccessHashFor<T>(long id) where T : ITLObject
|
public long GetAccessHashFor<T>(long id) where T : IObject
|
||||||
{
|
{
|
||||||
lock (_accessHashes)
|
lock (_accessHashes)
|
||||||
return _accessHashes.GetOrCreate(typeof(T)).TryGetValue(id, out var access_hash) ? access_hash : 0;
|
return _accessHashes.GetOrCreate(typeof(T)).TryGetValue(id, out var access_hash) ? access_hash : 0;
|
||||||
}
|
}
|
||||||
public void SetAccessHashFor<T>(long id, long access_hash) where T : ITLObject
|
public void SetAccessHashFor<T>(long id, long access_hash) where T : IObject
|
||||||
{
|
{
|
||||||
lock (_accessHashes)
|
lock (_accessHashes)
|
||||||
_accessHashes.GetOrCreate(typeof(T))[id] = access_hash;
|
_accessHashes.GetOrCreate(typeof(T))[id] = access_hash;
|
||||||
|
|
|
||||||
|
|
@ -224,7 +224,7 @@ namespace WTelegram
|
||||||
}
|
}
|
||||||
|
|
||||||
[TLDef(0x7A19CB76)] //RSA_public_key#7a19cb76 n:bytes e:bytes = RSAPublicKey
|
[TLDef(0x7A19CB76)] //RSA_public_key#7a19cb76 n:bytes e:bytes = RSAPublicKey
|
||||||
public partial class RSAPublicKey : ITLObject { public byte[] n, e; }
|
public partial class RSAPublicKey : IObject { public byte[] n, e; }
|
||||||
|
|
||||||
public static void LoadPublicKey(string pem)
|
public static void LoadPublicKey(string pem)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ namespace TL
|
||||||
using Client = WTelegram.Client;
|
using Client = WTelegram.Client;
|
||||||
|
|
||||||
[TLDef(0x05162463)] //resPQ#05162463 nonce:int128 server_nonce:int128 pq:bytes server_public_key_fingerprints:Vector<long> = ResPQ
|
[TLDef(0x05162463)] //resPQ#05162463 nonce:int128 server_nonce:int128 pq:bytes server_public_key_fingerprints:Vector<long> = ResPQ
|
||||||
public partial class ResPQ : ITLObject
|
public partial class ResPQ : IObject
|
||||||
{
|
{
|
||||||
public Int128 nonce;
|
public Int128 nonce;
|
||||||
public Int128 server_nonce;
|
public Int128 server_nonce;
|
||||||
|
|
@ -18,7 +18,7 @@ namespace TL
|
||||||
}
|
}
|
||||||
|
|
||||||
[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
|
[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 partial class PQInnerData : IObject
|
||||||
{
|
{
|
||||||
public byte[] pq;
|
public byte[] pq;
|
||||||
public byte[] p;
|
public byte[] p;
|
||||||
|
|
@ -45,7 +45,7 @@ namespace TL
|
||||||
}
|
}
|
||||||
|
|
||||||
[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(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 partial class BindAuthKeyInner : ITLObject
|
public partial class BindAuthKeyInner : IObject
|
||||||
{
|
{
|
||||||
public long nonce;
|
public long nonce;
|
||||||
public long temp_auth_key_id;
|
public long temp_auth_key_id;
|
||||||
|
|
@ -54,7 +54,7 @@ namespace TL
|
||||||
public DateTime expires_at;
|
public DateTime expires_at;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract partial class ServerDHParams : ITLObject
|
public abstract partial class ServerDHParams : IObject
|
||||||
{
|
{
|
||||||
public Int128 nonce;
|
public Int128 nonce;
|
||||||
public Int128 server_nonce;
|
public Int128 server_nonce;
|
||||||
|
|
@ -71,7 +71,7 @@ namespace TL
|
||||||
}
|
}
|
||||||
|
|
||||||
[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 : IObject
|
||||||
{
|
{
|
||||||
public Int128 nonce;
|
public Int128 nonce;
|
||||||
public Int128 server_nonce;
|
public Int128 server_nonce;
|
||||||
|
|
@ -82,7 +82,7 @@ namespace TL
|
||||||
}
|
}
|
||||||
|
|
||||||
[TLDef(0x6643B654)] //client_DH_inner_data#6643b654 nonce:int128 server_nonce:int128 retry_id:long g_b:bytes = Client_DH_Inner_Data
|
[TLDef(0x6643B654)] //client_DH_inner_data#6643b654 nonce:int128 server_nonce:int128 retry_id:long g_b:bytes = Client_DH_Inner_Data
|
||||||
public partial class ClientDHInnerData : ITLObject
|
public partial class ClientDHInnerData : IObject
|
||||||
{
|
{
|
||||||
public Int128 nonce;
|
public Int128 nonce;
|
||||||
public Int128 server_nonce;
|
public Int128 server_nonce;
|
||||||
|
|
@ -90,7 +90,7 @@ namespace TL
|
||||||
public byte[] g_b;
|
public byte[] g_b;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract partial class SetClientDHParamsAnswer : ITLObject
|
public abstract partial class SetClientDHParamsAnswer : IObject
|
||||||
{
|
{
|
||||||
public Int128 nonce;
|
public Int128 nonce;
|
||||||
public Int128 server_nonce;
|
public Int128 server_nonce;
|
||||||
|
|
@ -122,13 +122,13 @@ namespace TL
|
||||||
}
|
}
|
||||||
|
|
||||||
[TLDef(0x62D6B459)] //msgs_ack#62d6b459 msg_ids:Vector<long> = MsgsAck
|
[TLDef(0x62D6B459)] //msgs_ack#62d6b459 msg_ids:Vector<long> = MsgsAck
|
||||||
public partial class MsgsAck : ITLObject
|
public partial class MsgsAck : IObject
|
||||||
{
|
{
|
||||||
public long[] msg_ids;
|
public long[] msg_ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
[TLDef(0xA7EFF811)] //bad_msg_notification#a7eff811 bad_msg_id:long bad_msg_seqno:int error_code:int = BadMsgNotification
|
[TLDef(0xA7EFF811)] //bad_msg_notification#a7eff811 bad_msg_id:long bad_msg_seqno:int error_code:int = BadMsgNotification
|
||||||
public partial class BadMsgNotification : ITLObject
|
public partial class BadMsgNotification : IObject
|
||||||
{
|
{
|
||||||
public long bad_msg_id;
|
public long bad_msg_id;
|
||||||
public int bad_msg_seqno;
|
public int bad_msg_seqno;
|
||||||
|
|
@ -141,26 +141,26 @@ namespace TL
|
||||||
}
|
}
|
||||||
|
|
||||||
[TLDef(0xDA69FB52)] //msgs_state_req#da69fb52 msg_ids:Vector<long> = MsgsStateReq
|
[TLDef(0xDA69FB52)] //msgs_state_req#da69fb52 msg_ids:Vector<long> = MsgsStateReq
|
||||||
public partial class MsgsStateReq : ITLObject
|
public partial class MsgsStateReq : IObject
|
||||||
{
|
{
|
||||||
public long[] msg_ids;
|
public long[] msg_ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
[TLDef(0x04DEB57D)] //msgs_state_info#04deb57d req_msg_id:long info:bytes = MsgsStateInfo
|
[TLDef(0x04DEB57D)] //msgs_state_info#04deb57d req_msg_id:long info:bytes = MsgsStateInfo
|
||||||
public partial class MsgsStateInfo : ITLObject
|
public partial class MsgsStateInfo : IObject
|
||||||
{
|
{
|
||||||
public long req_msg_id;
|
public long req_msg_id;
|
||||||
public byte[] info;
|
public byte[] info;
|
||||||
}
|
}
|
||||||
|
|
||||||
[TLDef(0x8CC0D131)] //msgs_all_info#8cc0d131 msg_ids:Vector<long> info:bytes = MsgsAllInfo
|
[TLDef(0x8CC0D131)] //msgs_all_info#8cc0d131 msg_ids:Vector<long> info:bytes = MsgsAllInfo
|
||||||
public partial class MsgsAllInfo : ITLObject
|
public partial class MsgsAllInfo : IObject
|
||||||
{
|
{
|
||||||
public long[] msg_ids;
|
public long[] msg_ids;
|
||||||
public byte[] info;
|
public byte[] info;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract partial class MsgDetailedInfoBase : ITLObject
|
public abstract partial class MsgDetailedInfoBase : IObject
|
||||||
{
|
{
|
||||||
public abstract long AnswerMsgId { get; }
|
public abstract long AnswerMsgId { get; }
|
||||||
public abstract int Bytes { get; }
|
public abstract int Bytes { get; }
|
||||||
|
|
@ -191,19 +191,19 @@ namespace TL
|
||||||
}
|
}
|
||||||
|
|
||||||
[TLDef(0x7D861A08)] //msg_resend_req#7d861a08 msg_ids:Vector<long> = MsgResendReq
|
[TLDef(0x7D861A08)] //msg_resend_req#7d861a08 msg_ids:Vector<long> = MsgResendReq
|
||||||
public partial class MsgResendReq : ITLObject
|
public partial class MsgResendReq : IObject
|
||||||
{
|
{
|
||||||
public long[] msg_ids;
|
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 : IObject
|
||||||
{
|
{
|
||||||
public int error_code;
|
public int error_code;
|
||||||
public string error_message;
|
public string error_message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract partial class RpcDropAnswer : ITLObject { }
|
public abstract partial class RpcDropAnswer : IObject { }
|
||||||
[TLDef(0x5E2AD36E)] //rpc_answer_unknown#5e2ad36e = RpcDropAnswer
|
[TLDef(0x5E2AD36E)] //rpc_answer_unknown#5e2ad36e = RpcDropAnswer
|
||||||
public partial class RpcAnswerUnknown : RpcDropAnswer { }
|
public partial class RpcAnswerUnknown : RpcDropAnswer { }
|
||||||
[TLDef(0xCD78E586)] //rpc_answer_dropped_running#cd78e586 = RpcDropAnswer
|
[TLDef(0xCD78E586)] //rpc_answer_dropped_running#cd78e586 = RpcDropAnswer
|
||||||
|
|
@ -217,7 +217,7 @@ namespace TL
|
||||||
}
|
}
|
||||||
|
|
||||||
[TLDef(0x0949D9DC)] //future_salt#0949d9dc valid_since:int valid_until:int salt:long = FutureSalt
|
[TLDef(0x0949D9DC)] //future_salt#0949d9dc valid_since:int valid_until:int salt:long = FutureSalt
|
||||||
public partial class FutureSalt : ITLObject
|
public partial class FutureSalt : IObject
|
||||||
{
|
{
|
||||||
public DateTime valid_since;
|
public DateTime valid_since;
|
||||||
public DateTime valid_until;
|
public DateTime valid_until;
|
||||||
|
|
@ -225,7 +225,7 @@ namespace TL
|
||||||
}
|
}
|
||||||
|
|
||||||
[TLDef(0xAE500895)] //future_salts#ae500895 req_msg_id:long now:int salts:vector<future_salt> = FutureSalts
|
[TLDef(0xAE500895)] //future_salts#ae500895 req_msg_id:long now:int salts:vector<future_salt> = FutureSalts
|
||||||
public partial class FutureSalts : ITLObject
|
public partial class FutureSalts : IObject
|
||||||
{
|
{
|
||||||
public long req_msg_id;
|
public long req_msg_id;
|
||||||
public DateTime now;
|
public DateTime now;
|
||||||
|
|
@ -233,13 +233,13 @@ namespace TL
|
||||||
}
|
}
|
||||||
|
|
||||||
[TLDef(0x347773C5)] //pong#347773c5 msg_id:long ping_id:long = Pong
|
[TLDef(0x347773C5)] //pong#347773c5 msg_id:long ping_id:long = Pong
|
||||||
public partial class Pong : ITLObject
|
public partial class Pong : IObject
|
||||||
{
|
{
|
||||||
public long msg_id;
|
public long msg_id;
|
||||||
public long ping_id;
|
public long ping_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract partial class DestroySessionRes : ITLObject
|
public abstract partial class DestroySessionRes : IObject
|
||||||
{
|
{
|
||||||
public long session_id;
|
public long session_id;
|
||||||
}
|
}
|
||||||
|
|
@ -248,7 +248,7 @@ namespace TL
|
||||||
[TLDef(0x62D350C9)] //destroy_session_none#62d350c9 session_id:long = DestroySessionRes
|
[TLDef(0x62D350C9)] //destroy_session_none#62d350c9 session_id:long = DestroySessionRes
|
||||||
public partial class DestroySessionNone : DestroySessionRes { }
|
public partial class DestroySessionNone : DestroySessionRes { }
|
||||||
|
|
||||||
public abstract partial class NewSession : ITLObject { }
|
public abstract partial class NewSession : IObject { }
|
||||||
[TLDef(0x9EC20908)] //new_session_created#9ec20908 first_msg_id:long unique_id:long server_salt:long = NewSession
|
[TLDef(0x9EC20908)] //new_session_created#9ec20908 first_msg_id:long unique_id:long server_salt:long = NewSession
|
||||||
public partial class NewSessionCreated : NewSession
|
public partial class NewSessionCreated : NewSession
|
||||||
{
|
{
|
||||||
|
|
@ -258,7 +258,7 @@ namespace TL
|
||||||
}
|
}
|
||||||
|
|
||||||
[TLDef(0x9299359F)] //http_wait#9299359f max_delay:int wait_after:int max_wait:int = HttpWait
|
[TLDef(0x9299359F)] //http_wait#9299359f max_delay:int wait_after:int max_wait:int = HttpWait
|
||||||
public partial class HttpWait : ITLObject
|
public partial class HttpWait : IObject
|
||||||
{
|
{
|
||||||
public int max_delay;
|
public int max_delay;
|
||||||
public int wait_after;
|
public int wait_after;
|
||||||
|
|
@ -266,7 +266,7 @@ namespace TL
|
||||||
}
|
}
|
||||||
|
|
||||||
[TLDef(0xD433AD73)] //ipPort#d433ad73 ipv4:int port:int = IpPort
|
[TLDef(0xD433AD73)] //ipPort#d433ad73 ipv4:int port:int = IpPort
|
||||||
public partial class IpPort : ITLObject
|
public partial class IpPort : IObject
|
||||||
{
|
{
|
||||||
public int ipv4;
|
public int ipv4;
|
||||||
public int port;
|
public int port;
|
||||||
|
|
@ -278,7 +278,7 @@ namespace TL
|
||||||
}
|
}
|
||||||
|
|
||||||
[TLDef(0x4679B65F)] //accessPointRule#4679b65f phone_prefix_rules:bytes dc_id:int ips:vector<IpPort> = AccessPointRule
|
[TLDef(0x4679B65F)] //accessPointRule#4679b65f phone_prefix_rules:bytes dc_id:int ips:vector<IpPort> = AccessPointRule
|
||||||
public partial class AccessPointRule : ITLObject
|
public partial class AccessPointRule : IObject
|
||||||
{
|
{
|
||||||
public byte[] phone_prefix_rules;
|
public byte[] phone_prefix_rules;
|
||||||
public int dc_id;
|
public int dc_id;
|
||||||
|
|
@ -286,7 +286,7 @@ namespace TL
|
||||||
}
|
}
|
||||||
|
|
||||||
[TLDef(0x5A592A6C)] //help.configSimple#5a592a6c date:int expires:int rules:vector<AccessPointRule> = help.ConfigSimple
|
[TLDef(0x5A592A6C)] //help.configSimple#5a592a6c date:int expires:int rules:vector<AccessPointRule> = help.ConfigSimple
|
||||||
public partial class Help_ConfigSimple : ITLObject
|
public partial class Help_ConfigSimple : IObject
|
||||||
{
|
{
|
||||||
public DateTime date;
|
public DateTime date;
|
||||||
public DateTime expires;
|
public DateTime expires;
|
||||||
|
|
@ -298,7 +298,7 @@ namespace TL
|
||||||
public static class MTProto
|
public static class MTProto
|
||||||
{
|
{
|
||||||
[TLDef(0x60469778)] //req_pq#60469778 nonce:int128 = ResPQ
|
[TLDef(0x60469778)] //req_pq#60469778 nonce:int128 = ResPQ
|
||||||
public partial class ReqPq_ : ITLMethod<ResPQ>
|
public partial class ReqPq_ : IMethod<ResPQ>
|
||||||
{
|
{
|
||||||
public Int128 nonce;
|
public Int128 nonce;
|
||||||
}
|
}
|
||||||
|
|
@ -309,7 +309,7 @@ namespace TL
|
||||||
});
|
});
|
||||||
|
|
||||||
[TLDef(0xBE7E8EF1)] //req_pq_multi#be7e8ef1 nonce:int128 = ResPQ
|
[TLDef(0xBE7E8EF1)] //req_pq_multi#be7e8ef1 nonce:int128 = ResPQ
|
||||||
public partial class ReqPqMulti_ : ITLMethod<ResPQ>
|
public partial class ReqPqMulti_ : IMethod<ResPQ>
|
||||||
{
|
{
|
||||||
public Int128 nonce;
|
public Int128 nonce;
|
||||||
}
|
}
|
||||||
|
|
@ -320,7 +320,7 @@ namespace TL
|
||||||
});
|
});
|
||||||
|
|
||||||
[TLDef(0xD712E4BE)] //req_DH_params#d712e4be nonce:int128 server_nonce:int128 p:bytes q:bytes public_key_fingerprint:long encrypted_data:bytes = Server_DH_Params
|
[TLDef(0xD712E4BE)] //req_DH_params#d712e4be nonce:int128 server_nonce:int128 p:bytes q:bytes public_key_fingerprint:long encrypted_data:bytes = Server_DH_Params
|
||||||
public partial class ReqDHParams_ : ITLMethod<ServerDHParams>
|
public partial class ReqDHParams_ : IMethod<ServerDHParams>
|
||||||
{
|
{
|
||||||
public Int128 nonce;
|
public Int128 nonce;
|
||||||
public Int128 server_nonce;
|
public Int128 server_nonce;
|
||||||
|
|
@ -341,7 +341,7 @@ namespace TL
|
||||||
});
|
});
|
||||||
|
|
||||||
[TLDef(0xF5045F1F)] //set_client_DH_params#f5045f1f nonce:int128 server_nonce:int128 encrypted_data:bytes = Set_client_DH_params_answer
|
[TLDef(0xF5045F1F)] //set_client_DH_params#f5045f1f nonce:int128 server_nonce:int128 encrypted_data:bytes = Set_client_DH_params_answer
|
||||||
public partial class SetClientDHParams_ : ITLMethod<SetClientDHParamsAnswer>
|
public partial class SetClientDHParams_ : IMethod<SetClientDHParamsAnswer>
|
||||||
{
|
{
|
||||||
public Int128 nonce;
|
public Int128 nonce;
|
||||||
public Int128 server_nonce;
|
public Int128 server_nonce;
|
||||||
|
|
@ -356,14 +356,14 @@ namespace TL
|
||||||
});
|
});
|
||||||
|
|
||||||
[TLDef(0xD1435160)] //destroy_auth_key#d1435160 = DestroyAuthKeyRes
|
[TLDef(0xD1435160)] //destroy_auth_key#d1435160 = DestroyAuthKeyRes
|
||||||
public partial class DestroyAuthKey_ : ITLMethod<DestroyAuthKeyRes> { }
|
public partial class DestroyAuthKey_ : IMethod<DestroyAuthKeyRes> { }
|
||||||
public static Task<DestroyAuthKeyRes> DestroyAuthKey(this Client client)
|
public static Task<DestroyAuthKeyRes> DestroyAuthKey(this Client client)
|
||||||
=> client.CallBareAsync(new DestroyAuthKey_
|
=> client.CallBareAsync(new DestroyAuthKey_
|
||||||
{
|
{
|
||||||
});
|
});
|
||||||
|
|
||||||
[TLDef(0x58E4A740)] //rpc_drop_answer#58e4a740 req_msg_id:long = RpcDropAnswer
|
[TLDef(0x58E4A740)] //rpc_drop_answer#58e4a740 req_msg_id:long = RpcDropAnswer
|
||||||
public partial class RpcDropAnswer_ : ITLMethod<RpcDropAnswer>
|
public partial class RpcDropAnswer_ : IMethod<RpcDropAnswer>
|
||||||
{
|
{
|
||||||
public long req_msg_id;
|
public long req_msg_id;
|
||||||
}
|
}
|
||||||
|
|
@ -374,7 +374,7 @@ namespace TL
|
||||||
});
|
});
|
||||||
|
|
||||||
[TLDef(0xB921BD04)] //get_future_salts#b921bd04 num:int = FutureSalts
|
[TLDef(0xB921BD04)] //get_future_salts#b921bd04 num:int = FutureSalts
|
||||||
public partial class GetFutureSalts_ : ITLMethod<FutureSalts>
|
public partial class GetFutureSalts_ : IMethod<FutureSalts>
|
||||||
{
|
{
|
||||||
public int num;
|
public int num;
|
||||||
}
|
}
|
||||||
|
|
@ -385,7 +385,7 @@ namespace TL
|
||||||
});
|
});
|
||||||
|
|
||||||
[TLDef(0x7ABE77EC)] //ping#7abe77ec ping_id:long = Pong
|
[TLDef(0x7ABE77EC)] //ping#7abe77ec ping_id:long = Pong
|
||||||
public partial class Ping_ : ITLMethod<Pong>
|
public partial class Ping_ : IMethod<Pong>
|
||||||
{
|
{
|
||||||
public long ping_id;
|
public long ping_id;
|
||||||
}
|
}
|
||||||
|
|
@ -396,7 +396,7 @@ namespace TL
|
||||||
});
|
});
|
||||||
|
|
||||||
[TLDef(0xF3427B8C)] //ping_delay_disconnect#f3427b8c ping_id:long disconnect_delay:int = Pong
|
[TLDef(0xF3427B8C)] //ping_delay_disconnect#f3427b8c ping_id:long disconnect_delay:int = Pong
|
||||||
public partial class PingDelayDisconnect_ : ITLMethod<Pong>
|
public partial class PingDelayDisconnect_ : IMethod<Pong>
|
||||||
{
|
{
|
||||||
public long ping_id;
|
public long ping_id;
|
||||||
public int disconnect_delay;
|
public int disconnect_delay;
|
||||||
|
|
@ -409,7 +409,7 @@ namespace TL
|
||||||
});
|
});
|
||||||
|
|
||||||
[TLDef(0xE7512126)] //destroy_session#e7512126 session_id:long = DestroySessionRes
|
[TLDef(0xE7512126)] //destroy_session#e7512126 session_id:long = DestroySessionRes
|
||||||
public partial class DestroySession_ : ITLMethod<DestroySessionRes>
|
public partial class DestroySession_ : IMethod<DestroySessionRes>
|
||||||
{
|
{
|
||||||
public long session_id;
|
public long session_id;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
1460
src/TL.Schema.cs
1460
src/TL.Schema.cs
File diff suppressed because it is too large
Load diff
|
|
@ -8,7 +8,7 @@ namespace TL
|
||||||
using Client = WTelegram.Client;
|
using Client = WTelegram.Client;
|
||||||
|
|
||||||
/// <summary>Object describes the contents of an encrypted message. <para>See <a href="https://corefork.telegram.org/type/DecryptedMessage"/></para></summary>
|
/// <summary>Object describes the contents of an encrypted message. <para>See <a href="https://corefork.telegram.org/type/DecryptedMessage"/></para></summary>
|
||||||
public abstract partial class DecryptedMessageBase : ITLObject
|
public abstract partial class DecryptedMessageBase : IObject
|
||||||
{
|
{
|
||||||
/// <summary>Random message ID, assigned by the author of message.<br/>Must be equal to the ID passed to sending method.</summary>
|
/// <summary>Random message ID, assigned by the author of message.<br/>Must be equal to the ID passed to sending method.</summary>
|
||||||
public abstract long RandomId { get; }
|
public abstract long RandomId { get; }
|
||||||
|
|
@ -16,13 +16,13 @@ namespace TL
|
||||||
|
|
||||||
/// <summary>Object describes media contents of an encrypted message. <para>See <a href="https://corefork.telegram.org/type/DecryptedMessageMedia"/></para></summary>
|
/// <summary>Object describes media contents of an encrypted message. <para>See <a href="https://corefork.telegram.org/type/DecryptedMessageMedia"/></para></summary>
|
||||||
/// <remarks>a <c>null</c> value means <a href="https://corefork.telegram.org/constructor/decryptedMessageMediaEmpty">decryptedMessageMediaEmpty</a></remarks>
|
/// <remarks>a <c>null</c> value means <a href="https://corefork.telegram.org/constructor/decryptedMessageMediaEmpty">decryptedMessageMediaEmpty</a></remarks>
|
||||||
public abstract partial class DecryptedMessageMedia : ITLObject { }
|
public abstract partial class DecryptedMessageMedia : IObject { }
|
||||||
|
|
||||||
/// <summary>Object describes the action to which a service message is linked. <para>See <a href="https://corefork.telegram.org/type/DecryptedMessageAction"/></para></summary>
|
/// <summary>Object describes the action to which a service message is linked. <para>See <a href="https://corefork.telegram.org/type/DecryptedMessageAction"/></para></summary>
|
||||||
public abstract partial class DecryptedMessageAction : ITLObject { }
|
public abstract partial class DecryptedMessageAction : IObject { }
|
||||||
|
|
||||||
/// <summary>Indicates the location of a photo, will be deprecated soon <para>See <a href="https://corefork.telegram.org/type/FileLocation"/></para></summary>
|
/// <summary>Indicates the location of a photo, will be deprecated soon <para>See <a href="https://corefork.telegram.org/type/FileLocation"/></para></summary>
|
||||||
public abstract partial class FileLocationBase : ITLObject
|
public abstract partial class FileLocationBase : IObject
|
||||||
{
|
{
|
||||||
/// <summary>Server volume</summary>
|
/// <summary>Server volume</summary>
|
||||||
public abstract long VolumeId { get; }
|
public abstract long VolumeId { get; }
|
||||||
|
|
@ -307,7 +307,7 @@ namespace TL
|
||||||
|
|
||||||
/// <summary>Sets the layer number for the contents of an encrypted message. <para>See <a href="https://corefork.telegram.org/constructor/decryptedMessageLayer"/></para></summary>
|
/// <summary>Sets the layer number for the contents of an encrypted message. <para>See <a href="https://corefork.telegram.org/constructor/decryptedMessageLayer"/></para></summary>
|
||||||
[TLDef(0x1BE31789)]
|
[TLDef(0x1BE31789)]
|
||||||
public partial class DecryptedMessageLayer : ITLObject
|
public partial class DecryptedMessageLayer : IObject
|
||||||
{
|
{
|
||||||
/// <summary>Set of random bytes to prevent content recognition in short encrypted messages.<br/>Clients are required to check that there are at least 15 random bytes included in each message. Messages with less than 15 random bytes must be ignored.<br/>Parameter moved here from <see cref="DecryptedMessage"/> in <a href="https://corefork.telegram.org/api/layers#layer-17">Layer 17</a>.</summary>
|
/// <summary>Set of random bytes to prevent content recognition in short encrypted messages.<br/>Clients are required to check that there are at least 15 random bytes included in each message. Messages with less than 15 random bytes must be ignored.<br/>Parameter moved here from <see cref="DecryptedMessage"/> in <a href="https://corefork.telegram.org/api/layers#layer-17">Layer 17</a>.</summary>
|
||||||
public byte[] random_bytes;
|
public byte[] random_bytes;
|
||||||
|
|
|
||||||
30
src/TL.cs
30
src/TL.cs
|
|
@ -9,12 +9,12 @@ using System.Text;
|
||||||
|
|
||||||
namespace TL
|
namespace TL
|
||||||
{
|
{
|
||||||
public interface ITLObject { }
|
public interface IObject { }
|
||||||
public interface ITLMethod<ReturnType> : ITLObject { }
|
public interface IMethod<ReturnType> : IObject { }
|
||||||
|
|
||||||
public static class Serialization
|
public static class Serialization
|
||||||
{
|
{
|
||||||
internal static byte[] Serialize(this ITLObject msg)
|
internal static byte[] Serialize(this IObject msg)
|
||||||
{
|
{
|
||||||
using var memStream = new MemoryStream(1024);
|
using var memStream = new MemoryStream(1024);
|
||||||
using (var writer = new BinaryWriter(memStream))
|
using (var writer = new BinaryWriter(memStream))
|
||||||
|
|
@ -22,14 +22,14 @@ namespace TL
|
||||||
return memStream.ToArray();
|
return memStream.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static T Deserialize<T>(byte[] bytes) where T : ITLObject
|
internal static T Deserialize<T>(byte[] bytes) where T : IObject
|
||||||
{
|
{
|
||||||
using var memStream = new MemoryStream(bytes);
|
using var memStream = new MemoryStream(bytes);
|
||||||
using var reader = new BinaryReader(memStream, null);
|
using var reader = new BinaryReader(memStream, null);
|
||||||
return (T)reader.ReadTLObject();
|
return (T)reader.ReadTLObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void WriteTLObject<T>(this BinaryWriter writer, T obj) where T : ITLObject
|
internal static void WriteTLObject<T>(this BinaryWriter writer, T obj) where T : IObject
|
||||||
{
|
{
|
||||||
if (obj == null) { writer.WriteTLNull(typeof(T)); return; }
|
if (obj == null) { writer.WriteTLNull(typeof(T)); return; }
|
||||||
var type = obj.GetType();
|
var type = obj.GetType();
|
||||||
|
|
@ -49,7 +49,7 @@ namespace TL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static ITLObject ReadTLObject(this BinaryReader reader, uint ctorNb = 0)
|
internal static IObject ReadTLObject(this BinaryReader reader, uint ctorNb = 0)
|
||||||
{
|
{
|
||||||
if (ctorNb == 0) ctorNb = reader.ReadUInt32();
|
if (ctorNb == 0) ctorNb = reader.ReadUInt32();
|
||||||
if (!Layer.Table.TryGetValue(ctorNb, out var type))
|
if (!Layer.Table.TryGetValue(ctorNb, out var type))
|
||||||
|
|
@ -69,7 +69,7 @@ namespace TL
|
||||||
if (field.Name == "flags") flags = (int)value;
|
if (field.Name == "flags") flags = (int)value;
|
||||||
else if (field.Name == "access_hash") reader.Client?.UpdateAccessHash(obj, type, value);
|
else if (field.Name == "access_hash") reader.Client?.UpdateAccessHash(obj, type, value);
|
||||||
}
|
}
|
||||||
return type == typeof(GzipPacked) ? UnzipPacket((GzipPacked)obj, reader.Client) : (ITLObject)obj;
|
return type == typeof(GzipPacked) ? UnzipPacket((GzipPacked)obj, reader.Client) : (IObject)obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void WriteTLValue(this BinaryWriter writer, object value, Type valueType)
|
internal static void WriteTLValue(this BinaryWriter writer, object value, Type valueType)
|
||||||
|
|
@ -102,7 +102,7 @@ namespace TL
|
||||||
writer.Write(int128);
|
writer.Write(int128);
|
||||||
else if (value is Int256 int256)
|
else if (value is Int256 int256)
|
||||||
writer.Write(int256);
|
writer.Write(int256);
|
||||||
else if (value is ITLObject tlObject)
|
else if (value is IObject tlObject)
|
||||||
WriteTLObject(writer, tlObject);
|
WriteTLObject(writer, tlObject);
|
||||||
else
|
else
|
||||||
ShouldntBeHere();
|
ShouldntBeHere();
|
||||||
|
|
@ -290,7 +290,7 @@ namespace TL
|
||||||
writer.Write(0); // null arrays/strings are serialized as empty
|
writer.Write(0); // null arrays/strings are serialized as empty
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static ITLObject UnzipPacket(GzipPacked obj, WTelegram.Client client)
|
internal static IObject UnzipPacket(GzipPacked obj, WTelegram.Client client)
|
||||||
{
|
{
|
||||||
using var reader = new BinaryReader(new GZipStream(new MemoryStream(obj.packed_data), CompressionMode.Decompress), client);
|
using var reader = new BinaryReader(new GZipStream(new MemoryStream(obj.packed_data), CompressionMode.Decompress), client);
|
||||||
var result = reader.ReadTLObject();
|
var result = reader.ReadTLObject();
|
||||||
|
|
@ -358,7 +358,7 @@ namespace TL
|
||||||
public override string ToString() => $"RpcException: {Code} {Message}";
|
public override string ToString() => $"RpcException: {Code} {Message}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ReactorError : ITLObject
|
public class ReactorError : IObject
|
||||||
{
|
{
|
||||||
public Exception Exception;
|
public Exception Exception;
|
||||||
}
|
}
|
||||||
|
|
@ -366,7 +366,7 @@ namespace TL
|
||||||
// Below TL types are commented "parsed manually" from https://github.com/telegramdesktop/tdesktop/blob/dev/Telegram/Resources/tl/mtproto.tl
|
// 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
|
[TLDef(0xF35C6D01)] //rpc_result#f35c6d01 req_msg_id:long result:Object = RpcResult
|
||||||
public partial class RpcResult : ITLObject
|
public partial class RpcResult : IObject
|
||||||
{
|
{
|
||||||
public long req_msg_id;
|
public long req_msg_id;
|
||||||
public object result;
|
public object result;
|
||||||
|
|
@ -379,14 +379,14 @@ namespace TL
|
||||||
public long msg_id;
|
public long msg_id;
|
||||||
public int seqno;
|
public int seqno;
|
||||||
public int bytes;
|
public int bytes;
|
||||||
public ITLObject body;
|
public IObject body;
|
||||||
}
|
}
|
||||||
|
|
||||||
[TLDef(0x73F1F8DC)] //msg_container#73f1f8dc messages:vector<%Message> = MessageContainer
|
[TLDef(0x73F1F8DC)] //msg_container#73f1f8dc messages:vector<%Message> = MessageContainer
|
||||||
public partial class MsgContainer : ITLObject { public _Message[] messages; }
|
public partial class MsgContainer : IObject { public _Message[] messages; }
|
||||||
[TLDef(0xE06046B2)] //msg_copy#e06046b2 orig_message:Message = MessageCopy
|
[TLDef(0xE06046B2)] //msg_copy#e06046b2 orig_message:Message = MessageCopy
|
||||||
public partial class MsgCopy : ITLObject { public _Message orig_message; }
|
public partial class MsgCopy : IObject { public _Message orig_message; }
|
||||||
|
|
||||||
[TLDef(0x3072CFA1)] //gzip_packed#3072cfa1 packed_data:bytes = Object
|
[TLDef(0x3072CFA1)] //gzip_packed#3072cfa1 packed_data:bytes = Object
|
||||||
public partial class GzipPacked : ITLObject { public byte[] packed_data; }
|
public partial class GzipPacked : IObject { public byte[] packed_data; }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue