From a8a82f39a501d9c1d9f2d52b92f5e67242f87101 Mon Sep 17 00:00:00 2001 From: Paulo Rogerio Panhoto Date: Tue, 26 Dec 2017 15:27:05 -0200 Subject: [PATCH 01/30] Modifications to Session and TelegramClient to allow a customised Session object to be passed on to Telegram Client and modify, in example, IP address and port. --- TLSharp.Core/Session.cs | 19 +++++++++---------- TLSharp.Core/TelegramClient.cs | 7 ++----- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/TLSharp.Core/Session.cs b/TLSharp.Core/Session.cs index 987c5d22..f4bca817 100644 --- a/TLSharp.Core/Session.cs +++ b/TLSharp.Core/Session.cs @@ -69,13 +69,18 @@ public class Session public long LastMessageId { get; set; } public int SessionExpires { get; set; } public TLUser TLUser { get; set; } + public ISessionStore Store { get { return _store; }} private Random random; private ISessionStore _store; - public Session(ISessionStore store) + public Session(ISessionStore store, string sessionUserId) { random = new Random(); + Id = GenerateRandomUlong (); + SessionUserId = sessionUserId; + ServerAddress = defaultConnectionAddress; + Port = defaultConnectionPort; _store = store; } @@ -133,7 +138,7 @@ public static Session FromBytes(byte[] buffer, ISessionStore store, string sessi var authData = Serializers.Bytes.read(reader); - return new Session(store) + return new Session(store, sessionUserId) { AuthKey = new AuthKey(authData), Id = id, @@ -155,15 +160,9 @@ public void Save() _store.Save(this); } - public static Session TryLoadOrCreateNew(ISessionStore store, string sessionUserId) + public static Session GetSession(ISessionStore store, string sessionUserId, Session provided) { - return store.Load(sessionUserId) ?? new Session(store) - { - Id = GenerateRandomUlong(), - SessionUserId = sessionUserId, - ServerAddress = defaultConnectionAddress, - Port = defaultConnectionPort - }; + return store.Load (sessionUserId) ?? provided ?? new Session (store, sessionUserId); } private static ulong GenerateRandomUlong() diff --git a/TLSharp.Core/TelegramClient.cs b/TLSharp.Core/TelegramClient.cs index 06924869..ff9519eb 100644 --- a/TLSharp.Core/TelegramClient.cs +++ b/TLSharp.Core/TelegramClient.cs @@ -31,22 +31,19 @@ public class TelegramClient : IDisposable private TcpClientConnectionHandler _handler; public TelegramClient(int apiId, string apiHash, - ISessionStore store = null, string sessionUserId = "session", TcpClientConnectionHandler handler = null) + Session session = null, string sessionUserId = "session", TcpClientConnectionHandler handler = null) { if (apiId == default(int)) throw new MissingApiConfigurationException("API_ID"); if (string.IsNullOrEmpty(apiHash)) throw new MissingApiConfigurationException("API_HASH"); - if (store == null) - store = new FileSessionStore(); - TLContext.Init(); _apiHash = apiHash; _apiId = apiId; _handler = handler; - _session = Session.TryLoadOrCreateNew(store, sessionUserId); + _session = Session.GetSession(session?.Store ?? new FileSessionStore(), session?.SessionUserId ?? sessionUserId, session); _transport = new TcpTransport(_session.ServerAddress, _session.Port, _handler); } From a69db6ba27d66af25da2f977c9f7c2b3e876980e Mon Sep 17 00:00:00 2001 From: Paulo Rogerio Panhoto Date: Wed, 27 Dec 2017 17:32:27 -0200 Subject: [PATCH 02/30] TelegramClient exposes Session as a property so that TLUser can be retrieved by application in case the sign in process is bypassed. Example code: if (client.IsUserAuthorized()) user = client.Session.TLUser; else { /* sign in or sign up */ } --- TLSharp.Core/TelegramClient.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/TLSharp.Core/TelegramClient.cs b/TLSharp.Core/TelegramClient.cs index ff9519eb..eae8b596 100644 --- a/TLSharp.Core/TelegramClient.cs +++ b/TLSharp.Core/TelegramClient.cs @@ -30,6 +30,8 @@ public class TelegramClient : IDisposable private List dcOptions; private TcpClientConnectionHandler _handler; + public Session Session { get { return _session; } } + public TelegramClient(int apiId, string apiHash, Session session = null, string sessionUserId = "session", TcpClientConnectionHandler handler = null) { From a4a5ae4a2ec803afa3bf80a6508b9d3f924751ad Mon Sep 17 00:00:00 2001 From: Paulo Rogerio Panhoto Date: Thu, 28 Dec 2017 18:15:13 -0200 Subject: [PATCH 03/30] First update event attempt. --- TLSharp.Core/Network/MtProtoSender.cs | 69 +++++++++++++++++++-------- TLSharp.Core/TelegramClient.cs | 10 ++++ 2 files changed, 59 insertions(+), 20 deletions(-) diff --git a/TLSharp.Core/Network/MtProtoSender.cs b/TLSharp.Core/Network/MtProtoSender.cs index 795e8788..9ce05946 100644 --- a/TLSharp.Core/Network/MtProtoSender.cs +++ b/TLSharp.Core/Network/MtProtoSender.cs @@ -21,6 +21,10 @@ public class MtProtoSender private TcpTransport _transport; private Session _session; + public delegate void HandleUpdates (TeleSharp.TL.TLAbsUpdates updates); + + public event HandleUpdates UpdatesEvent; + public List needConfirmation = new List(); public MtProtoSender(TcpTransport transport, Session session) @@ -141,7 +145,7 @@ public async Task Receive(TeleSharp.TL.TLMethod request) using (var messageStream = new MemoryStream(result.Item1, false)) using (var messageReader = new BinaryReader(messageStream)) { - processMessage(result.Item2, result.Item3, messageReader, request); + await processMessage(result.Item2, result.Item3, messageReader, request); } } @@ -161,7 +165,7 @@ public async Task SendPingAsync() await Receive(pingRequest); } - private bool processMessage(ulong messageId, int sequence, BinaryReader messageReader, TeleSharp.TL.TLMethod request) + private async Task processMessage(ulong messageId, int sequence, BinaryReader messageReader, TeleSharp.TL.TLMethod request) { // TODO: check salt // TODO: check sessionid @@ -176,7 +180,7 @@ private bool processMessage(ulong messageId, int sequence, BinaryReader messageR { case 0x73f1f8dc: // container //logger.debug("MSG container"); - return HandleContainer(messageId, sequence, messageReader, request); + return await HandleContainer(messageId, sequence, messageReader, request); case 0x7abe77ec: // ping //logger.debug("MSG ping"); return HandlePing(messageId, sequence, messageReader); @@ -206,46 +210,71 @@ private bool processMessage(ulong messageId, int sequence, BinaryReader messageR return HandleRpcResult(messageId, sequence, messageReader, request); case 0x3072cfa1: // gzip_packed //logger.debug("MSG gzip_packed"); - return HandleGzipPacked(messageId, sequence, messageReader, request); + return await HandleGzipPacked(messageId, sequence, messageReader, request); case 0xe317af7e: case 0xd3f45784: case 0x2b2fbd4e: case 0x78d4dec1: case 0x725b04c3: case 0x74ae4240: - return HandleUpdate(messageId, sequence, messageReader); + return await HandleUpdate(messageId, sequence, messageReader, request); default: //logger.debug("unknown message: {0}", code); return false; } } - private bool HandleUpdate(ulong messageId, int sequence, BinaryReader messageReader) + private async Task HandleUpdate(ulong messageId, int sequence, BinaryReader messageReader, TeleSharp.TL.TLMethod request) { - return false; - - /* try { - UpdatesEvent(TL.Parse(messageReader)); - return true; + var update = ParseUpdate (messageId, messageReader); + if (update != null && UpdatesEvent != null) + UpdatesEvent(update); + await Receive (request); } - catch (Exception e) + catch { - logger.warning("update processing exception: {0}", e); - return false; } - */ + return false; + } + + private TeleSharp.TL.TLAbsUpdates ParseUpdate(ulong messageId, BinaryReader messageReader) + { + switch (messageId) + { + case 0xe317af7e: + return DecodeUpdate(messageReader); + case 0xd3f45784: + return DecodeUpdate (messageReader); + case 0x2b2fbd4e: + return DecodeUpdate (messageReader); + case 0x78d4dec1: + return DecodeUpdate (messageReader); + case 0x725b04c3: + return DecodeUpdate (messageReader); + case 0x74ae4240: + return DecodeUpdate (messageReader); + default: + return null; + } + } + + private TeleSharp.TL.TLAbsUpdates DecodeUpdate(BinaryReader messageReader) where T: TeleSharp.TL.TLAbsUpdates, new() + { + var update = new T (); + update.DeserializeBody (messageReader); + return update; } - private bool HandleGzipPacked(ulong messageId, int sequence, BinaryReader messageReader, TeleSharp.TL.TLMethod request) + private async Task HandleGzipPacked(ulong messageId, int sequence, BinaryReader messageReader, TeleSharp.TL.TLMethod request) { uint code = messageReader.ReadUInt32(); byte[] packedData = GZipStream.UncompressBuffer(Serializers.Bytes.read(messageReader)); using (MemoryStream packedStream = new MemoryStream(packedData, false)) using (BinaryReader compressedReader = new BinaryReader(packedStream)) { - processMessage(messageId, sequence, compressedReader, request); + await processMessage(messageId, sequence, compressedReader, request); } return true; @@ -496,7 +525,7 @@ private bool HandlePing(ulong messageId, int sequence, BinaryReader messageReade return false; } - private bool HandleContainer(ulong messageId, int sequence, BinaryReader messageReader, TeleSharp.TL.TLMethod request) + private async Task HandleContainer(ulong messageId, int sequence, BinaryReader messageReader, TeleSharp.TL.TLMethod request) { uint code = messageReader.ReadUInt32(); int size = messageReader.ReadInt32(); @@ -508,12 +537,12 @@ private bool HandleContainer(ulong messageId, int sequence, BinaryReader message long beginPosition = messageReader.BaseStream.Position; try { - if (!processMessage(innerMessageId, sequence, messageReader, request)) + if (!await processMessage(innerMessageId, sequence, messageReader, request)) { messageReader.BaseStream.Position = beginPosition + innerLength; } } - catch (Exception e) + catch (Exception) { // logger.error("failed to process message in contailer: {0}", e); messageReader.BaseStream.Position = beginPosition + innerLength; diff --git a/TLSharp.Core/TelegramClient.cs b/TLSharp.Core/TelegramClient.cs index eae8b596..86e248ce 100644 --- a/TLSharp.Core/TelegramClient.cs +++ b/TLSharp.Core/TelegramClient.cs @@ -30,6 +30,10 @@ public class TelegramClient : IDisposable private List dcOptions; private TcpClientConnectionHandler _handler; + public delegate void UpdatesEvent (TelegramClient source, TLAbsUpdates updates); + + public event UpdatesEvent Updates; + public Session Session { get { return _session; } } public TelegramClient(int apiId, string apiHash, @@ -59,6 +63,7 @@ public async Task ConnectAsync(bool reconnect = false) } _sender = new MtProtoSender(_transport, _session); + _sender.UpdatesEvent += _sender_UpdatesEvent; //set-up layer var config = new TLRequestGetConfig(); @@ -108,6 +113,11 @@ private async Task ReconnectToDcAsync(int dcId) } } + private void _sender_UpdatesEvent (TLAbsUpdates updates) + { + Updates (this, updates); + } + private async Task RequestWithDcMigration(TLMethod request) { var completed = false; From cf983474b43e801e35abd9aca2db1b183d329e7d Mon Sep 17 00:00:00 2001 From: Paulo Rogerio Panhoto Date: Thu, 28 Dec 2017 19:31:13 -0200 Subject: [PATCH 04/30] Fixed receive only call. * Must remove debug message "Msg code:" when feature will get complete. --- TLSharp.Core/Network/MtProtoSender.cs | 38 ++++++++++++++++++--------- TLSharp.Core/TelegramClient.cs | 5 ++++ 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/TLSharp.Core/Network/MtProtoSender.cs b/TLSharp.Core/Network/MtProtoSender.cs index 9ce05946..8fa51380 100644 --- a/TLSharp.Core/Network/MtProtoSender.cs +++ b/TLSharp.Core/Network/MtProtoSender.cs @@ -136,22 +136,35 @@ private Tuple DecodeMessage(byte[] body) return new Tuple(message, remoteMessageId, remoteSequence); } - public async Task Receive(TeleSharp.TL.TLMethod request) + public async Task Receive (TeleSharp.TL.TLMethod request) { - while (!request.ConfirmReceived) + while (!request.ConfirmReceived) { - var result = DecodeMessage((await _transport.Receieve()).Body); + var result = DecodeMessage ((await _transport.Receieve ()).Body); - using (var messageStream = new MemoryStream(result.Item1, false)) - using (var messageReader = new BinaryReader(messageStream)) + using (var messageStream = new MemoryStream (result.Item1, false)) + using (var messageReader = new BinaryReader (messageStream)) { - await processMessage(result.Item2, result.Item3, messageReader, request); + await processMessage (result.Item2, result.Item3, messageReader, request); } } return null; } + public async Task Receive() + { + var result = DecodeMessage ((await _transport.Receieve ()).Body); + + using (var messageStream = new MemoryStream (result.Item1, false)) + using (var messageReader = new BinaryReader (messageStream)) + { + await processMessage (result.Item2, result.Item3, messageReader, null); + } + + return null; + } + public async Task SendPingAsync() { var pingRequest = new PingRequest(); @@ -171,11 +184,13 @@ private async Task processMessage(ulong messageId, int sequence, BinaryRea // TODO: check sessionid // TODO: check seqno + //logger.debug("processMessage: msg_id {0}, sequence {1}, data {2}", BitConverter.ToString(((MemoryStream)messageReader.BaseStream).GetBuffer(), (int) messageReader.BaseStream.Position, (int) (messageReader.BaseStream.Length - messageReader.BaseStream.Position)).Replace("-","").ToLower()); needConfirmation.Add(messageId); uint code = messageReader.ReadUInt32(); messageReader.BaseStream.Position -= 4; + Console.WriteLine ("Msg code: {0:x8}", code); switch (code) { case 0x73f1f8dc: // container @@ -217,21 +232,20 @@ private async Task processMessage(ulong messageId, int sequence, BinaryRea case 0x78d4dec1: case 0x725b04c3: case 0x74ae4240: - return await HandleUpdate(messageId, sequence, messageReader, request); + return await HandleUpdate(code, sequence, messageReader, request); default: //logger.debug("unknown message: {0}", code); return false; } } - private async Task HandleUpdate(ulong messageId, int sequence, BinaryReader messageReader, TeleSharp.TL.TLMethod request) + private async Task HandleUpdate(uint code, int sequence, BinaryReader messageReader, TeleSharp.TL.TLMethod request) { try { - var update = ParseUpdate (messageId, messageReader); + var update = ParseUpdate (code, messageReader); if (update != null && UpdatesEvent != null) UpdatesEvent(update); - await Receive (request); } catch { @@ -239,9 +253,9 @@ private async Task HandleUpdate(ulong messageId, int sequence, BinaryReade return false; } - private TeleSharp.TL.TLAbsUpdates ParseUpdate(ulong messageId, BinaryReader messageReader) + private TeleSharp.TL.TLAbsUpdates ParseUpdate(uint code, BinaryReader messageReader) { - switch (messageId) + switch (code) { case 0xe317af7e: return DecodeUpdate(messageReader); diff --git a/TLSharp.Core/TelegramClient.cs b/TLSharp.Core/TelegramClient.cs index 86e248ce..fa0414b4 100644 --- a/TLSharp.Core/TelegramClient.cs +++ b/TLSharp.Core/TelegramClient.cs @@ -138,6 +138,11 @@ private async Task RequestWithDcMigration(TLMethod request) } } + public async Task WaitEventAsync() + { + await _sender.Receive (); + } + public bool IsUserAuthorized() { return _session.TLUser != null; From 017f5ddc1b6c7b97fbb58193305b49890cbb4bcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paulo=20Rog=C3=A9rio=20Panhoto?= Date: Fri, 29 Dec 2017 11:39:50 -0200 Subject: [PATCH 05/30] undone the 'async' changes. --- TLSharp.Core/Network/MtProtoSender.cs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/TLSharp.Core/Network/MtProtoSender.cs b/TLSharp.Core/Network/MtProtoSender.cs index 8fa51380..abee9b53 100644 --- a/TLSharp.Core/Network/MtProtoSender.cs +++ b/TLSharp.Core/Network/MtProtoSender.cs @@ -145,7 +145,7 @@ public async Task Receive (TeleSharp.TL.TLMethod request) using (var messageStream = new MemoryStream (result.Item1, false)) using (var messageReader = new BinaryReader (messageStream)) { - await processMessage (result.Item2, result.Item3, messageReader, request); + processMessage (result.Item2, result.Item3, messageReader, request); } } @@ -159,7 +159,7 @@ public async Task Receive() using (var messageStream = new MemoryStream (result.Item1, false)) using (var messageReader = new BinaryReader (messageStream)) { - await processMessage (result.Item2, result.Item3, messageReader, null); + processMessage (result.Item2, result.Item3, messageReader, null); } return null; @@ -178,7 +178,7 @@ public async Task SendPingAsync() await Receive(pingRequest); } - private async Task processMessage(ulong messageId, int sequence, BinaryReader messageReader, TeleSharp.TL.TLMethod request) + private bool processMessage(ulong messageId, int sequence, BinaryReader messageReader, TeleSharp.TL.TLMethod request) { // TODO: check salt // TODO: check sessionid @@ -195,7 +195,7 @@ private async Task processMessage(ulong messageId, int sequence, BinaryRea { case 0x73f1f8dc: // container //logger.debug("MSG container"); - return await HandleContainer(messageId, sequence, messageReader, request); + return HandleContainer(messageId, sequence, messageReader, request); case 0x7abe77ec: // ping //logger.debug("MSG ping"); return HandlePing(messageId, sequence, messageReader); @@ -225,21 +225,21 @@ private async Task processMessage(ulong messageId, int sequence, BinaryRea return HandleRpcResult(messageId, sequence, messageReader, request); case 0x3072cfa1: // gzip_packed //logger.debug("MSG gzip_packed"); - return await HandleGzipPacked(messageId, sequence, messageReader, request); + return HandleGzipPacked(messageId, sequence, messageReader, request); case 0xe317af7e: case 0xd3f45784: case 0x2b2fbd4e: case 0x78d4dec1: case 0x725b04c3: case 0x74ae4240: - return await HandleUpdate(code, sequence, messageReader, request); + return HandleUpdate(code, sequence, messageReader, request); default: //logger.debug("unknown message: {0}", code); return false; } } - private async Task HandleUpdate(uint code, int sequence, BinaryReader messageReader, TeleSharp.TL.TLMethod request) + private bool HandleUpdate(uint code, int sequence, BinaryReader messageReader, TeleSharp.TL.TLMethod request) { try { @@ -281,14 +281,14 @@ private TeleSharp.TL.TLAbsUpdates ParseUpdate(uint code, BinaryReader messageRea return update; } - private async Task HandleGzipPacked(ulong messageId, int sequence, BinaryReader messageReader, TeleSharp.TL.TLMethod request) + private bool HandleGzipPacked(ulong messageId, int sequence, BinaryReader messageReader, TeleSharp.TL.TLMethod request) { uint code = messageReader.ReadUInt32(); byte[] packedData = GZipStream.UncompressBuffer(Serializers.Bytes.read(messageReader)); using (MemoryStream packedStream = new MemoryStream(packedData, false)) using (BinaryReader compressedReader = new BinaryReader(packedStream)) { - await processMessage(messageId, sequence, compressedReader, request); + processMessage(messageId, sequence, compressedReader, request); } return true; @@ -539,7 +539,7 @@ private bool HandlePing(ulong messageId, int sequence, BinaryReader messageReade return false; } - private async Task HandleContainer(ulong messageId, int sequence, BinaryReader messageReader, TeleSharp.TL.TLMethod request) + private bool HandleContainer(ulong messageId, int sequence, BinaryReader messageReader, TeleSharp.TL.TLMethod request) { uint code = messageReader.ReadUInt32(); int size = messageReader.ReadInt32(); @@ -551,7 +551,7 @@ private async Task HandleContainer(ulong messageId, int sequence, BinaryRe long beginPosition = messageReader.BaseStream.Position; try { - if (!await processMessage(innerMessageId, sequence, messageReader, request)) + if (!processMessage(innerMessageId, sequence, messageReader, request)) { messageReader.BaseStream.Position = beginPosition + innerLength; } From f871597de793408f71febda65f0ec8d54d74c905 Mon Sep 17 00:00:00 2001 From: Paulo Rogerio Panhoto Date: Tue, 2 Jan 2018 18:04:21 -0200 Subject: [PATCH 06/30] API modified to receive events instead of relying on polling to update chats. --- TLSharp.Core/Network/MtProtoSender.cs | 31 ++++++++++++++++----------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/TLSharp.Core/Network/MtProtoSender.cs b/TLSharp.Core/Network/MtProtoSender.cs index abee9b53..37a57fd4 100644 --- a/TLSharp.Core/Network/MtProtoSender.cs +++ b/TLSharp.Core/Network/MtProtoSender.cs @@ -18,6 +18,8 @@ public class MtProtoSender { //private ulong sessionId = GenerateRandomUlong(); + private readonly uint UpdatesTooLongID = (uint) new TeleSharp.TL.TLUpdatesTooLong ().Constructor; + private TcpTransport _transport; private Session _session; @@ -190,7 +192,6 @@ private bool processMessage(ulong messageId, int sequence, BinaryReader messageR uint code = messageReader.ReadUInt32(); messageReader.BaseStream.Position -= 4; - Console.WriteLine ("Msg code: {0:x8}", code); switch (code) { case 0x73f1f8dc: // container @@ -227,14 +228,15 @@ private bool processMessage(ulong messageId, int sequence, BinaryReader messageR //logger.debug("MSG gzip_packed"); return HandleGzipPacked(messageId, sequence, messageReader, request); case 0xe317af7e: - case 0xd3f45784: - case 0x2b2fbd4e: + case 0x914fbf11: + case 0x16812688: case 0x78d4dec1: case 0x725b04c3: case 0x74ae4240: + case 0x11f1331c: return HandleUpdate(code, sequence, messageReader, request); default: - //logger.debug("unknown message: {0}", code); + Console.WriteLine ("Msg code: {0:x8}", code); return false; } } @@ -244,11 +246,14 @@ private bool HandleUpdate(uint code, int sequence, BinaryReader messageReader, T try { var update = ParseUpdate (code, messageReader); - if (update != null && UpdatesEvent != null) - UpdatesEvent(update); + if (update != null && UpdatesEvent != null) + { + UpdatesEvent (update); + } } - catch + catch (Exception ex) { + Console.WriteLine (ex); } return false; } @@ -259,9 +264,9 @@ private TeleSharp.TL.TLAbsUpdates ParseUpdate(uint code, BinaryReader messageRea { case 0xe317af7e: return DecodeUpdate(messageReader); - case 0xd3f45784: + case 0x914fbf11: return DecodeUpdate (messageReader); - case 0x2b2fbd4e: + case 0x16812688: return DecodeUpdate (messageReader); case 0x78d4dec1: return DecodeUpdate (messageReader); @@ -269,15 +274,17 @@ private TeleSharp.TL.TLAbsUpdates ParseUpdate(uint code, BinaryReader messageRea return DecodeUpdate (messageReader); case 0x74ae4240: return DecodeUpdate (messageReader); + case 0x11f1331c: + return DecodeUpdate (messageReader); default: return null; } } - private TeleSharp.TL.TLAbsUpdates DecodeUpdate(BinaryReader messageReader) where T: TeleSharp.TL.TLAbsUpdates, new() + private TeleSharp.TL.TLAbsUpdates DecodeUpdate(BinaryReader messageReader) where T: TeleSharp.TL.TLAbsUpdates { - var update = new T (); - update.DeserializeBody (messageReader); + var ms = messageReader.BaseStream as MemoryStream; + var update = (T) TeleSharp.TL.ObjectUtils.DeserializeObject (messageReader); return update; } From 76362061f6f31d1d374972f9992bdfdf8442ff93 Mon Sep 17 00:00:00 2001 From: Paulo Rogerio Panhoto Date: Wed, 3 Jan 2018 19:38:47 -0200 Subject: [PATCH 07/30] Updated nuget packages --- TLSharp.Core/packages.config | 1 - TLSharp.Tests.NUnit/TLSharp.Tests.NUnit.csproj | 6 ++---- TLSharp.Tests.NUnit/packages.config | 2 +- TeleSharp.Generator/TeleSharp.Generator.csproj | 7 +++---- TeleSharp.Generator/packages.config | 2 +- 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/TLSharp.Core/packages.config b/TLSharp.Core/packages.config index 00518560..204475cd 100644 --- a/TLSharp.Core/packages.config +++ b/TLSharp.Core/packages.config @@ -1,5 +1,4 @@  - \ No newline at end of file diff --git a/TLSharp.Tests.NUnit/TLSharp.Tests.NUnit.csproj b/TLSharp.Tests.NUnit/TLSharp.Tests.NUnit.csproj index e947f4e9..761b473b 100644 --- a/TLSharp.Tests.NUnit/TLSharp.Tests.NUnit.csproj +++ b/TLSharp.Tests.NUnit/TLSharp.Tests.NUnit.csproj @@ -30,7 +30,7 @@ - ..\packages\NUnit.2.6.4\lib\nunit.framework.dll + ..\packages\NUnit.3.9.0\lib\net45\nunit.framework.dll @@ -40,11 +40,9 @@ app.config - - - + {DE5C0467-EE99-4734-95F2-EFF7A0B99924} diff --git a/TLSharp.Tests.NUnit/packages.config b/TLSharp.Tests.NUnit/packages.config index c714ef3a..967e817f 100644 --- a/TLSharp.Tests.NUnit/packages.config +++ b/TLSharp.Tests.NUnit/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/TeleSharp.Generator/TeleSharp.Generator.csproj b/TeleSharp.Generator/TeleSharp.Generator.csproj index 94f3e9b3..b90bc141 100644 --- a/TeleSharp.Generator/TeleSharp.Generator.csproj +++ b/TeleSharp.Generator/TeleSharp.Generator.csproj @@ -33,10 +33,6 @@ 4 - - ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll - True - @@ -45,6 +41,9 @@ + + ..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll + diff --git a/TeleSharp.Generator/packages.config b/TeleSharp.Generator/packages.config index 9d64bf36..ee51c237 100644 --- a/TeleSharp.Generator/packages.config +++ b/TeleSharp.Generator/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file From 42ace63b28c0e224984ddf6e100edfd2626f1fd8 Mon Sep 17 00:00:00 2001 From: ppanhoto78 Date: Thu, 4 Jan 2018 19:39:26 -0200 Subject: [PATCH 08/30] Update README.md Changed to highlight the changes to the fork. --- README.md | 485 +++++++++++++++++++++++++++--------------------------- 1 file changed, 245 insertions(+), 240 deletions(-) diff --git a/README.md b/README.md index 6605bbc6..747ca4ce 100644 --- a/README.md +++ b/README.md @@ -7,255 +7,260 @@ TLSharp [![NuGet version](https://badge.fury.io/nu/TLSharp.svg)](https://badge.fury.io/nu/TLSharp) -_Unofficial_ Telegram (http://telegram.org) client library implemented in C#. Latest TL scheme supported, thanks to Afshin Arani +_Unofficial_ Telegram (http://telegram.org) client library implemented in C#. Please refer to (https://github.com/sochix/TLSharp) for the original version and further documentation. -It's a perfect fit for any developer who would like to send data directly to Telegram users or write own custom Telegram client. - -:star2: If you :heart: library, please star it! :star2: - -# News -* **JavaScript Telegram Client** - - Hi everyone! I want to create JavaScript client for Telegram, it will have next features: - - * send & receieve messages from users/groups/channels - * easy installation with npm or yarn - * latest Telegram Schema - * examples and documentation - - If you like this idea, please leave your email [here](http://eepurl.com/cBXX8n). - -* **TLSharp GUI** - - If you have difficulties with console or writing code, you can try [Telegram Tools](https://github.com/sochix/telegram-tools). It's a GUI for TLSharp. - -# Table of contents - -- [How do I add this to my project?](#how-do-i-add-this-to-my-project) -- [Dependencies](#dependencies) -- [Starter Guide](#starter-guide) - - [Quick configuration](#quick-configuration) - - [First requests](#first-requests) - - [Working with files](#working-with-files) -- [Available Methods](#available-methods) -- [Contributing](#contributing) -- [FAQ](#faq) -- [Donations](#donations) -- [License](#license) - -# How do I add this to my project? - -Install via NuGet - -``` - > Install-Package TLSharp -``` - -or build from source - -1. Clone TLSharp from GitHub -1. Compile source with VS2015 or MonoDevelop -1. Add reference to ```TLSharp.Core.dll``` to your awesome project. - -# Dependencies - -TLSharp has a few dependenices, most of functionality implemented from scratch. -All dependencies listed in [package.conf file](https://github.com/sochix/TLSharp/blob/master/TLSharp.Core/packages.config). - -# Starter Guide - -## Quick Configuration -Telegram API isn't that easy to start. You need to do some configuration first. - -1. Create a [developer account](https://my.telegram.org/) in Telegram. -1. Goto [API development tools](https://my.telegram.org/apps) and copy **API_ID** and **API_HASH** from your account. You'll need it later. - -## First requests -To start work, create an instance of TelegramClient and establish connection - -```csharp - var client = new TelegramClient(apiId, apiHash); - await client.ConnectAsync(); -``` -Now you can work with Telegram API, but -> -> Only a small portion of the API methods are available to unauthorized users. ([full description](https://core.telegram.org/api/auth)) - -For authentication you need to run following code -```csharp - var hash = await client.SendCodeRequestAsync(""); - var code = ""; // you can change code in debugger - - var user = await client.MakeAuthAsync("", hash, code); -``` - -Full code you can see at [AuthUser test](https://github.com/sochix/TLSharp/blob/master/TLSharp.Tests/TLSharpTests.cs#L70) - -When user is authenticated, TLSharp creates special file called _session.dat_. In this file TLSharp store all information needed for user session. So you need to authenticate user every time the _session.dat_ file is corrupted or removed. - -You can call any method on authenticated user. For example, let's send message to a friend by his phone number: - -```csharp - //get available contacts - var result = await client.GetContactsAsync(); - - //find recipient in contacts - var user = result.Users.lists - .Where(x => x.GetType() == typeof (TLUser)) - .Cast() - .FirstOrDefault(x => x.phone == ""); - - //send message - await client.SendMessageAsync(new TLInputPeerUser() {user_id = user.id}, "OUR_MESSAGE"); -``` - -Full code you can see at [SendMessage test](https://github.com/sochix/TLSharp/blob/master/TLSharp.Tests/TLSharpTests.cs#L87) - -To send message to channel you could use the following code: -```csharp - //get user dialogs - var dialogs = await client.GetUserDialogsAsync(); - - //find channel by title - var chat = dialogs.chats.lists - .Where(c => c.GetType() == typeof(TLChannel)) - .Cast() - .FirstOrDefault(c => c.title == ""); - - //send message - await client.SendMessageAsync(new TLInputPeerChannel() { channel_id = chat.id, access_hash = chat.access_hash.Value }, "OUR_MESSAGE"); -``` -Full code you can see at [SendMessageToChannel test](https://github.com/sochix/TLSharp/blob/master/TLSharp.Tests/TLSharpTests.cs#L107) -## Working with files -Telegram separate files to two categories -> big file and small file. File is Big if its size more than 10 Mb. TLSharp tries to hide this complexity from you, thats why we provide one method to upload files **UploadFile**. - -```csharp - var fileResult = await client.UploadFile("cat.jpg", new StreamReader("data/cat.jpg")); -``` - -TLSharp provides two wrappers for sending photo and document - -```csharp - await client.SendUploadedPhoto(new TLInputPeerUser() { user_id = user.id }, fileResult, "kitty"); - await client.SendUploadedDocument( - new TLInputPeerUser() { user_id = user.id }, - fileResult, - "some zips", //caption - "application/zip", //mime-type - new TLVector()); //document attributes, such as file name -``` -Full code you can see at [SendPhotoToContactTest](https://github.com/sochix/TLSharp/blob/master/TLSharp.Tests/TLSharpTests.cs#L125) and [SendBigFileToContactTest](https://github.com/sochix/TLSharp/blob/master/TLSharp.Tests/TLSharpTests.cs#L143) - -To download file you should call **GetFile** method +# Sample code ```csharp - await client.GetFile( - new TLInputDocumentFileLocation() +using System; +using System.Threading.Tasks; +using TeleSharp.TL; +using TLSharp.Core; +using System.Linq; +using TeleSharp.TL.Messages; +using System.Collections.Generic; + +namespace TLSharpPOC +{ + class MainClass + { + const int APIId = 0; + const string APIHash = "???"; + const string phone = "???"; + public static void Main(string[] args) + { + new MainClass().MainAsync(args).Wait(); + } + + private readonly Dictionary ContactList; + + private async Task MainAsync(string[] args) + { + TelegramClient client = null; + try + { + // -- if necessary, IP can be changed so the client can connect to the test network. + Session session = null; + // new Session(new FileSessionStore(), "session") + //{ + // ServerAddress = "149.154.175.10", + // Port = 443 + //}; + //Console.WriteLine($"{session.ServerAddress}:{session.Port} {phone}"); + client = new TelegramClient(APIId, APIHash, session); + // subscribe an event to receive live messages + client.Updates += Client_Updates; + await client.ConnectAsync(); + Console.WriteLine($"Authorised: {client.IsUserAuthorized()}"); + TLUser user = null; + // -- If the user has already authenticated, this step will prevent account from being blocked as it + // -- reuses the data from last authorisation. + if (client.IsUserAuthorized()) + user = client.Session.TLUser; + else { - access_hash = document.access_hash, - id = document.id, - version = document.version - }, - document.size); //size of fileChunk you want to retrieve -``` - -Full code you can see at [DownloadFileFromContactTest](https://github.com/sochix/TLSharp/blob/master/TLSharp.Tests/TLSharpTests.cs#L167) - -# Available Methods - -For your convenience TLSharp have wrappers for several Telegram API methods. You could add your own, see details below. - -1. IsPhoneRegisteredAsync -1. SendCodeRequestAsync -1. MakeAuthAsync -1. SignUpAsync -1. GetContactsAsync -1. SendMessageAsync -1. SendTypingAsync -1. GetUserDialogsAsync -1. SendUploadedPhoto -1. SendUploadedDocument -1. GetFile -1. UploadFile -1. SendPingAsync -1. GetHistoryAsync - -**What if you can't find needed method at the list?** - -Don't panic. You can call any method with help of `SendRequestAsync` function. For example, send user typing method: - -```csharp - - //Create request - var req = new TLRequestSetTyping() - { - action = new TLSendMessageTypingAction(), - peer = peer - }; - - //run request, and deserialize response to Boolean - return await SendRequestAsync(req); -``` - -**Where you can find a list of requests and its params?** - -The only way is [Telegram API docs](https://core.telegram.org/methods). Yes, it's outdated. But there is no other source. -Latest scheme in JSON format you can find [here](https://gist.github.com/aarani/b22b7cda024973dff68e1672794b0298) - -# Contributing - -Contributing is highly appreciated! Donations required - -## What things can I Implement (Project Roadmap)? - -### Release 1.0.0 - -* [DONE] Add PHONE_MIGRATE handling -* [DONE] Add FILE_MIGRATE handling -* Add Updates handling -* [DONE] Add NuGet package -* [DONE] Add wrappers for media uploading and downloading -* Store user session as JSON - -# FAQ - -#### What API layer is supported? -The latest one - 66. Thanks to Afshin Arani for his TLGenerator - -#### I get a xxxMigrationException or a MIGRATE_X error! - -TLSharp library should automatically handle these errors. If you see such errors, please open a new Github issue with the details (include a stacktrace, etc.). - -#### I get an exception: System.IO.EndOfStreamException: Unable to read beyond the end of the stream. All test methos except that AuthenticationWorks and TestConnection return same error. I did every thing including setting api id and hash, and setting server address.- - -You should create a Telegram session. See [configuration guide](#sending-messages-set-up) - -#### Why do I get a FloodException/FLOOD_WAIT error? -It's likely [Telegram restrictions](https://core.telegram.org/api/errors#420-flood), or a bug in TLSharp (if you feel it's the latter, please open a Github issue). You can know the time to wait by accessing the FloodException::TimeToWait property. - -#### Why does TLSharp lacks feature XXXX? - -Now TLSharp is basic realization of Telegram protocol, you can be a contributor or a sponsor to speed-up developemnt of any feature. - -#### Nothing helps -Ask your question at gitter or create an issue in project bug tracker. + var registered = await client.IsPhoneRegisteredAsync(phone); + var hash = await client.SendCodeRequestAsync(phone); + Console.Write("Code: "); + var code = Console.ReadLine(); + if (!registered) + { + Console.WriteLine($"Sign up {phone}"); + user = await client.SignUpAsync(phone, hash, code, "First", "Last"); + } + Console.WriteLine($"Sign in {phone}"); + user = await client.MakeAuthAsync(phone, hash, code); + } + + var contacts = await client.GetContactsAsync(); + Console.WriteLine("Contacts:"); + foreach (var contact in contacts.Users.OfType()) + { + var contactUser = contact as TLUser; + Console.WriteLine($"\t{contact.Id} {contact.Phone} {contact.FirstName} {contact.LastName}"); + } -**Attach following information**: -* Full problem description and exception message -* Stack-trace -* Your code that runs in to this exception + var dialogs = (TLDialogs) await client.GetUserDialogsAsync(); + Console.WriteLine("Channels: "); + foreach (var channelObj in dialogs.Chats.OfType()) + { + var channel = channelObj as TLChannel; + Console.WriteLine($"\tChat: {channel.Title}"); + } -Without information listen above your issue will be closed. + Console.WriteLine("Groups:"); + TLChat chat = null; + foreach (var chatObj in dialogs.Chats.OfType()) + { + chat = chatObj as TLChat; + Console.WriteLine($"Chat name: {chat.Title}"); + var request = new TLRequestGetFullChat() { ChatId = chat.Id }; + var fullChat = await client.SendRequestAsync(request); + + var participants = (fullChat.FullChat as TeleSharp.TL.TLChatFull).Participants as TLChatParticipants; + foreach (var p in participants.Participants) + { + if (p is TLChatParticipant) + { + var participant = p as TLChatParticipant; + Console.WriteLine($"\t{participant.UserId}"); + } + else if (p is TLChatParticipantAdmin) + { + var participant = p as TLChatParticipantAdmin; + Console.WriteLine($"\t{participant.UserId}**"); + } + else if (p is TLChatParticipantCreator) + { + var participant = p as TLChatParticipantCreator; + Console.WriteLine($"\t{participant.UserId}**"); + } + } + + var peer = new TLInputPeerChat() { ChatId = chat.Id }; + var m = await client.GetHistoryAsync(peer, 0, 0, 0); + Console.WriteLine(m); + if (m is TLMessages) + { + var messages = m as TLMessages; + + + foreach (var message in messages.Messages) + { + if (message is TLMessage) + { + var m1 = message as TLMessage; + Console.WriteLine($"\t\t{m1.Id} {m1.Message}"); + } + else if (message is TLMessageService) + { + var m1 = message as TLMessageService; + Console.WriteLine($"\t\t{m1.Id} {m1.Action}"); + } + } + } + else if (m is TLMessagesSlice) + { + bool done = false; + int total = 0; + while (!done) + { + var messages = m as TLMessagesSlice; + + foreach (var m1 in messages.Messages) + { + if (m1 is TLMessage) + { + var message = m1 as TLMessage; + Console.WriteLine($"\t\t{message.Id} {message.Message}"); + ++total; + } + else if (m1 is TLMessageService) + { + var message = m1 as TLMessageService; + Console.WriteLine($"\t\t{message.Id} {message.Action}"); + ++total; + done = message.Action is TLMessageActionChatCreate; + } + } + m = await client.GetHistoryAsync(peer, total, 0, 0); + } + } + } + + // -- Wait in a loop to handle incoming updates. No need to poll. + for (;;) + { + await client.WaitEventAsync(); + } + } + catch (Exception e) + { + Console.WriteLine(e); + } + } + + private void Client_Updates(TelegramClient client, TLAbsUpdates updates) + { + Console.WriteLine($"Got update: {updates}"); + if (updates is TLUpdateShort) + { + var updateShort = updates as TLUpdateShort; + Console.WriteLine($"Short: {updateShort.Update}"); + if (updateShort.Update is TLUpdateUserStatus) + { + var status = updateShort.Update as TLUpdateUserStatus; + Console.WriteLine($"User {status.UserId} is {status.Status}"); + if (status.Status is TLUserStatusOnline) + { + try + { + var peer = new TLInputPeerUser() { UserId = status.UserId }; + client.SendMessageAsync(peer, "Você está online.").Wait(); + } catch {} + } + } + } + else if (updates is TLUpdateShortMessage) + { + var message = updates as TLUpdateShortMessage; + Console.WriteLine($"Message: {message.Message}"); + MarkMessageRead(client, new TLInputPeerUser() { UserId = message.UserId }, message.Id); + } + else if (updates is TLUpdateShortChatMessage) + { + var message = updates as TLUpdateShortChatMessage; + Console.WriteLine($"Chat Message: {message.Message}"); + MarkMessageRead(client, new TLInputPeerChat() { ChatId = message.ChatId }, message.Id); + } + else if (updates is TLUpdates) + { + var allUpdates = updates as TLUpdates; + foreach (var update in allUpdates.Updates) + { + Console.WriteLine($"\t{update}"); + if (update is TLUpdateNewChannelMessage) + { + var metaMessage = update as TLUpdateNewChannelMessage; + var message = metaMessage.Message as TLMessage; + Console.WriteLine($"Channel message: {message.Message}"); + var channel = allUpdates.Chats[0] as TLChannel; + MarkMessageRead(client, + new TLInputPeerChannel() { ChannelId = channel.Id, AccessHash = channel.AccessHash.Value }, + message.Id ); + } + } + + foreach(var user in allUpdates.Users) + { + Console.WriteLine($"{user}"); + } -# Donations -Thanks for donations! It's highly appreciated. - + foreach (var chat in allUpdates.Chats) + { + Console.WriteLine($"{chat}"); + } + } + } + + private void MarkMessageRead(TelegramClient client, TLAbsInputPeer peer, int id) + { + // An exception happens here but it's not fatal. + try + { + var request = new TLRequestReadHistory(); + request.MaxId = id; + request.Peer = peer; + client.SendRequestAsync(request).Wait(); + } + catch {} + + } + } +} -List of donators: -* [mtbitcoin](https://github.com/mtbitcoin) +``` -# Contributors -* [Afshin Arani](http://aarani.ir) - TLGenerator, and a lot of other usefull things -* [Knocte](https://github.com/knocte) # License From bf202981098a9b1aeac690cd64791fe101a9d8a9 Mon Sep 17 00:00:00 2001 From: ppanhoto78 Date: Thu, 4 Jan 2018 19:40:50 -0200 Subject: [PATCH 09/30] Update README.md --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 747ca4ce..21ab4440 100644 --- a/README.md +++ b/README.md @@ -31,8 +31,6 @@ namespace TLSharpPOC new MainClass().MainAsync(args).Wait(); } - private readonly Dictionary ContactList; - private async Task MainAsync(string[] args) { TelegramClient client = null; From 73022fc37c3a57a7ef4462707ca7e11b895d8577 Mon Sep 17 00:00:00 2001 From: ppanhoto78 Date: Thu, 4 Jan 2018 19:43:22 -0200 Subject: [PATCH 10/30] Update README.md --- README.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/README.md b/README.md index 21ab4440..45145c4f 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,6 @@ TLSharp ------------------------------- - -[![Join the chat at https://gitter.im/TLSharp/Lobby](https://badges.gitter.im/TLSharp/Lobby.svg)](https://gitter.im/TLSharp/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -[![Build status](https://ci.appveyor.com/api/projects/status/95rl618ch5c4h2fa?svg=true)](https://ci.appveyor.com/project/sochix/tlsharp) -[![NuGet version](https://badge.fury.io/nu/TLSharp.svg)](https://badge.fury.io/nu/TLSharp) - - _Unofficial_ Telegram (http://telegram.org) client library implemented in C#. Please refer to (https://github.com/sochix/TLSharp) for the original version and further documentation. # Sample code From 936a26c6bd4e270d4dda39e41b0c9747503bfae3 Mon Sep 17 00:00:00 2001 From: Paulo Rogerio Panhoto Date: Fri, 5 Jan 2018 11:12:41 -0200 Subject: [PATCH 11/30] * HandleUpdate fixed for the case where there are no subscribers. * main event loop added to TelegramClient as a single function call. --- TLSharp.Core/Network/MtProtoSender.cs | 1 + TLSharp.Core/TelegramClient.cs | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/TLSharp.Core/Network/MtProtoSender.cs b/TLSharp.Core/Network/MtProtoSender.cs index 37a57fd4..e81b5da5 100644 --- a/TLSharp.Core/Network/MtProtoSender.cs +++ b/TLSharp.Core/Network/MtProtoSender.cs @@ -330,6 +330,7 @@ private bool HandleRpcResult(ulong messageId, int sequence, BinaryReader message { // rpc_error int errorCode = messageReader.ReadInt32(); string errorMessage = Serializers.String.read(messageReader); + Console.Error.WriteLine($"ERROR: {errorMessage} - {errorCode}"); if (errorMessage.StartsWith("FLOOD_WAIT_")) { diff --git a/TLSharp.Core/TelegramClient.cs b/TLSharp.Core/TelegramClient.cs index fa0414b4..641f8d44 100644 --- a/TLSharp.Core/TelegramClient.cs +++ b/TLSharp.Core/TelegramClient.cs @@ -113,9 +113,17 @@ private async Task ReconnectToDcAsync(int dcId) } } + public async Task MainLoopAsync() + { + for (;;) + { + await WaitEventAsync(); + } + } + private void _sender_UpdatesEvent (TLAbsUpdates updates) { - Updates (this, updates); + Updates?.Invoke (this, updates); } private async Task RequestWithDcMigration(TLMethod request) From 9ad192c6d6ab7d1d8feb02b4209655faf26bff67 Mon Sep 17 00:00:00 2001 From: Paulo Rogerio Panhoto Date: Mon, 8 Jan 2018 16:51:33 -0200 Subject: [PATCH 12/30] * Adds a CancellationToken to the "event" API so that it can be interrupted. * There's also a new event that allows a client app to know whether it's safe to do requests without interfering with the event loop. --- TLSharp.Core/Network/MtProtoSender.cs | 4 +-- TLSharp.Core/Network/TcpTransport.cs | 51 +++++++++++++++++++++++++++ TLSharp.Core/TelegramClient.cs | 20 ++++++++--- 3 files changed, 69 insertions(+), 6 deletions(-) diff --git a/TLSharp.Core/Network/MtProtoSender.cs b/TLSharp.Core/Network/MtProtoSender.cs index e81b5da5..f7d9dc95 100644 --- a/TLSharp.Core/Network/MtProtoSender.cs +++ b/TLSharp.Core/Network/MtProtoSender.cs @@ -154,9 +154,9 @@ public async Task Receive (TeleSharp.TL.TLMethod request) return null; } - public async Task Receive() + public async Task Receive(CancellationToken token) { - var result = DecodeMessage ((await _transport.Receieve ()).Body); + var result = DecodeMessage ((await _transport.Receieve (token)).Body); using (var messageStream = new MemoryStream (result.Item1, false)) using (var messageReader = new BinaryReader (messageStream)) diff --git a/TLSharp.Core/Network/TcpTransport.cs b/TLSharp.Core/Network/TcpTransport.cs index 31bd6b4c..39ae672e 100644 --- a/TLSharp.Core/Network/TcpTransport.cs +++ b/TLSharp.Core/Network/TcpTransport.cs @@ -1,6 +1,7 @@ using System; using System.Net; using System.Net.Sockets; +using System.Threading; using System.Threading.Tasks; namespace TLSharp.Core.Network @@ -86,6 +87,56 @@ public async Task Receieve() return new TcpMessage(seq, body); } + public async Task Receieve(CancellationToken token) + { + var stream = _tcpClient.GetStream(); + + var packetLengthBytes = new byte[4]; + if (await stream.ReadAsync(packetLengthBytes, 0, 4, token) != 4) + throw new InvalidOperationException("Couldn't read the packet length"); + int packetLength = BitConverter.ToInt32(packetLengthBytes, 0); + + var seqBytes = new byte[4]; + if (await stream.ReadAsync(seqBytes, 0, 4) != 4) + throw new InvalidOperationException("Couldn't read the sequence"); + int seq = BitConverter.ToInt32(seqBytes, 0); + + int readBytes = 0; + var body = new byte[packetLength - 12]; + int neededToRead = packetLength - 12; + + do + { + var bodyByte = new byte[packetLength - 12]; + var availableBytes = await stream.ReadAsync(bodyByte, 0, neededToRead); + neededToRead -= availableBytes; + Buffer.BlockCopy(bodyByte, 0, body, readBytes, availableBytes); + readBytes += availableBytes; + } + while (readBytes != packetLength - 12); + + var crcBytes = new byte[4]; + if (await stream.ReadAsync(crcBytes, 0, 4) != 4) + throw new InvalidOperationException("Couldn't read the crc"); + int checksum = BitConverter.ToInt32(crcBytes, 0); + + byte[] rv = new byte[packetLengthBytes.Length + seqBytes.Length + body.Length]; + + Buffer.BlockCopy(packetLengthBytes, 0, rv, 0, packetLengthBytes.Length); + Buffer.BlockCopy(seqBytes, 0, rv, packetLengthBytes.Length, seqBytes.Length); + Buffer.BlockCopy(body, 0, rv, packetLengthBytes.Length + seqBytes.Length, body.Length); + var crc32 = new Ionic.Crc.CRC32(); + crc32.SlurpBlock(rv, 0, rv.Length); + var validChecksum = crc32.Crc32Result; + + if (checksum != validChecksum) + { + throw new InvalidOperationException("invalid checksum! skip"); + } + + return new TcpMessage(seq, body); + } + public bool IsConnected { get diff --git a/TLSharp.Core/TelegramClient.cs b/TLSharp.Core/TelegramClient.cs index 641f8d44..faeedd99 100644 --- a/TLSharp.Core/TelegramClient.cs +++ b/TLSharp.Core/TelegramClient.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Security.Cryptography; using System.Text; +using System.Threading; using System.Threading.Tasks; using TeleSharp.TL; using TeleSharp.TL.Account; @@ -31,8 +32,10 @@ public class TelegramClient : IDisposable private TcpClientConnectionHandler _handler; public delegate void UpdatesEvent (TelegramClient source, TLAbsUpdates updates); + public delegate void ClientEvent(TelegramClient source); public event UpdatesEvent Updates; + public event ClientEvent IdleLoop; public Session Session { get { return _session; } } @@ -113,11 +116,20 @@ private async Task ReconnectToDcAsync(int dcId) } } - public async Task MainLoopAsync() + public async Task MainLoopAsync(CancellationTokenSource source) { for (;;) { - await WaitEventAsync(); + try + { + await WaitEventAsync(source.Token); + } catch (OperationCanceledException) + { + } + finally + { + IdleLoop(this); + } } } @@ -146,9 +158,9 @@ private async Task RequestWithDcMigration(TLMethod request) } } - public async Task WaitEventAsync() + public async Task WaitEventAsync(CancellationToken token) { - await _sender.Receive (); + await _sender.Receive (token); } public bool IsUserAuthorized() From 15163c534f428a2f8e94a5e405b09df26d830e4c Mon Sep 17 00:00:00 2001 From: Paulo Rogerio Panhoto Date: Wed, 17 Jan 2018 15:41:53 -0200 Subject: [PATCH 13/30] Handles correctly the case of null IdleLoop handler. --- TLSharp.Core/TelegramClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TLSharp.Core/TelegramClient.cs b/TLSharp.Core/TelegramClient.cs index faeedd99..201c20ca 100644 --- a/TLSharp.Core/TelegramClient.cs +++ b/TLSharp.Core/TelegramClient.cs @@ -128,7 +128,7 @@ public async Task MainLoopAsync(CancellationTokenSource source) } finally { - IdleLoop(this); + IdleLoop?.Invoke(this); } } } From 3f5adeb3e95f51fec9b58e04a0f29cec14f8ee7b Mon Sep 17 00:00:00 2001 From: Paulo Rogerio Panhoto Date: Wed, 14 Feb 2018 17:04:01 -0200 Subject: [PATCH 14/30] Clears idle handlers after they've been processed. --- TLSharp.Core/TelegramClient.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/TLSharp.Core/TelegramClient.cs b/TLSharp.Core/TelegramClient.cs index 201c20ca..7747f1d6 100644 --- a/TLSharp.Core/TelegramClient.cs +++ b/TLSharp.Core/TelegramClient.cs @@ -129,6 +129,7 @@ public async Task MainLoopAsync(CancellationTokenSource source) finally { IdleLoop?.Invoke(this); + IdleLoop = null; } } } From ef1f96159263af036e0512f0195bd22fa0e8548b Mon Sep 17 00:00:00 2001 From: Paulo Rogerio Panhoto Date: Tue, 20 Feb 2018 15:25:20 -0300 Subject: [PATCH 15/30] Added debug logging to MtProtoSender, so that state machine can be "visible". --- TLSharp.Core/Network/MtProtoSender.cs | 7 ++++++- TLSharp.Core/Network/Sniffer.cs | 25 +++++++++++++++++++++++++ TLSharp.Core/TLSharp.Core.csproj | 4 ++++ TLSharp.Core/packages.config | 1 + 4 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 TLSharp.Core/Network/Sniffer.cs diff --git a/TLSharp.Core/Network/MtProtoSender.cs b/TLSharp.Core/Network/MtProtoSender.cs index f7d9dc95..98dd95c9 100644 --- a/TLSharp.Core/Network/MtProtoSender.cs +++ b/TLSharp.Core/Network/MtProtoSender.cs @@ -18,6 +18,8 @@ public class MtProtoSender { //private ulong sessionId = GenerateRandomUlong(); + private static NLog.Logger logger = NLog.LogManager.GetLogger("MTProto"); + private readonly uint UpdatesTooLongID = (uint) new TeleSharp.TL.TLUpdatesTooLong ().Constructor; private TcpTransport _transport; @@ -88,7 +90,9 @@ public async Task Send(byte[] packet, TeleSharp.TL.TLMethod request) plaintextWriter.Write(packet.Length); plaintextWriter.Write(packet); - msgKey = Helpers.CalcMsgKey(plaintextPacket.GetBuffer()); + var buffer = plaintextPacket.GetBuffer(); + logger.Debug(Sniffer.MessageOut(buffer)); + msgKey = Helpers.CalcMsgKey(buffer); ciphertext = AES.EncryptAES(Helpers.CalcKey(_session.AuthKey.Data, msgKey, true), plaintextPacket.GetBuffer()); } } @@ -123,6 +127,7 @@ private Tuple DecodeMessage(byte[] body) AESKeyData keyData = Helpers.CalcKey(_session.AuthKey.Data, msgKey, false); byte[] plaintext = AES.DecryptAES(keyData, inputReader.ReadBytes((int)(inputStream.Length - inputStream.Position))); + logger.Debug(Sniffer.MessageIn(plaintext)); using (MemoryStream plaintextStream = new MemoryStream(plaintext)) using (BinaryReader plaintextReader = new BinaryReader(plaintextStream)) diff --git a/TLSharp.Core/Network/Sniffer.cs b/TLSharp.Core/Network/Sniffer.cs new file mode 100644 index 00000000..e80a1053 --- /dev/null +++ b/TLSharp.Core/Network/Sniffer.cs @@ -0,0 +1,25 @@ +using System; +using System.Text; + +namespace TLSharp.Core.Network +{ + public static class Sniffer + { + public static string MessageOut(byte[] data) + { + return WriteMessage(new StringBuilder("[OUT]:"), data); + } + + public static string MessageIn(byte[] data) + { + return WriteMessage(new StringBuilder("[IN]:"), data); + } + + private static string WriteMessage(StringBuilder log, byte[] data) + { + foreach (var b in data) + log.AppendFormat(" {:x2}", b); + return log.ToString(); + } + } +} diff --git a/TLSharp.Core/TLSharp.Core.csproj b/TLSharp.Core/TLSharp.Core.csproj index fbef9425..7cca179c 100644 --- a/TLSharp.Core/TLSharp.Core.csproj +++ b/TLSharp.Core/TLSharp.Core.csproj @@ -42,6 +42,9 @@ + + ..\..\packages\NLog.4.4.12\lib\net45\NLog.dll + @@ -68,6 +71,7 @@ + diff --git a/TLSharp.Core/packages.config b/TLSharp.Core/packages.config index 204475cd..518c7dc2 100644 --- a/TLSharp.Core/packages.config +++ b/TLSharp.Core/packages.config @@ -1,4 +1,5 @@  + \ No newline at end of file From a425d142f93ada2c04d667233388f17c98a5f53a Mon Sep 17 00:00:00 2001 From: Paulo Rogerio Panhoto Date: Tue, 20 Feb 2018 18:43:36 -0300 Subject: [PATCH 16/30] Additional log messages. --- TLSharp.Core/Network/MtProtoSender.cs | 2 +- TLSharp.Core/TelegramClient.cs | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/TLSharp.Core/Network/MtProtoSender.cs b/TLSharp.Core/Network/MtProtoSender.cs index 98dd95c9..1884f47f 100644 --- a/TLSharp.Core/Network/MtProtoSender.cs +++ b/TLSharp.Core/Network/MtProtoSender.cs @@ -91,7 +91,7 @@ public async Task Send(byte[] packet, TeleSharp.TL.TLMethod request) plaintextWriter.Write(packet); var buffer = plaintextPacket.GetBuffer(); - logger.Debug(Sniffer.MessageOut(buffer)); + logger.Debug("Send {0} {1}", request, Sniffer.MessageOut(buffer)); msgKey = Helpers.CalcMsgKey(buffer); ciphertext = AES.EncryptAES(Helpers.CalcKey(_session.AuthKey.Data, msgKey, true), plaintextPacket.GetBuffer()); } diff --git a/TLSharp.Core/TelegramClient.cs b/TLSharp.Core/TelegramClient.cs index 7747f1d6..c898598f 100644 --- a/TLSharp.Core/TelegramClient.cs +++ b/TLSharp.Core/TelegramClient.cs @@ -22,6 +22,7 @@ namespace TLSharp.Core { public class TelegramClient : IDisposable { + private static NLog.Logger logger = NLog.LogManager.GetLogger("TelegramClient"); private MtProtoSender _sender; private AuthKey _key; private TcpTransport _transport; @@ -122,12 +123,14 @@ public async Task MainLoopAsync(CancellationTokenSource source) { try { + logger.Trace("Socket waiting"); await WaitEventAsync(source.Token); } catch (OperationCanceledException) { } finally { + logger.Trace("Running idle tasks"); IdleLoop?.Invoke(this); IdleLoop = null; } From 549b83157734a7c9619f20290c432b3cd20f49e9 Mon Sep 17 00:00:00 2001 From: Paulo Rogerio Panhoto Date: Thu, 22 Feb 2018 11:12:32 -0300 Subject: [PATCH 17/30] Instead of relying on a cancellation token, which caused some confusion on client implementation, Loop will run within constrained intervals which will be the longer waiting period for a scheduled action to run. --- TLSharp.Core/Network/MtProtoSender.cs | 4 ++-- TLSharp.Core/Network/TcpTransport.cs | 8 ++++++-- TLSharp.Core/TelegramClient.cs | 10 +++++----- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/TLSharp.Core/Network/MtProtoSender.cs b/TLSharp.Core/Network/MtProtoSender.cs index 1884f47f..54a96655 100644 --- a/TLSharp.Core/Network/MtProtoSender.cs +++ b/TLSharp.Core/Network/MtProtoSender.cs @@ -159,9 +159,9 @@ public async Task Receive (TeleSharp.TL.TLMethod request) return null; } - public async Task Receive(CancellationToken token) + public async Task Receive(int timeoutms) { - var result = DecodeMessage ((await _transport.Receieve (token)).Body); + var result = DecodeMessage ((await _transport.Receieve (timeoutms)).Body); using (var messageStream = new MemoryStream (result.Item1, false)) using (var messageReader = new BinaryReader (messageStream)) diff --git a/TLSharp.Core/Network/TcpTransport.cs b/TLSharp.Core/Network/TcpTransport.cs index 39ae672e..83d50383 100644 --- a/TLSharp.Core/Network/TcpTransport.cs +++ b/TLSharp.Core/Network/TcpTransport.cs @@ -87,12 +87,16 @@ public async Task Receieve() return new TcpMessage(seq, body); } - public async Task Receieve(CancellationToken token) + public async Task Receieve(int timeoutms) { var stream = _tcpClient.GetStream(); var packetLengthBytes = new byte[4]; - if (await stream.ReadAsync(packetLengthBytes, 0, 4, token) != 4) + var recvTask = stream.ReadAsync(packetLengthBytes, 0, 4); + var task = await Task.WhenAny(recvTask, Task.Delay(timeoutms)); + if (task != recvTask) + throw new TimeoutException(); + if (recvTask.Result != 4) throw new InvalidOperationException("Couldn't read the packet length"); int packetLength = BitConverter.ToInt32(packetLengthBytes, 0); diff --git a/TLSharp.Core/TelegramClient.cs b/TLSharp.Core/TelegramClient.cs index c898598f..b9aebb5d 100644 --- a/TLSharp.Core/TelegramClient.cs +++ b/TLSharp.Core/TelegramClient.cs @@ -117,15 +117,15 @@ private async Task ReconnectToDcAsync(int dcId) } } - public async Task MainLoopAsync(CancellationTokenSource source) + public async Task MainLoopAsync(int timeslicems) { for (;;) { try { logger.Trace("Socket waiting"); - await WaitEventAsync(source.Token); - } catch (OperationCanceledException) + await WaitEventAsync(timeslicems); + } catch (TimeoutException) { } finally @@ -162,9 +162,9 @@ private async Task RequestWithDcMigration(TLMethod request) } } - public async Task WaitEventAsync(CancellationToken token) + public async Task WaitEventAsync(int timeoutms) { - await _sender.Receive (token); + await _sender.Receive (timeoutms); } public bool IsUserAuthorized() From 083e45585d7f80f311f73ee1be00f53c29583182 Mon Sep 17 00:00:00 2001 From: Paulo Rogerio Panhoto Date: Thu, 22 Feb 2018 11:29:14 -0300 Subject: [PATCH 18/30] Fixed buffer "sniffer" --- TLSharp.Core/Network/Sniffer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TLSharp.Core/Network/Sniffer.cs b/TLSharp.Core/Network/Sniffer.cs index e80a1053..a1033bc2 100644 --- a/TLSharp.Core/Network/Sniffer.cs +++ b/TLSharp.Core/Network/Sniffer.cs @@ -18,7 +18,7 @@ public static string MessageIn(byte[] data) private static string WriteMessage(StringBuilder log, byte[] data) { foreach (var b in data) - log.AppendFormat(" {:x2}", b); + log.AppendFormat(" {0:x2}", b); return log.ToString(); } } From 2c8ea9c7ecb578357dd47b1fd4569128d8543c35 Mon Sep 17 00:00:00 2001 From: Paulo Rogerio Panhoto Date: Thu, 22 Feb 2018 16:09:11 -0300 Subject: [PATCH 19/30] Fixed event waiting with timeout. --- TLSharp.Core/Network/MtProtoSender.cs | 1290 +++++++++++++------------ TLSharp.Core/Network/TcpTransport.cs | 27 +- TLSharp.Core/TelegramClient.cs | 20 +- 3 files changed, 680 insertions(+), 657 deletions(-) diff --git a/TLSharp.Core/Network/MtProtoSender.cs b/TLSharp.Core/Network/MtProtoSender.cs index 54a96655..dba57604 100644 --- a/TLSharp.Core/Network/MtProtoSender.cs +++ b/TLSharp.Core/Network/MtProtoSender.cs @@ -1,644 +1,646 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Text.RegularExpressions; -using System.Threading; -using System.Threading.Tasks; -using Ionic.Zlib; -using TLSharp.Core.MTProto; -using TLSharp.Core.MTProto.Crypto; -using TLSharp.Core.Requests; -using TLSharp.Core.Utils; - -namespace TLSharp.Core.Network -{ - public class MtProtoSender - { - //private ulong sessionId = GenerateRandomUlong(); - - private static NLog.Logger logger = NLog.LogManager.GetLogger("MTProto"); - - private readonly uint UpdatesTooLongID = (uint) new TeleSharp.TL.TLUpdatesTooLong ().Constructor; - - private TcpTransport _transport; - private Session _session; - - public delegate void HandleUpdates (TeleSharp.TL.TLAbsUpdates updates); - - public event HandleUpdates UpdatesEvent; - - public List needConfirmation = new List(); - - public MtProtoSender(TcpTransport transport, Session session) - { - _transport = transport; - _session = session; - } - - public void ChangeTransport(TcpTransport transport) - { - _transport = transport; - } - - private int GenerateSequence(bool confirmed) - { - return confirmed ? _session.Sequence++ * 2 + 1 : _session.Sequence * 2; - } - - public async Task Send(TeleSharp.TL.TLMethod request) - { - // TODO: refactor - if (needConfirmation.Any()) - { - var ackRequest = new AckRequest(needConfirmation); - using (var memory = new MemoryStream()) - using (var writer = new BinaryWriter(memory)) - { - ackRequest.SerializeBody(writer); - await Send(memory.ToArray(), ackRequest); - needConfirmation.Clear(); - } - } - - - using (var memory = new MemoryStream()) - using (var writer = new BinaryWriter(memory)) - { - request.SerializeBody(writer); - await Send(memory.ToArray(), request); - } - - _session.Save(); - } - - public async Task Send(byte[] packet, TeleSharp.TL.TLMethod request) - { - request.MessageId = _session.GetNewMessageId(); - - byte[] msgKey; - byte[] ciphertext; - using (MemoryStream plaintextPacket = makeMemory(8 + 8 + 8 + 4 + 4 + packet.Length)) - { - using (BinaryWriter plaintextWriter = new BinaryWriter(plaintextPacket)) - { - plaintextWriter.Write(_session.Salt); - plaintextWriter.Write(_session.Id); - plaintextWriter.Write(request.MessageId); - plaintextWriter.Write(GenerateSequence(request.Confirmed)); - plaintextWriter.Write(packet.Length); - plaintextWriter.Write(packet); - - var buffer = plaintextPacket.GetBuffer(); - logger.Debug("Send {0} {1}", request, Sniffer.MessageOut(buffer)); - msgKey = Helpers.CalcMsgKey(buffer); - ciphertext = AES.EncryptAES(Helpers.CalcKey(_session.AuthKey.Data, msgKey, true), plaintextPacket.GetBuffer()); - } - } - - using (MemoryStream ciphertextPacket = makeMemory(8 + 16 + ciphertext.Length)) - { - using (BinaryWriter writer = new BinaryWriter(ciphertextPacket)) - { - writer.Write(_session.AuthKey.Id); - writer.Write(msgKey); - writer.Write(ciphertext); - - await _transport.Send(ciphertextPacket.GetBuffer()); - } - } - } - - private Tuple DecodeMessage(byte[] body) - { - byte[] message; - ulong remoteMessageId; - int remoteSequence; - - using (var inputStream = new MemoryStream(body)) - using (var inputReader = new BinaryReader(inputStream)) - { - if (inputReader.BaseStream.Length < 8) - throw new InvalidOperationException($"Can't decode packet"); - - ulong remoteAuthKeyId = inputReader.ReadUInt64(); // TODO: check auth key id - byte[] msgKey = inputReader.ReadBytes(16); // TODO: check msg_key correctness - AESKeyData keyData = Helpers.CalcKey(_session.AuthKey.Data, msgKey, false); - - byte[] plaintext = AES.DecryptAES(keyData, inputReader.ReadBytes((int)(inputStream.Length - inputStream.Position))); - logger.Debug(Sniffer.MessageIn(plaintext)); - - using (MemoryStream plaintextStream = new MemoryStream(plaintext)) - using (BinaryReader plaintextReader = new BinaryReader(plaintextStream)) - { - var remoteSalt = plaintextReader.ReadUInt64(); - var remoteSessionId = plaintextReader.ReadUInt64(); - remoteMessageId = plaintextReader.ReadUInt64(); - remoteSequence = plaintextReader.ReadInt32(); - int msgLen = plaintextReader.ReadInt32(); - message = plaintextReader.ReadBytes(msgLen); - } - } - return new Tuple(message, remoteMessageId, remoteSequence); - } - - public async Task Receive (TeleSharp.TL.TLMethod request) - { - while (!request.ConfirmReceived) - { - var result = DecodeMessage ((await _transport.Receieve ()).Body); - - using (var messageStream = new MemoryStream (result.Item1, false)) - using (var messageReader = new BinaryReader (messageStream)) - { - processMessage (result.Item2, result.Item3, messageReader, request); - } - } - - return null; - } - - public async Task Receive(int timeoutms) - { - var result = DecodeMessage ((await _transport.Receieve (timeoutms)).Body); - - using (var messageStream = new MemoryStream (result.Item1, false)) - using (var messageReader = new BinaryReader (messageStream)) - { - processMessage (result.Item2, result.Item3, messageReader, null); - } - - return null; - } - - public async Task SendPingAsync() - { - var pingRequest = new PingRequest(); - using (var memory = new MemoryStream()) - using (var writer = new BinaryWriter(memory)) - { - pingRequest.SerializeBody(writer); - await Send(memory.ToArray(), pingRequest); - } - - await Receive(pingRequest); - } - - private bool processMessage(ulong messageId, int sequence, BinaryReader messageReader, TeleSharp.TL.TLMethod request) - { - // TODO: check salt - // TODO: check sessionid - // TODO: check seqno - - - //logger.debug("processMessage: msg_id {0}, sequence {1}, data {2}", BitConverter.ToString(((MemoryStream)messageReader.BaseStream).GetBuffer(), (int) messageReader.BaseStream.Position, (int) (messageReader.BaseStream.Length - messageReader.BaseStream.Position)).Replace("-","").ToLower()); - needConfirmation.Add(messageId); - - uint code = messageReader.ReadUInt32(); - messageReader.BaseStream.Position -= 4; - switch (code) - { - case 0x73f1f8dc: // container - //logger.debug("MSG container"); - return HandleContainer(messageId, sequence, messageReader, request); - case 0x7abe77ec: // ping - //logger.debug("MSG ping"); - return HandlePing(messageId, sequence, messageReader); - case 0x347773c5: // pong - //logger.debug("MSG pong"); - return HandlePong(messageId, sequence, messageReader, request); - case 0xae500895: // future_salts - //logger.debug("MSG future_salts"); - return HandleFutureSalts(messageId, sequence, messageReader); - case 0x9ec20908: // new_session_created - //logger.debug("MSG new_session_created"); - return HandleNewSessionCreated(messageId, sequence, messageReader); - case 0x62d6b459: // msgs_ack - //logger.debug("MSG msds_ack"); - return HandleMsgsAck(messageId, sequence, messageReader); - case 0xedab447b: // bad_server_salt - //logger.debug("MSG bad_server_salt"); - return HandleBadServerSalt(messageId, sequence, messageReader, request); - case 0xa7eff811: // bad_msg_notification - //logger.debug("MSG bad_msg_notification"); - return HandleBadMsgNotification(messageId, sequence, messageReader); - case 0x276d3ec6: // msg_detailed_info - //logger.debug("MSG msg_detailed_info"); - return HandleMsgDetailedInfo(messageId, sequence, messageReader); - case 0xf35c6d01: // rpc_result - //logger.debug("MSG rpc_result"); - return HandleRpcResult(messageId, sequence, messageReader, request); - case 0x3072cfa1: // gzip_packed - //logger.debug("MSG gzip_packed"); - return HandleGzipPacked(messageId, sequence, messageReader, request); - case 0xe317af7e: - case 0x914fbf11: - case 0x16812688: - case 0x78d4dec1: - case 0x725b04c3: - case 0x74ae4240: - case 0x11f1331c: - return HandleUpdate(code, sequence, messageReader, request); - default: - Console.WriteLine ("Msg code: {0:x8}", code); - return false; - } - } - - private bool HandleUpdate(uint code, int sequence, BinaryReader messageReader, TeleSharp.TL.TLMethod request) - { - try - { - var update = ParseUpdate (code, messageReader); - if (update != null && UpdatesEvent != null) - { - UpdatesEvent (update); - } - } - catch (Exception ex) - { - Console.WriteLine (ex); - } - return false; - } - - private TeleSharp.TL.TLAbsUpdates ParseUpdate(uint code, BinaryReader messageReader) - { - switch (code) - { - case 0xe317af7e: - return DecodeUpdate(messageReader); - case 0x914fbf11: - return DecodeUpdate (messageReader); - case 0x16812688: - return DecodeUpdate (messageReader); - case 0x78d4dec1: - return DecodeUpdate (messageReader); - case 0x725b04c3: - return DecodeUpdate (messageReader); - case 0x74ae4240: - return DecodeUpdate (messageReader); - case 0x11f1331c: - return DecodeUpdate (messageReader); - default: - return null; - } - } - - private TeleSharp.TL.TLAbsUpdates DecodeUpdate(BinaryReader messageReader) where T: TeleSharp.TL.TLAbsUpdates - { - var ms = messageReader.BaseStream as MemoryStream; - var update = (T) TeleSharp.TL.ObjectUtils.DeserializeObject (messageReader); - return update; - } - - private bool HandleGzipPacked(ulong messageId, int sequence, BinaryReader messageReader, TeleSharp.TL.TLMethod request) - { - uint code = messageReader.ReadUInt32(); - byte[] packedData = GZipStream.UncompressBuffer(Serializers.Bytes.read(messageReader)); - using (MemoryStream packedStream = new MemoryStream(packedData, false)) - using (BinaryReader compressedReader = new BinaryReader(packedStream)) - { - processMessage(messageId, sequence, compressedReader, request); - } - - return true; - } - - private bool HandleRpcResult(ulong messageId, int sequence, BinaryReader messageReader, TeleSharp.TL.TLMethod request) - { - uint code = messageReader.ReadUInt32(); - ulong requestId = messageReader.ReadUInt64(); - - if (requestId == (ulong)request.MessageId) - request.ConfirmReceived = true; - - //throw new NotImplementedException(); - /* - lock (runningRequests) - { - if (!runningRequests.ContainsKey(requestId)) - { - logger.warning("rpc response on unknown request: {0}", requestId); - messageReader.BaseStream.Position -= 12; - return false; - } - - request = runningRequests[requestId]; - runningRequests.Remove(requestId); - } - */ - - uint innerCode = messageReader.ReadUInt32(); - if (innerCode == 0x2144ca19) - { // rpc_error - int errorCode = messageReader.ReadInt32(); - string errorMessage = Serializers.String.read(messageReader); - Console.Error.WriteLine($"ERROR: {errorMessage} - {errorCode}"); - - if (errorMessage.StartsWith("FLOOD_WAIT_")) - { - var resultString = Regex.Match(errorMessage, @"\d+").Value; - var seconds = int.Parse(resultString); - throw new FloodException(TimeSpan.FromSeconds(seconds)); - } - else if (errorMessage.StartsWith("PHONE_MIGRATE_")) - { - var resultString = Regex.Match(errorMessage, @"\d+").Value; - var dcIdx = int.Parse(resultString); - throw new PhoneMigrationException(dcIdx); - } - else if (errorMessage.StartsWith("FILE_MIGRATE_")) - { - var resultString = Regex.Match(errorMessage, @"\d+").Value; - var dcIdx = int.Parse(resultString); - throw new FileMigrationException(dcIdx); - } - else if (errorMessage.StartsWith("USER_MIGRATE_")) - { - var resultString = Regex.Match(errorMessage, @"\d+").Value; - var dcIdx = int.Parse(resultString); - throw new UserMigrationException(dcIdx); - } - else if (errorMessage.StartsWith("NETWORK_MIGRATE_")) - { - var resultString = Regex.Match(errorMessage, @"\d+").Value; - var dcIdx = int.Parse(resultString); - throw new NetworkMigrationException(dcIdx); - } - else if (errorMessage == "PHONE_CODE_INVALID") - { - throw new InvalidPhoneCodeException("The numeric code used to authenticate does not match the numeric code sent by SMS/Telegram"); - } - else if (errorMessage == "SESSION_PASSWORD_NEEDED") - { - throw new CloudPasswordNeededException("This Account has Cloud Password !"); - } - else - { - throw new InvalidOperationException(errorMessage); - } - - } - else if (innerCode == 0x3072cfa1) - { - try - { - // gzip_packed - byte[] packedData = Serializers.Bytes.read(messageReader); - using (var ms = new MemoryStream()) - { - using (var packedStream = new MemoryStream(packedData, false)) - using (var zipStream = new GZipStream(packedStream, CompressionMode.Decompress)) - { - zipStream.CopyTo(ms); - ms.Position = 0; - } - using (var compressedReader = new BinaryReader(ms)) - { - request.DeserializeResponse(compressedReader); - } - } - } - catch (ZlibException ex) - { - - } - } - else - { - messageReader.BaseStream.Position -= 4; - request.DeserializeResponse(messageReader); - } - - return false; - } - - private bool HandleMsgDetailedInfo(ulong messageId, int sequence, BinaryReader messageReader) - { - return false; - } - - private bool HandleBadMsgNotification(ulong messageId, int sequence, BinaryReader messageReader) - { - uint code = messageReader.ReadUInt32(); - ulong requestId = messageReader.ReadUInt64(); - int requestSequence = messageReader.ReadInt32(); - int errorCode = messageReader.ReadInt32(); - - switch (errorCode) - { - case 16: - throw new InvalidOperationException("msg_id too low (most likely, client time is wrong; it would be worthwhile to synchronize it using msg_id notifications and re-send the original message with the “correct” msg_id or wrap it in a container with a new msg_id if the original message had waited too long on the client to be transmitted)"); - case 17: - throw new InvalidOperationException("msg_id too high (similar to the previous case, the client time has to be synchronized, and the message re-sent with the correct msg_id)"); - case 18: - throw new InvalidOperationException("incorrect two lower order msg_id bits (the server expects client message msg_id to be divisible by 4)"); - case 19: - throw new InvalidOperationException("container msg_id is the same as msg_id of a previously received message (this must never happen)"); - case 20: - throw new InvalidOperationException("message too old, and it cannot be verified whether the server has received a message with this msg_id or not"); - case 32: - throw new InvalidOperationException("msg_seqno too low (the server has already received a message with a lower msg_id but with either a higher or an equal and odd seqno)"); - case 33: - throw new InvalidOperationException(" msg_seqno too high (similarly, there is a message with a higher msg_id but with either a lower or an equal and odd seqno)"); - case 34: - throw new InvalidOperationException("an even msg_seqno expected (irrelevant message), but odd received"); - case 35: - throw new InvalidOperationException("odd msg_seqno expected (relevant message), but even received"); - case 48: - throw new InvalidOperationException("incorrect server salt (in this case, the bad_server_salt response is received with the correct salt, and the message is to be re-sent with it)"); - case 64: - throw new InvalidOperationException("invalid container"); - - } - throw new NotImplementedException("This should never happens"); - /* - logger.debug("bad_msg_notification: msgid {0}, seq {1}, errorcode {2}", requestId, requestSequence, - errorCode); - */ - /* - if (!runningRequests.ContainsKey(requestId)) - { - logger.debug("bad msg notification on unknown request"); - return true; - } - */ - - //OnBrokenSessionEvent(); - //MTProtoRequest request = runningRequests[requestId]; - //request.OnException(new MTProtoBadMessageException(errorCode)); - - return true; - } - - private bool HandleBadServerSalt(ulong messageId, int sequence, BinaryReader messageReader, TeleSharp.TL.TLMethod request) - { - uint code = messageReader.ReadUInt32(); - ulong badMsgId = messageReader.ReadUInt64(); - int badMsgSeqNo = messageReader.ReadInt32(); - int errorCode = messageReader.ReadInt32(); - ulong newSalt = messageReader.ReadUInt64(); - - //logger.debug("bad_server_salt: msgid {0}, seq {1}, errorcode {2}, newsalt {3}", badMsgId, badMsgSeqNo, errorCode, newSalt); - - _session.Salt = newSalt; - - //resend - Send(request); - /* - if(!runningRequests.ContainsKey(badMsgId)) { - logger.debug("bad server salt on unknown message"); - return true; - } - */ - - - //MTProtoRequest request = runningRequests[badMsgId]; - //request.OnException(new MTProtoBadServerSaltException(salt)); - - return true; - } - - private bool HandleMsgsAck(ulong messageId, int sequence, BinaryReader messageReader) - { - return false; - } - - private bool HandleNewSessionCreated(ulong messageId, int sequence, BinaryReader messageReader) - { - return false; - } - - private bool HandleFutureSalts(ulong messageId, int sequence, BinaryReader messageReader) - { - uint code = messageReader.ReadUInt32(); - ulong requestId = messageReader.ReadUInt64(); - - messageReader.BaseStream.Position -= 12; - - throw new NotImplementedException("Handle future server salts function isn't implemented."); - /* - if (!runningRequests.ContainsKey(requestId)) - { - logger.info("future salts on unknown request"); - return false; - } - */ - - // MTProtoRequest request = runningRequests[requestId]; - // runningRequests.Remove(requestId); - // request.OnResponse(messageReader); - - return true; - } - - private bool HandlePong(ulong messageId, int sequence, BinaryReader messageReader, TeleSharp.TL.TLMethod request) - { - uint code = messageReader.ReadUInt32(); - ulong msgId = messageReader.ReadUInt64(); - - if (msgId == (ulong)request.MessageId) - { - request.ConfirmReceived = true; - } - - return false; - } - - private bool HandlePing(ulong messageId, int sequence, BinaryReader messageReader) - { - return false; - } - - private bool HandleContainer(ulong messageId, int sequence, BinaryReader messageReader, TeleSharp.TL.TLMethod request) - { - uint code = messageReader.ReadUInt32(); - int size = messageReader.ReadInt32(); - for (int i = 0; i < size; i++) - { - ulong innerMessageId = messageReader.ReadUInt64(); - int innerSequence = messageReader.ReadInt32(); - int innerLength = messageReader.ReadInt32(); - long beginPosition = messageReader.BaseStream.Position; - try - { - if (!processMessage(innerMessageId, sequence, messageReader, request)) - { - messageReader.BaseStream.Position = beginPosition + innerLength; - } - } - catch (Exception) - { - // logger.error("failed to process message in contailer: {0}", e); - messageReader.BaseStream.Position = beginPosition + innerLength; - } - } - - return false; - } - - private MemoryStream makeMemory(int len) - { - return new MemoryStream(new byte[len], 0, len, true, true); - } - } - - public class FloodException : Exception - { - public TimeSpan TimeToWait { get; private set; } - - internal FloodException(TimeSpan timeToWait) - : base($"Flood prevention. Telegram now requires your program to do requests again only after {timeToWait.TotalSeconds} seconds have passed ({nameof(TimeToWait)} property)." + - " If you think the culprit of this problem may lie in TLSharp's implementation, open a Github issue please.") - { - TimeToWait = timeToWait; - } - } - - internal abstract class DataCenterMigrationException : Exception - { - internal int DC { get; private set; } - - private const string REPORT_MESSAGE = - " See: https://github.com/sochix/TLSharp#i-get-a-xxxmigrationexception-or-a-migrate_x-error"; - - protected DataCenterMigrationException(string msg, int dc) : base (msg + REPORT_MESSAGE) - { - DC = dc; - } - } - - internal class PhoneMigrationException : DataCenterMigrationException - { - internal PhoneMigrationException(int dc) - : base ($"Phone number registered to a different DC: {dc}.", dc) - { - } - } - - internal class FileMigrationException : DataCenterMigrationException - { - internal FileMigrationException(int dc) - : base ($"File located on a different DC: {dc}.", dc) - { - } - } - - internal class UserMigrationException : DataCenterMigrationException - { - internal UserMigrationException(int dc) - : base($"User located on a different DC: {dc}.", dc) - { - } - } - - internal class NetworkMigrationException : DataCenterMigrationException - { - internal NetworkMigrationException(int dc) - : base($"Network located on a different DC: {dc}.", dc) - { - } - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text.RegularExpressions; +using System.Threading; +using System.Threading.Tasks; +using Ionic.Zlib; +using TLSharp.Core.MTProto; +using TLSharp.Core.MTProto.Crypto; +using TLSharp.Core.Requests; +using TLSharp.Core.Utils; + +namespace TLSharp.Core.Network +{ + public class MtProtoSender + { + //private ulong sessionId = GenerateRandomUlong(); + + private static NLog.Logger logger = NLog.LogManager.GetLogger("MTProto"); + + private readonly uint UpdatesTooLongID = (uint) new TeleSharp.TL.TLUpdatesTooLong ().Constructor; + + private TcpTransport _transport; + private Session _session; + + public delegate void HandleUpdates (TeleSharp.TL.TLAbsUpdates updates); + + public event HandleUpdates UpdatesEvent; + + public List needConfirmation = new List(); + + public MtProtoSender(TcpTransport transport, Session session) + { + _transport = transport; + _session = session; + } + + public void ChangeTransport(TcpTransport transport) + { + _transport = transport; + } + + private int GenerateSequence(bool confirmed) + { + return confirmed ? _session.Sequence++ * 2 + 1 : _session.Sequence * 2; + } + + private async Task Ack() + { + if (needConfirmation.Any()) + { + var ackRequest = new AckRequest(needConfirmation); + using (var memory = new MemoryStream()) + using (var writer = new BinaryWriter(memory)) + { + ackRequest.SerializeBody(writer); + await Send(memory.ToArray(), ackRequest); + needConfirmation.Clear(); + } + } + } + + public async Task Send(TeleSharp.TL.TLMethod request) + { + using (var memory = new MemoryStream()) + using (var writer = new BinaryWriter(memory)) + { + request.SerializeBody(writer); + await Send(memory.ToArray(), request); + } + + _session.Save(); + } + + public async Task Send(byte[] packet, TeleSharp.TL.TLMethod request) + { + request.MessageId = _session.GetNewMessageId(); + + byte[] msgKey; + byte[] ciphertext; + using (MemoryStream plaintextPacket = makeMemory(8 + 8 + 8 + 4 + 4 + packet.Length)) + { + using (BinaryWriter plaintextWriter = new BinaryWriter(plaintextPacket)) + { + plaintextWriter.Write(_session.Salt); + plaintextWriter.Write(_session.Id); + plaintextWriter.Write(request.MessageId); + plaintextWriter.Write(GenerateSequence(request.Confirmed)); + plaintextWriter.Write(packet.Length); + plaintextWriter.Write(packet); + + var buffer = plaintextPacket.GetBuffer(); + logger.Debug("Send {0} {1:x8} {2}", request, request.Constructor, Sniffer.MessageOut(buffer)); + msgKey = Helpers.CalcMsgKey(buffer); + ciphertext = AES.EncryptAES(Helpers.CalcKey(_session.AuthKey.Data, msgKey, true), plaintextPacket.GetBuffer()); + } + } + + using (MemoryStream ciphertextPacket = makeMemory(8 + 16 + ciphertext.Length)) + { + using (BinaryWriter writer = new BinaryWriter(ciphertextPacket)) + { + writer.Write(_session.AuthKey.Id); + writer.Write(msgKey); + writer.Write(ciphertext); + + await _transport.Send(ciphertextPacket.GetBuffer()); + } + } + } + + private Tuple DecodeMessage(byte[] body) + { + byte[] message; + ulong remoteMessageId; + int remoteSequence; + + using (var inputStream = new MemoryStream(body)) + using (var inputReader = new BinaryReader(inputStream)) + { + if (inputReader.BaseStream.Length < 8) + throw new InvalidOperationException($"Can't decode packet"); + + ulong remoteAuthKeyId = inputReader.ReadUInt64(); // TODO: check auth key id + byte[] msgKey = inputReader.ReadBytes(16); // TODO: check msg_key correctness + AESKeyData keyData = Helpers.CalcKey(_session.AuthKey.Data, msgKey, false); + + byte[] plaintext = AES.DecryptAES(keyData, inputReader.ReadBytes((int)(inputStream.Length - inputStream.Position))); + logger.Debug(Sniffer.MessageIn(plaintext)); + + using (MemoryStream plaintextStream = new MemoryStream(plaintext)) + using (BinaryReader plaintextReader = new BinaryReader(plaintextStream)) + { + var remoteSalt = plaintextReader.ReadUInt64(); + var remoteSessionId = plaintextReader.ReadUInt64(); + remoteMessageId = plaintextReader.ReadUInt64(); + remoteSequence = plaintextReader.ReadInt32(); + int msgLen = plaintextReader.ReadInt32(); + message = plaintextReader.ReadBytes(msgLen); + } + } + return new Tuple(message, remoteMessageId, remoteSequence); + } + + public async Task Receive (TeleSharp.TL.TLMethod request) + { + while (!request.ConfirmReceived) + { + var result = DecodeMessage ((await _transport.Receieve ()).Body); + + using (var messageStream = new MemoryStream (result.Item1, false)) + using (var messageReader = new BinaryReader (messageStream)) + { + processMessage (result.Item2, result.Item3, messageReader, request); + } + } + + return null; + } + + public async Task Receive(int timeoutms) + { + var result = DecodeMessage ((await _transport.Receieve (timeoutms)).Body); + + using (var messageStream = new MemoryStream (result.Item1, false)) + using (var messageReader = new BinaryReader (messageStream)) + { + processMessage (result.Item2, result.Item3, messageReader, null); + } + + return null; + } + + public async Task SendPingAsync() + { + var pingRequest = new PingRequest(); + using (var memory = new MemoryStream()) + using (var writer = new BinaryWriter(memory)) + { + pingRequest.SerializeBody(writer); + await Send(memory.ToArray(), pingRequest); + } + + await Receive(pingRequest); + } + + private bool processMessage(ulong messageId, int sequence, BinaryReader messageReader, TeleSharp.TL.TLMethod request) + { + // TODO: check salt + // TODO: check sessionid + // TODO: check seqno + + + //logger.debug("processMessage: msg_id {0}, sequence {1}, data {2}", BitConverter.ToString(((MemoryStream)messageReader.BaseStream).GetBuffer(), (int) messageReader.BaseStream.Position, (int) (messageReader.BaseStream.Length - messageReader.BaseStream.Position)).Replace("-","").ToLower()); + needConfirmation.Add(messageId); + Ack().Wait(); + + uint code = messageReader.ReadUInt32(); + messageReader.BaseStream.Position -= 4; + switch (code) + { + case 0x73f1f8dc: // container + //logger.debug("MSG container"); + return HandleContainer(messageId, sequence, messageReader, request); + case 0x7abe77ec: // ping + //logger.debug("MSG ping"); + return HandlePing(messageId, sequence, messageReader); + case 0x347773c5: // pong + //logger.debug("MSG pong"); + return HandlePong(messageId, sequence, messageReader, request); + case 0xae500895: // future_salts + //logger.debug("MSG future_salts"); + return HandleFutureSalts(messageId, sequence, messageReader); + case 0x9ec20908: // new_session_created + //logger.debug("MSG new_session_created"); + return HandleNewSessionCreated(messageId, sequence, messageReader); + case 0x62d6b459: // msgs_ack + //logger.debug("MSG msds_ack"); + return HandleMsgsAck(messageId, sequence, messageReader); + case 0xedab447b: // bad_server_salt + //logger.debug("MSG bad_server_salt"); + return HandleBadServerSalt(messageId, sequence, messageReader, request); + case 0xa7eff811: // bad_msg_notification + //logger.debug("MSG bad_msg_notification"); + return HandleBadMsgNotification(messageId, sequence, messageReader); + case 0x276d3ec6: // msg_detailed_info + //logger.debug("MSG msg_detailed_info"); + return HandleMsgDetailedInfo(messageId, sequence, messageReader); + case 0xf35c6d01: // rpc_result + //logger.debug("MSG rpc_result"); + return HandleRpcResult(messageId, sequence, messageReader, request); + case 0x3072cfa1: // gzip_packed + //logger.debug("MSG gzip_packed"); + return HandleGzipPacked(messageId, sequence, messageReader, request); + case 0xe317af7e: + case 0x914fbf11: + case 0x16812688: + case 0x78d4dec1: + case 0x725b04c3: + case 0x74ae4240: + case 0x11f1331c: + return HandleUpdate(code, sequence, messageReader, request); + default: + Console.WriteLine ("Msg code: {0:x8}", code); + return false; + } + } + + private bool HandleUpdate(uint code, int sequence, BinaryReader messageReader, TeleSharp.TL.TLMethod request) + { + try + { + var update = ParseUpdate (code, messageReader); + if (update != null && UpdatesEvent != null) + { + UpdatesEvent (update); + } + } + catch (Exception ex) + { + Console.WriteLine (ex); + } + return false; + } + + private TeleSharp.TL.TLAbsUpdates ParseUpdate(uint code, BinaryReader messageReader) + { + switch (code) + { + case 0xe317af7e: + return DecodeUpdate(messageReader); + case 0x914fbf11: + return DecodeUpdate (messageReader); + case 0x16812688: + return DecodeUpdate (messageReader); + case 0x78d4dec1: + return DecodeUpdate (messageReader); + case 0x725b04c3: + return DecodeUpdate (messageReader); + case 0x74ae4240: + return DecodeUpdate (messageReader); + case 0x11f1331c: + return DecodeUpdate (messageReader); + default: + return null; + } + } + + private TeleSharp.TL.TLAbsUpdates DecodeUpdate(BinaryReader messageReader) where T: TeleSharp.TL.TLAbsUpdates + { + var ms = messageReader.BaseStream as MemoryStream; + var update = (T) TeleSharp.TL.ObjectUtils.DeserializeObject (messageReader); + return update; + } + + private bool HandleGzipPacked(ulong messageId, int sequence, BinaryReader messageReader, TeleSharp.TL.TLMethod request) + { + uint code = messageReader.ReadUInt32(); + byte[] packedData = GZipStream.UncompressBuffer(Serializers.Bytes.read(messageReader)); + using (MemoryStream packedStream = new MemoryStream(packedData, false)) + using (BinaryReader compressedReader = new BinaryReader(packedStream)) + { + processMessage(messageId, sequence, compressedReader, request); + } + + return true; + } + + private bool HandleRpcResult(ulong messageId, int sequence, BinaryReader messageReader, TeleSharp.TL.TLMethod request) + { + uint code = messageReader.ReadUInt32(); + ulong requestId = messageReader.ReadUInt64(); + + if (requestId == (ulong)request.MessageId) + request.ConfirmReceived = true; + + //throw new NotImplementedException(); + /* + lock (runningRequests) + { + if (!runningRequests.ContainsKey(requestId)) + { + logger.warning("rpc response on unknown request: {0}", requestId); + messageReader.BaseStream.Position -= 12; + return false; + } + + request = runningRequests[requestId]; + runningRequests.Remove(requestId); + } + */ + + uint innerCode = messageReader.ReadUInt32(); + if (innerCode == 0x2144ca19) + { // rpc_error + int errorCode = messageReader.ReadInt32(); + string errorMessage = Serializers.String.read(messageReader); + Console.Error.WriteLine($"ERROR: {errorMessage} - {errorCode}"); + + if (errorMessage.StartsWith("FLOOD_WAIT_")) + { + var resultString = Regex.Match(errorMessage, @"\d+").Value; + var seconds = int.Parse(resultString); + throw new FloodException(TimeSpan.FromSeconds(seconds)); + } + else if (errorMessage.StartsWith("PHONE_MIGRATE_")) + { + var resultString = Regex.Match(errorMessage, @"\d+").Value; + var dcIdx = int.Parse(resultString); + throw new PhoneMigrationException(dcIdx); + } + else if (errorMessage.StartsWith("FILE_MIGRATE_")) + { + var resultString = Regex.Match(errorMessage, @"\d+").Value; + var dcIdx = int.Parse(resultString); + throw new FileMigrationException(dcIdx); + } + else if (errorMessage.StartsWith("USER_MIGRATE_")) + { + var resultString = Regex.Match(errorMessage, @"\d+").Value; + var dcIdx = int.Parse(resultString); + throw new UserMigrationException(dcIdx); + } + else if (errorMessage.StartsWith("NETWORK_MIGRATE_")) + { + var resultString = Regex.Match(errorMessage, @"\d+").Value; + var dcIdx = int.Parse(resultString); + throw new NetworkMigrationException(dcIdx); + } + else if (errorMessage == "PHONE_CODE_INVALID") + { + throw new InvalidPhoneCodeException("The numeric code used to authenticate does not match the numeric code sent by SMS/Telegram"); + } + else if (errorMessage == "SESSION_PASSWORD_NEEDED") + { + throw new CloudPasswordNeededException("This Account has Cloud Password !"); + } + else + { + throw new InvalidOperationException(errorMessage); + } + + } + else if (innerCode == 0x3072cfa1) + { + try + { + // gzip_packed + byte[] packedData = Serializers.Bytes.read(messageReader); + using (var ms = new MemoryStream()) + { + using (var packedStream = new MemoryStream(packedData, false)) + using (var zipStream = new GZipStream(packedStream, CompressionMode.Decompress)) + { + zipStream.CopyTo(ms); + ms.Position = 0; + } + using (var compressedReader = new BinaryReader(ms)) + { + request.DeserializeResponse(compressedReader); + } + } + } + catch (ZlibException ex) + { + + } + } + else + { + messageReader.BaseStream.Position -= 4; + request.DeserializeResponse(messageReader); + } + + return false; + } + + private bool HandleMsgDetailedInfo(ulong messageId, int sequence, BinaryReader messageReader) + { + return false; + } + + private bool HandleBadMsgNotification(ulong messageId, int sequence, BinaryReader messageReader) + { + uint code = messageReader.ReadUInt32(); + ulong requestId = messageReader.ReadUInt64(); + int requestSequence = messageReader.ReadInt32(); + int errorCode = messageReader.ReadInt32(); + + switch (errorCode) + { + case 16: + throw new InvalidOperationException("msg_id too low (most likely, client time is wrong; it would be worthwhile to synchronize it using msg_id notifications and re-send the original message with the “correct” msg_id or wrap it in a container with a new msg_id if the original message had waited too long on the client to be transmitted)"); + case 17: + throw new InvalidOperationException("msg_id too high (similar to the previous case, the client time has to be synchronized, and the message re-sent with the correct msg_id)"); + case 18: + throw new InvalidOperationException("incorrect two lower order msg_id bits (the server expects client message msg_id to be divisible by 4)"); + case 19: + throw new InvalidOperationException("container msg_id is the same as msg_id of a previously received message (this must never happen)"); + case 20: + throw new InvalidOperationException("message too old, and it cannot be verified whether the server has received a message with this msg_id or not"); + case 32: + throw new InvalidOperationException("msg_seqno too low (the server has already received a message with a lower msg_id but with either a higher or an equal and odd seqno)"); + case 33: + throw new InvalidOperationException(" msg_seqno too high (similarly, there is a message with a higher msg_id but with either a lower or an equal and odd seqno)"); + case 34: + throw new InvalidOperationException("an even msg_seqno expected (irrelevant message), but odd received"); + case 35: + throw new InvalidOperationException("odd msg_seqno expected (relevant message), but even received"); + case 48: + throw new InvalidOperationException("incorrect server salt (in this case, the bad_server_salt response is received with the correct salt, and the message is to be re-sent with it)"); + case 64: + throw new InvalidOperationException("invalid container"); + + } + throw new NotImplementedException("This should never happens"); + /* + logger.debug("bad_msg_notification: msgid {0}, seq {1}, errorcode {2}", requestId, requestSequence, + errorCode); + */ + /* + if (!runningRequests.ContainsKey(requestId)) + { + logger.debug("bad msg notification on unknown request"); + return true; + } + */ + + //OnBrokenSessionEvent(); + //MTProtoRequest request = runningRequests[requestId]; + //request.OnException(new MTProtoBadMessageException(errorCode)); + + return true; + } + + private bool HandleBadServerSalt(ulong messageId, int sequence, BinaryReader messageReader, TeleSharp.TL.TLMethod request) + { + uint code = messageReader.ReadUInt32(); + ulong badMsgId = messageReader.ReadUInt64(); + int badMsgSeqNo = messageReader.ReadInt32(); + int errorCode = messageReader.ReadInt32(); + ulong newSalt = messageReader.ReadUInt64(); + + //logger.debug("bad_server_salt: msgid {0}, seq {1}, errorcode {2}, newsalt {3}", badMsgId, badMsgSeqNo, errorCode, newSalt); + + _session.Salt = newSalt; + + //resend + Send(request); + /* + if(!runningRequests.ContainsKey(badMsgId)) { + logger.debug("bad server salt on unknown message"); + return true; + } + */ + + + //MTProtoRequest request = runningRequests[badMsgId]; + //request.OnException(new MTProtoBadServerSaltException(salt)); + + return true; + } + + private bool HandleMsgsAck(ulong messageId, int sequence, BinaryReader messageReader) + { + return false; + } + + private bool HandleNewSessionCreated(ulong messageId, int sequence, BinaryReader messageReader) + { + return false; + } + + private bool HandleFutureSalts(ulong messageId, int sequence, BinaryReader messageReader) + { + uint code = messageReader.ReadUInt32(); + ulong requestId = messageReader.ReadUInt64(); + + messageReader.BaseStream.Position -= 12; + + throw new NotImplementedException("Handle future server salts function isn't implemented."); + /* + if (!runningRequests.ContainsKey(requestId)) + { + logger.info("future salts on unknown request"); + return false; + } + */ + + // MTProtoRequest request = runningRequests[requestId]; + // runningRequests.Remove(requestId); + // request.OnResponse(messageReader); + + return true; + } + + private bool HandlePong(ulong messageId, int sequence, BinaryReader messageReader, TeleSharp.TL.TLMethod request) + { + uint code = messageReader.ReadUInt32(); + ulong msgId = messageReader.ReadUInt64(); + + if (msgId == (ulong)request.MessageId) + { + request.ConfirmReceived = true; + } + + return false; + } + + private bool HandlePing(ulong messageId, int sequence, BinaryReader messageReader) + { + return false; + } + + private bool HandleContainer(ulong messageId, int sequence, BinaryReader messageReader, TeleSharp.TL.TLMethod request) + { + uint code = messageReader.ReadUInt32(); + int size = messageReader.ReadInt32(); + for (int i = 0; i < size; i++) + { + ulong innerMessageId = messageReader.ReadUInt64(); + int innerSequence = messageReader.ReadInt32(); + int innerLength = messageReader.ReadInt32(); + long beginPosition = messageReader.BaseStream.Position; + try + { + if (!processMessage(innerMessageId, sequence, messageReader, request)) + { + messageReader.BaseStream.Position = beginPosition + innerLength; + } + } + catch (Exception) + { + // logger.error("failed to process message in contailer: {0}", e); + messageReader.BaseStream.Position = beginPosition + innerLength; + } + } + + return false; + } + + private MemoryStream makeMemory(int len) + { + return new MemoryStream(new byte[len], 0, len, true, true); + } + } + + public class FloodException : Exception + { + public TimeSpan TimeToWait { get; private set; } + + internal FloodException(TimeSpan timeToWait) + : base($"Flood prevention. Telegram now requires your program to do requests again only after {timeToWait.TotalSeconds} seconds have passed ({nameof(TimeToWait)} property)." + + " If you think the culprit of this problem may lie in TLSharp's implementation, open a Github issue please.") + { + TimeToWait = timeToWait; + } + } + + internal abstract class DataCenterMigrationException : Exception + { + internal int DC { get; private set; } + + private const string REPORT_MESSAGE = + " See: https://github.com/sochix/TLSharp#i-get-a-xxxmigrationexception-or-a-migrate_x-error"; + + protected DataCenterMigrationException(string msg, int dc) : base (msg + REPORT_MESSAGE) + { + DC = dc; + } + } + + internal class PhoneMigrationException : DataCenterMigrationException + { + internal PhoneMigrationException(int dc) + : base ($"Phone number registered to a different DC: {dc}.", dc) + { + } + } + + internal class FileMigrationException : DataCenterMigrationException + { + internal FileMigrationException(int dc) + : base ($"File located on a different DC: {dc}.", dc) + { + } + } + + internal class UserMigrationException : DataCenterMigrationException + { + internal UserMigrationException(int dc) + : base($"User located on a different DC: {dc}.", dc) + { + } + } + + internal class NetworkMigrationException : DataCenterMigrationException + { + internal NetworkMigrationException(int dc) + : base($"Network located on a different DC: {dc}.", dc) + { + } + } +} diff --git a/TLSharp.Core/Network/TcpTransport.cs b/TLSharp.Core/Network/TcpTransport.cs index 83d50383..d160cd3f 100644 --- a/TLSharp.Core/Network/TcpTransport.cs +++ b/TLSharp.Core/Network/TcpTransport.cs @@ -10,8 +10,10 @@ namespace TLSharp.Core.Network public class TcpTransport : IDisposable { + private static NLog.Logger logger = TelegramClient.logger; private readonly TcpClient _tcpClient; private int sendCounter = 0; + private CancellationTokenSource tokenSource = new CancellationTokenSource(); public TcpTransport(string address, int port, TcpClientConnectionHandler handler = null) { @@ -39,17 +41,20 @@ public async Task Send(byte[] packet) public async Task Receieve() { + logger.Trace($"Wait for answer {_tcpClient.Available} ..."); var stream = _tcpClient.GetStream(); var packetLengthBytes = new byte[4]; if (await stream.ReadAsync(packetLengthBytes, 0, 4) != 4) throw new InvalidOperationException("Couldn't read the packet length"); int packetLength = BitConverter.ToInt32(packetLengthBytes, 0); + logger.Debug("[IN] Packet length: {0}", packetLength); var seqBytes = new byte[4]; if (await stream.ReadAsync(seqBytes, 0, 4) != 4) throw new InvalidOperationException("Couldn't read the sequence"); int seq = BitConverter.ToInt32(seqBytes, 0); + logger.Debug("[IN] Sequence: {0}", seq); int readBytes = 0; var body = new byte[packetLength - 12]; @@ -89,21 +94,33 @@ public async Task Receieve() public async Task Receieve(int timeoutms) { + logger.Trace($"Wait for event {_tcpClient.Available} ..."); var stream = _tcpClient.GetStream(); var packetLengthBytes = new byte[4]; - var recvTask = stream.ReadAsync(packetLengthBytes, 0, 4); - var task = await Task.WhenAny(recvTask, Task.Delay(timeoutms)); - if (task != recvTask) - throw new TimeoutException(); - if (recvTask.Result != 4) + var token = tokenSource.Token; + stream.ReadTimeout = timeoutms; + int bytes = 0; + try + { + bytes = stream.Read(packetLengthBytes, 0, 4); + } catch (System.IO.IOException io) + { + var socketError = io.InnerException as SocketException; + if (socketError != null && socketError.SocketErrorCode == SocketError.TimedOut) + throw new OperationCanceledException(); + throw io; + } + if (bytes != 4) throw new InvalidOperationException("Couldn't read the packet length"); int packetLength = BitConverter.ToInt32(packetLengthBytes, 0); + logger.Debug("[IN]* Packet length: {0}", packetLength); var seqBytes = new byte[4]; if (await stream.ReadAsync(seqBytes, 0, 4) != 4) throw new InvalidOperationException("Couldn't read the sequence"); int seq = BitConverter.ToInt32(seqBytes, 0); + logger.Debug("[IN]* sequence: {0}", seq); int readBytes = 0; var body = new byte[packetLength - 12]; diff --git a/TLSharp.Core/TelegramClient.cs b/TLSharp.Core/TelegramClient.cs index b9aebb5d..8ec8ac43 100644 --- a/TLSharp.Core/TelegramClient.cs +++ b/TLSharp.Core/TelegramClient.cs @@ -22,7 +22,7 @@ namespace TLSharp.Core { public class TelegramClient : IDisposable { - private static NLog.Logger logger = NLog.LogManager.GetLogger("TelegramClient"); + internal static NLog.Logger logger = NLog.LogManager.GetLogger("TelegramClient"); private MtProtoSender _sender; private AuthKey _key; private TcpTransport _transport; @@ -118,21 +118,25 @@ private async Task ReconnectToDcAsync(int dcId) } public async Task MainLoopAsync(int timeslicems) - { + { + logger.Trace("Entered loop"); for (;;) { try - { - logger.Trace("Socket waiting"); + { await WaitEventAsync(timeslicems); - } catch (TimeoutException) + } catch (OperationCanceledException) { + logger.Trace("Timeout"); } finally { - logger.Trace("Running idle tasks"); - IdleLoop?.Invoke(this); - IdleLoop = null; + if (IdleLoop != null) + { + logger.Trace("Running idle tasks"); + IdleLoop.Invoke(this); + IdleLoop = null; + } } } } From b71a72343c83264ad309955fff0729bca18fdaf6 Mon Sep 17 00:00:00 2001 From: Paulo Rogerio Panhoto Date: Thu, 22 Feb 2018 18:14:07 -0300 Subject: [PATCH 20/30] * Added logging messages. * Implemented ping. --- TLSharp.Core/Network/MtProtoSender.cs | 3 ++- TLSharp.Core/TelegramClient.cs | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/TLSharp.Core/Network/MtProtoSender.cs b/TLSharp.Core/Network/MtProtoSender.cs index dba57604..387c57e9 100644 --- a/TLSharp.Core/Network/MtProtoSender.cs +++ b/TLSharp.Core/Network/MtProtoSender.cs @@ -199,6 +199,7 @@ private bool processMessage(ulong messageId, int sequence, BinaryReader messageR uint code = messageReader.ReadUInt32(); messageReader.BaseStream.Position -= 4; + logger.Info("Processing message {0:x8}", code); switch (code) { case 0x73f1f8dc: // container @@ -243,7 +244,7 @@ private bool processMessage(ulong messageId, int sequence, BinaryReader messageR case 0x11f1331c: return HandleUpdate(code, sequence, messageReader, request); default: - Console.WriteLine ("Msg code: {0:x8}", code); + logger.Info("unhandled message"); return false; } } diff --git a/TLSharp.Core/TelegramClient.cs b/TLSharp.Core/TelegramClient.cs index 8ec8ac43..630cc35a 100644 --- a/TLSharp.Core/TelegramClient.cs +++ b/TLSharp.Core/TelegramClient.cs @@ -120,6 +120,8 @@ private async Task ReconnectToDcAsync(int dcId) public async Task MainLoopAsync(int timeslicems) { logger.Trace("Entered loop"); + await SendPingAsync(); + var lastPing = DateTime.UtcNow; for (;;) { try @@ -131,6 +133,12 @@ public async Task MainLoopAsync(int timeslicems) } finally { + var now = DateTime.UtcNow; + if ((now - lastPing).TotalSeconds >= 30) + { + await SendPingAsync(); + lastPing = now; + } if (IdleLoop != null) { logger.Trace("Running idle tasks"); @@ -262,6 +270,7 @@ public async Task SignUpAsync(string phoneNumber, string phoneCodeHash, } public async Task SendRequestAsync(TLMethod methodToExecute) { + logger.Info("Sending Request: {0} {1:x8}", methodToExecute, methodToExecute.Constructor); await RequestWithDcMigration(methodToExecute); var result = methodToExecute.GetType().GetProperty("Response").GetValue(methodToExecute); From f30dc2da43028c148e50d1cadab9f49642969b66 Mon Sep 17 00:00:00 2001 From: Paulo Rogerio Panhoto Date: Thu, 22 Feb 2018 19:24:29 -0300 Subject: [PATCH 21/30] Disconsider ping delay for purpose of next ping message. --- TLSharp.Core/TelegramClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TLSharp.Core/TelegramClient.cs b/TLSharp.Core/TelegramClient.cs index 630cc35a..2f80552f 100644 --- a/TLSharp.Core/TelegramClient.cs +++ b/TLSharp.Core/TelegramClient.cs @@ -120,8 +120,8 @@ private async Task ReconnectToDcAsync(int dcId) public async Task MainLoopAsync(int timeslicems) { logger.Trace("Entered loop"); - await SendPingAsync(); var lastPing = DateTime.UtcNow; + await SendPingAsync(); for (;;) { try From 57b804e15a145b6495f07cf894c420a640ac89fd Mon Sep 17 00:00:00 2001 From: Paulo Rogerio Panhoto Date: Tue, 27 Feb 2018 16:42:10 -0300 Subject: [PATCH 22/30] Adds a function to allow the app to terminate a loop and close the client. --- TLSharp.Core/TelegramClient.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/TLSharp.Core/TelegramClient.cs b/TLSharp.Core/TelegramClient.cs index 2f80552f..b0d84afb 100644 --- a/TLSharp.Core/TelegramClient.cs +++ b/TLSharp.Core/TelegramClient.cs @@ -31,6 +31,7 @@ public class TelegramClient : IDisposable private Session _session; private List dcOptions; private TcpClientConnectionHandler _handler; + private bool _looping; public delegate void UpdatesEvent (TelegramClient source, TLAbsUpdates updates); public delegate void ClientEvent(TelegramClient source); @@ -117,12 +118,18 @@ private async Task ReconnectToDcAsync(int dcId) } } + public void Close() + { + _looping = false; + } + public async Task MainLoopAsync(int timeslicems) { logger.Trace("Entered loop"); var lastPing = DateTime.UtcNow; await SendPingAsync(); - for (;;) + _looping = true; + while (_looping) { try { @@ -415,7 +422,7 @@ public bool IsConnected return false; return _transport.IsConnected; } - } + } public void Dispose() { From aae366d33c0513b4e49e833f174c526f049d13aa Mon Sep 17 00:00:00 2001 From: Paulo Rogerio Panhoto Date: Tue, 27 Feb 2018 18:07:03 -0300 Subject: [PATCH 23/30] Captures all network exceptions in a new module. Adds a BadMessageException so that it can be better traced. --- TLSharp.Core/Network/Exceptions.cs | 69 +++++++++++++++++++++++ TLSharp.Core/Network/MtProtoSender.cs | 81 ++++----------------------- TLSharp.Core/TLSharp.Core.csproj | 1 + 3 files changed, 82 insertions(+), 69 deletions(-) create mode 100644 TLSharp.Core/Network/Exceptions.cs diff --git a/TLSharp.Core/Network/Exceptions.cs b/TLSharp.Core/Network/Exceptions.cs new file mode 100644 index 00000000..878e64e4 --- /dev/null +++ b/TLSharp.Core/Network/Exceptions.cs @@ -0,0 +1,69 @@ +using System; +namespace TLSharp.Core.Network +{ + public class FloodException : Exception + { + public TimeSpan TimeToWait { get; private set; } + + internal FloodException(TimeSpan timeToWait) + : base($"Flood prevention. Telegram now requires your program to do requests again only after {timeToWait.TotalSeconds} seconds have passed ({nameof(TimeToWait)} property)." + + " If you think the culprit of this problem may lie in TLSharp's implementation, open a Github issue please.") + { + TimeToWait = timeToWait; + } + } + + public class BadMessageException : Exception + { + internal BadMessageException(string description) : base(description) + { + } + } + + internal abstract class DataCenterMigrationException : Exception + { + internal int DC { get; private set; } + + private const string REPORT_MESSAGE = + " See: https://github.com/sochix/TLSharp#i-get-a-xxxmigrationexception-or-a-migrate_x-error"; + + protected DataCenterMigrationException(string msg, int dc) : base(msg + REPORT_MESSAGE) + { + DC = dc; + } + } + + internal class PhoneMigrationException : DataCenterMigrationException + { + internal PhoneMigrationException(int dc) + : base($"Phone number registered to a different DC: {dc}.", dc) + { + } + } + + internal class FileMigrationException : DataCenterMigrationException + { + internal FileMigrationException(int dc) + : base($"File located on a different DC: {dc}.", dc) + { + } + } + + internal class UserMigrationException : DataCenterMigrationException + { + internal UserMigrationException(int dc) + : base($"User located on a different DC: {dc}.", dc) + { + } + } + + internal class NetworkMigrationException : DataCenterMigrationException + { + internal NetworkMigrationException(int dc) + : base($"Network located on a different DC: {dc}.", dc) + { + } + } + + +} diff --git a/TLSharp.Core/Network/MtProtoSender.cs b/TLSharp.Core/Network/MtProtoSender.cs index 387c57e9..cfa93e3b 100644 --- a/TLSharp.Core/Network/MtProtoSender.cs +++ b/TLSharp.Core/Network/MtProtoSender.cs @@ -433,30 +433,30 @@ private bool HandleBadMsgNotification(ulong messageId, int sequence, BinaryReade switch (errorCode) { case 16: - throw new InvalidOperationException("msg_id too low (most likely, client time is wrong; it would be worthwhile to synchronize it using msg_id notifications and re-send the original message with the “correct” msg_id or wrap it in a container with a new msg_id if the original message had waited too long on the client to be transmitted)"); + throw new BadMessageException("msg_id too low (most likely, client time is wrong; it would be worthwhile to synchronize it using msg_id notifications and re-send the original message with the “correct” msg_id or wrap it in a container with a new msg_id if the original message had waited too long on the client to be transmitted)"); case 17: - throw new InvalidOperationException("msg_id too high (similar to the previous case, the client time has to be synchronized, and the message re-sent with the correct msg_id)"); + throw new BadMessageException("msg_id too high (similar to the previous case, the client time has to be synchronized, and the message re-sent with the correct msg_id)"); case 18: - throw new InvalidOperationException("incorrect two lower order msg_id bits (the server expects client message msg_id to be divisible by 4)"); + throw new BadMessageException("incorrect two lower order msg_id bits (the server expects client message msg_id to be divisible by 4)"); case 19: - throw new InvalidOperationException("container msg_id is the same as msg_id of a previously received message (this must never happen)"); + throw new BadMessageException("container msg_id is the same as msg_id of a previously received message (this must never happen)"); case 20: - throw new InvalidOperationException("message too old, and it cannot be verified whether the server has received a message with this msg_id or not"); + throw new BadMessageException("message too old, and it cannot be verified whether the server has received a message with this msg_id or not"); case 32: - throw new InvalidOperationException("msg_seqno too low (the server has already received a message with a lower msg_id but with either a higher or an equal and odd seqno)"); + throw new BadMessageException("msg_seqno too low (the server has already received a message with a lower msg_id but with either a higher or an equal and odd seqno)"); case 33: - throw new InvalidOperationException(" msg_seqno too high (similarly, there is a message with a higher msg_id but with either a lower or an equal and odd seqno)"); + throw new BadMessageException(" msg_seqno too high (similarly, there is a message with a higher msg_id but with either a lower or an equal and odd seqno)"); case 34: - throw new InvalidOperationException("an even msg_seqno expected (irrelevant message), but odd received"); + throw new BadMessageException("an even msg_seqno expected (irrelevant message), but odd received"); case 35: - throw new InvalidOperationException("odd msg_seqno expected (relevant message), but even received"); + throw new BadMessageException("odd msg_seqno expected (relevant message), but even received"); case 48: - throw new InvalidOperationException("incorrect server salt (in this case, the bad_server_salt response is received with the correct salt, and the message is to be re-sent with it)"); + throw new BadMessageException("incorrect server salt (in this case, the bad_server_salt response is received with the correct salt, and the message is to be re-sent with it)"); case 64: - throw new InvalidOperationException("invalid container"); + throw new BadMessageException("invalid container"); } - throw new NotImplementedException("This should never happens"); + throw new NotImplementedException("This should never happen!"); /* logger.debug("bad_msg_notification: msgid {0}, seq {1}, errorcode {2}", requestId, requestSequence, errorCode); @@ -587,61 +587,4 @@ private MemoryStream makeMemory(int len) return new MemoryStream(new byte[len], 0, len, true, true); } } - - public class FloodException : Exception - { - public TimeSpan TimeToWait { get; private set; } - - internal FloodException(TimeSpan timeToWait) - : base($"Flood prevention. Telegram now requires your program to do requests again only after {timeToWait.TotalSeconds} seconds have passed ({nameof(TimeToWait)} property)." + - " If you think the culprit of this problem may lie in TLSharp's implementation, open a Github issue please.") - { - TimeToWait = timeToWait; - } - } - - internal abstract class DataCenterMigrationException : Exception - { - internal int DC { get; private set; } - - private const string REPORT_MESSAGE = - " See: https://github.com/sochix/TLSharp#i-get-a-xxxmigrationexception-or-a-migrate_x-error"; - - protected DataCenterMigrationException(string msg, int dc) : base (msg + REPORT_MESSAGE) - { - DC = dc; - } - } - - internal class PhoneMigrationException : DataCenterMigrationException - { - internal PhoneMigrationException(int dc) - : base ($"Phone number registered to a different DC: {dc}.", dc) - { - } - } - - internal class FileMigrationException : DataCenterMigrationException - { - internal FileMigrationException(int dc) - : base ($"File located on a different DC: {dc}.", dc) - { - } - } - - internal class UserMigrationException : DataCenterMigrationException - { - internal UserMigrationException(int dc) - : base($"User located on a different DC: {dc}.", dc) - { - } - } - - internal class NetworkMigrationException : DataCenterMigrationException - { - internal NetworkMigrationException(int dc) - : base($"Network located on a different DC: {dc}.", dc) - { - } - } } diff --git a/TLSharp.Core/TLSharp.Core.csproj b/TLSharp.Core/TLSharp.Core.csproj index 7cca179c..144f695c 100644 --- a/TLSharp.Core/TLSharp.Core.csproj +++ b/TLSharp.Core/TLSharp.Core.csproj @@ -72,6 +72,7 @@ + From b98914ed55f4466d57f3cc034595d83f0ea0577b Mon Sep 17 00:00:00 2001 From: Paulo Rogerio Panhoto Date: Thu, 1 Mar 2018 12:02:22 -0300 Subject: [PATCH 24/30] Reports exception to logger where it used to go to console only. --- TLSharp.Core/Network/MtProtoSender.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/TLSharp.Core/Network/MtProtoSender.cs b/TLSharp.Core/Network/MtProtoSender.cs index cfa93e3b..fffce0d5 100644 --- a/TLSharp.Core/Network/MtProtoSender.cs +++ b/TLSharp.Core/Network/MtProtoSender.cs @@ -258,10 +258,11 @@ private bool HandleUpdate(uint code, int sequence, BinaryReader messageReader, T { UpdatesEvent (update); } + return true; } catch (Exception ex) { - Console.WriteLine (ex); + logger.Error($"HandleUpdate failed: {ex}"); } return false; } From 01e61f3ea401a497d75e9c4b2f8918e2419d867b Mon Sep 17 00:00:00 2001 From: Paulo Rogerio Panhoto Date: Thu, 1 Mar 2018 14:10:03 -0300 Subject: [PATCH 25/30] New flag to mask event reporting. This is necessary so that Initialisation doesn't get interrupted by any event. --- TLSharp.Core/Network/MtProtoSender.cs | 2 +- TLSharp.Core/TelegramClient.cs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/TLSharp.Core/Network/MtProtoSender.cs b/TLSharp.Core/Network/MtProtoSender.cs index fffce0d5..cb00efa4 100644 --- a/TLSharp.Core/Network/MtProtoSender.cs +++ b/TLSharp.Core/Network/MtProtoSender.cs @@ -262,7 +262,7 @@ private bool HandleUpdate(uint code, int sequence, BinaryReader messageReader, T } catch (Exception ex) { - logger.Error($"HandleUpdate failed: {ex}"); + logger.Debug($"HandleUpdate failed: {ex}"); } return false; } diff --git a/TLSharp.Core/TelegramClient.cs b/TLSharp.Core/TelegramClient.cs index b0d84afb..e3f44920 100644 --- a/TLSharp.Core/TelegramClient.cs +++ b/TLSharp.Core/TelegramClient.cs @@ -41,6 +41,8 @@ public class TelegramClient : IDisposable public Session Session { get { return _session; } } + public volatile bool AllowEvents = false; + public TelegramClient(int apiId, string apiHash, Session session = null, string sessionUserId = "session", TcpClientConnectionHandler handler = null) { @@ -158,7 +160,8 @@ public async Task MainLoopAsync(int timeslicems) private void _sender_UpdatesEvent (TLAbsUpdates updates) { - Updates?.Invoke (this, updates); + if (AllowEvents && Updates != null) + Updates(this, updates); } private async Task RequestWithDcMigration(TLMethod request) From 9f25a7615ec712f9c23ccbf9fd05b0949e9c08f2 Mon Sep 17 00:00:00 2001 From: Paulo Rogerio Panhoto Date: Thu, 1 Mar 2018 14:45:25 -0300 Subject: [PATCH 26/30] logs exception caught when handling a container message. --- TLSharp.Core/Network/MtProtoSender.cs | 4 +- TeleSharp.Generator/Result.cs | 0 TeleSharp.Generator/schema.json | 14451 ++++++++++++++++++++++++ 3 files changed, 14453 insertions(+), 2 deletions(-) create mode 100644 TeleSharp.Generator/Result.cs create mode 100644 TeleSharp.Generator/schema.json diff --git a/TLSharp.Core/Network/MtProtoSender.cs b/TLSharp.Core/Network/MtProtoSender.cs index cb00efa4..0b749438 100644 --- a/TLSharp.Core/Network/MtProtoSender.cs +++ b/TLSharp.Core/Network/MtProtoSender.cs @@ -573,9 +573,9 @@ private bool HandleContainer(ulong messageId, int sequence, BinaryReader message messageReader.BaseStream.Position = beginPosition + innerLength; } } - catch (Exception) + catch (Exception e) { - // logger.error("failed to process message in contailer: {0}", e); + logger.Debug($"failed to process message in contailer: {e}"); messageReader.BaseStream.Position = beginPosition + innerLength; } } diff --git a/TeleSharp.Generator/Result.cs b/TeleSharp.Generator/Result.cs new file mode 100644 index 00000000..e69de29b diff --git a/TeleSharp.Generator/schema.json b/TeleSharp.Generator/schema.json new file mode 100644 index 00000000..9ed6a48b --- /dev/null +++ b/TeleSharp.Generator/schema.json @@ -0,0 +1,14451 @@ +{ + "constructors": [ + { + "id": "-1132882121", + "predicate": "boolFalse", + "params": [], + "type": "Bool" + }, + { + "id": "-1720552011", + "predicate": "boolTrue", + "params": [], + "type": "Bool" + }, + { + "id": "-994444869", + "predicate": "error", + "params": [ + { + "name": "code", + "type": "int" + }, + { + "name": "text", + "type": "string" + } + ], + "type": "Error" + }, + { + "id": "1450380236", + "predicate": "null", + "params": [], + "type": "Null" + }, + { + "id": "2134579434", + "predicate": "inputPeerEmpty", + "params": [], + "type": "InputPeer" + }, + { + "id": "2107670217", + "predicate": "inputPeerSelf", + "params": [], + "type": "InputPeer" + }, + { + "id": "396093539", + "predicate": "inputPeerChat", + "params": [ + { + "name": "chat_id", + "type": "int" + } + ], + "type": "InputPeer" + }, + { + "id": "-1182234929", + "predicate": "inputUserEmpty", + "params": [], + "type": "InputUser" + }, + { + "id": "-138301121", + "predicate": "inputUserSelf", + "params": [], + "type": "InputUser" + }, + { + "id": "-208488460", + "predicate": "inputPhoneContact", + "params": [ + { + "name": "client_id", + "type": "long" + }, + { + "name": "phone", + "type": "string" + }, + { + "name": "first_name", + "type": "string" + }, + { + "name": "last_name", + "type": "string" + } + ], + "type": "InputContact" + }, + { + "id": "-181407105", + "predicate": "inputFile", + "params": [ + { + "name": "id", + "type": "long" + }, + { + "name": "parts", + "type": "int" + }, + { + "name": "name", + "type": "string" + }, + { + "name": "md5_checksum", + "type": "string" + } + ], + "type": "InputFile" + }, + { + "id": "-1771768449", + "predicate": "inputMediaEmpty", + "params": [], + "type": "InputMedia" + }, + { + "id": "792191537", + "predicate": "inputMediaUploadedPhoto", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "file", + "type": "InputFile" + }, + { + "name": "caption", + "type": "string" + }, + { + "name": "stickers", + "type": "flags.0?Vector" + }, + { + "name": "ttl_seconds", + "type": "flags.1?int" + } + ], + "type": "InputMedia" + }, + { + "id": "-2114308294", + "predicate": "inputMediaPhoto", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "id", + "type": "InputPhoto" + }, + { + "name": "caption", + "type": "string" + }, + { + "name": "ttl_seconds", + "type": "flags.0?int" + } + ], + "type": "InputMedia" + }, + { + "id": "-104578748", + "predicate": "inputMediaGeoPoint", + "params": [ + { + "name": "geo_point", + "type": "InputGeoPoint" + } + ], + "type": "InputMedia" + }, + { + "id": "-1494984313", + "predicate": "inputMediaContact", + "params": [ + { + "name": "phone_number", + "type": "string" + }, + { + "name": "first_name", + "type": "string" + }, + { + "name": "last_name", + "type": "string" + } + ], + "type": "InputMedia" + }, + { + "id": "480546647", + "predicate": "inputChatPhotoEmpty", + "params": [], + "type": "InputChatPhoto" + }, + { + "id": "-1837345356", + "predicate": "inputChatUploadedPhoto", + "params": [ + { + "name": "file", + "type": "InputFile" + } + ], + "type": "InputChatPhoto" + }, + { + "id": "-1991004873", + "predicate": "inputChatPhoto", + "params": [ + { + "name": "id", + "type": "InputPhoto" + } + ], + "type": "InputChatPhoto" + }, + { + "id": "-457104426", + "predicate": "inputGeoPointEmpty", + "params": [], + "type": "InputGeoPoint" + }, + { + "id": "-206066487", + "predicate": "inputGeoPoint", + "params": [ + { + "name": "lat", + "type": "double" + }, + { + "name": "long", + "type": "double" + } + ], + "type": "InputGeoPoint" + }, + { + "id": "483901197", + "predicate": "inputPhotoEmpty", + "params": [], + "type": "InputPhoto" + }, + { + "id": "-74070332", + "predicate": "inputPhoto", + "params": [ + { + "name": "id", + "type": "long" + }, + { + "name": "access_hash", + "type": "long" + } + ], + "type": "InputPhoto" + }, + { + "id": "342061462", + "predicate": "inputFileLocation", + "params": [ + { + "name": "volume_id", + "type": "long" + }, + { + "name": "local_id", + "type": "int" + }, + { + "name": "secret", + "type": "long" + } + ], + "type": "InputFileLocation" + }, + { + "id": "1996904104", + "predicate": "inputAppEvent", + "params": [ + { + "name": "time", + "type": "double" + }, + { + "name": "type", + "type": "string" + }, + { + "name": "peer", + "type": "long" + }, + { + "name": "data", + "type": "string" + } + ], + "type": "InputAppEvent" + }, + { + "id": "-1649296275", + "predicate": "peerUser", + "params": [ + { + "name": "user_id", + "type": "int" + } + ], + "type": "Peer" + }, + { + "id": "-1160714821", + "predicate": "peerChat", + "params": [ + { + "name": "chat_id", + "type": "int" + } + ], + "type": "Peer" + }, + { + "id": "-1432995067", + "predicate": "storage.fileUnknown", + "params": [], + "type": "storage.FileType" + }, + { + "id": "8322574", + "predicate": "storage.fileJpeg", + "params": [], + "type": "storage.FileType" + }, + { + "id": "-891180321", + "predicate": "storage.fileGif", + "params": [], + "type": "storage.FileType" + }, + { + "id": "172975040", + "predicate": "storage.filePng", + "params": [], + "type": "storage.FileType" + }, + { + "id": "1384777335", + "predicate": "storage.fileMp3", + "params": [], + "type": "storage.FileType" + }, + { + "id": "1258941372", + "predicate": "storage.fileMov", + "params": [], + "type": "storage.FileType" + }, + { + "id": "1086091090", + "predicate": "storage.filePartial", + "params": [], + "type": "storage.FileType" + }, + { + "id": "-1278304028", + "predicate": "storage.fileMp4", + "params": [], + "type": "storage.FileType" + }, + { + "id": "276907596", + "predicate": "storage.fileWebp", + "params": [], + "type": "storage.FileType" + }, + { + "id": "2086234950", + "predicate": "fileLocationUnavailable", + "params": [ + { + "name": "volume_id", + "type": "long" + }, + { + "name": "local_id", + "type": "int" + }, + { + "name": "secret", + "type": "long" + } + ], + "type": "FileLocation" + }, + { + "id": "1406570614", + "predicate": "fileLocation", + "params": [ + { + "name": "dc_id", + "type": "int" + }, + { + "name": "volume_id", + "type": "long" + }, + { + "name": "local_id", + "type": "int" + }, + { + "name": "secret", + "type": "long" + } + ], + "type": "FileLocation" + }, + { + "id": "537022650", + "predicate": "userEmpty", + "params": [ + { + "name": "id", + "type": "int" + } + ], + "type": "User" + }, + { + "id": "1326562017", + "predicate": "userProfilePhotoEmpty", + "params": [], + "type": "UserProfilePhoto" + }, + { + "id": "-715532088", + "predicate": "userProfilePhoto", + "params": [ + { + "name": "photo_id", + "type": "long" + }, + { + "name": "photo_small", + "type": "FileLocation" + }, + { + "name": "photo_big", + "type": "FileLocation" + } + ], + "type": "UserProfilePhoto" + }, + { + "id": "164646985", + "predicate": "userStatusEmpty", + "params": [], + "type": "UserStatus" + }, + { + "id": "-306628279", + "predicate": "userStatusOnline", + "params": [ + { + "name": "expires", + "type": "int" + } + ], + "type": "UserStatus" + }, + { + "id": "9203775", + "predicate": "userStatusOffline", + "params": [ + { + "name": "was_online", + "type": "int" + } + ], + "type": "UserStatus" + }, + { + "id": "-1683826688", + "predicate": "chatEmpty", + "params": [ + { + "name": "id", + "type": "int" + } + ], + "type": "Chat" + }, + { + "id": "-652419756", + "predicate": "chat", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "creator", + "type": "flags.0?true" + }, + { + "name": "kicked", + "type": "flags.1?true" + }, + { + "name": "left", + "type": "flags.2?true" + }, + { + "name": "admins_enabled", + "type": "flags.3?true" + }, + { + "name": "admin", + "type": "flags.4?true" + }, + { + "name": "deactivated", + "type": "flags.5?true" + }, + { + "name": "id", + "type": "int" + }, + { + "name": "title", + "type": "string" + }, + { + "name": "photo", + "type": "ChatPhoto" + }, + { + "name": "participants_count", + "type": "int" + }, + { + "name": "date", + "type": "int" + }, + { + "name": "version", + "type": "int" + }, + { + "name": "migrated_to", + "type": "flags.6?InputChannel" + } + ], + "type": "Chat" + }, + { + "id": "120753115", + "predicate": "chatForbidden", + "params": [ + { + "name": "id", + "type": "int" + }, + { + "name": "title", + "type": "string" + } + ], + "type": "Chat" + }, + { + "id": "771925524", + "predicate": "chatFull", + "params": [ + { + "name": "id", + "type": "int" + }, + { + "name": "participants", + "type": "ChatParticipants" + }, + { + "name": "chat_photo", + "type": "Photo" + }, + { + "name": "notify_settings", + "type": "PeerNotifySettings" + }, + { + "name": "exported_invite", + "type": "ExportedChatInvite" + }, + { + "name": "bot_info", + "type": "Vector" + } + ], + "type": "ChatFull" + }, + { + "id": "-925415106", + "predicate": "chatParticipant", + "params": [ + { + "name": "user_id", + "type": "int" + }, + { + "name": "inviter_id", + "type": "int" + }, + { + "name": "date", + "type": "int" + } + ], + "type": "ChatParticipant" + }, + { + "id": "-57668565", + "predicate": "chatParticipantsForbidden", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "chat_id", + "type": "int" + }, + { + "name": "self_participant", + "type": "flags.0?ChatParticipant" + } + ], + "type": "ChatParticipants" + }, + { + "id": "1061556205", + "predicate": "chatParticipants", + "params": [ + { + "name": "chat_id", + "type": "int" + }, + { + "name": "participants", + "type": "Vector" + }, + { + "name": "version", + "type": "int" + } + ], + "type": "ChatParticipants" + }, + { + "id": "935395612", + "predicate": "chatPhotoEmpty", + "params": [], + "type": "ChatPhoto" + }, + { + "id": "1632839530", + "predicate": "chatPhoto", + "params": [ + { + "name": "photo_small", + "type": "FileLocation" + }, + { + "name": "photo_big", + "type": "FileLocation" + } + ], + "type": "ChatPhoto" + }, + { + "id": "-2082087340", + "predicate": "messageEmpty", + "params": [ + { + "name": "id", + "type": "int" + } + ], + "type": "Message" + }, + { + "id": "1157215293", + "predicate": "message", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "out", + "type": "flags.1?true" + }, + { + "name": "mentioned", + "type": "flags.4?true" + }, + { + "name": "media_unread", + "type": "flags.5?true" + }, + { + "name": "silent", + "type": "flags.13?true" + }, + { + "name": "post", + "type": "flags.14?true" + }, + { + "name": "id", + "type": "int" + }, + { + "name": "from_id", + "type": "flags.8?int" + }, + { + "name": "to_id", + "type": "Peer" + }, + { + "name": "fwd_from", + "type": "flags.2?MessageFwdHeader" + }, + { + "name": "via_bot_id", + "type": "flags.11?int" + }, + { + "name": "reply_to_msg_id", + "type": "flags.3?int" + }, + { + "name": "date", + "type": "int" + }, + { + "name": "message", + "type": "string" + }, + { + "name": "media", + "type": "flags.9?MessageMedia" + }, + { + "name": "reply_markup", + "type": "flags.6?ReplyMarkup" + }, + { + "name": "entities", + "type": "flags.7?Vector" + }, + { + "name": "views", + "type": "flags.10?int" + }, + { + "name": "edit_date", + "type": "flags.15?int" + }, + { + "name": "post_author", + "type": "flags.16?string" + }, + { + "name": "grouped_id", + "type": "flags.17?long" + } + ], + "type": "Message" + }, + { + "id": "-1642487306", + "predicate": "messageService", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "out", + "type": "flags.1?true" + }, + { + "name": "mentioned", + "type": "flags.4?true" + }, + { + "name": "media_unread", + "type": "flags.5?true" + }, + { + "name": "silent", + "type": "flags.13?true" + }, + { + "name": "post", + "type": "flags.14?true" + }, + { + "name": "id", + "type": "int" + }, + { + "name": "from_id", + "type": "flags.8?int" + }, + { + "name": "to_id", + "type": "Peer" + }, + { + "name": "reply_to_msg_id", + "type": "flags.3?int" + }, + { + "name": "date", + "type": "int" + }, + { + "name": "action", + "type": "MessageAction" + } + ], + "type": "Message" + }, + { + "id": "1038967584", + "predicate": "messageMediaEmpty", + "params": [], + "type": "MessageMedia" + }, + { + "id": "-1256047857", + "predicate": "messageMediaPhoto", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "photo", + "type": "flags.0?Photo" + }, + { + "name": "caption", + "type": "flags.1?string" + }, + { + "name": "ttl_seconds", + "type": "flags.2?int" + } + ], + "type": "MessageMedia" + }, + { + "id": "1457575028", + "predicate": "messageMediaGeo", + "params": [ + { + "name": "geo", + "type": "GeoPoint" + } + ], + "type": "MessageMedia" + }, + { + "id": "1585262393", + "predicate": "messageMediaContact", + "params": [ + { + "name": "phone_number", + "type": "string" + }, + { + "name": "first_name", + "type": "string" + }, + { + "name": "last_name", + "type": "string" + }, + { + "name": "user_id", + "type": "int" + } + ], + "type": "MessageMedia" + }, + { + "id": "-1618676578", + "predicate": "messageMediaUnsupported", + "params": [], + "type": "MessageMedia" + }, + { + "id": "-1230047312", + "predicate": "messageActionEmpty", + "params": [], + "type": "MessageAction" + }, + { + "id": "-1503425638", + "predicate": "messageActionChatCreate", + "params": [ + { + "name": "title", + "type": "string" + }, + { + "name": "users", + "type": "Vector" + } + ], + "type": "MessageAction" + }, + { + "id": "-1247687078", + "predicate": "messageActionChatEditTitle", + "params": [ + { + "name": "title", + "type": "string" + } + ], + "type": "MessageAction" + }, + { + "id": "2144015272", + "predicate": "messageActionChatEditPhoto", + "params": [ + { + "name": "photo", + "type": "Photo" + } + ], + "type": "MessageAction" + }, + { + "id": "-1780220945", + "predicate": "messageActionChatDeletePhoto", + "params": [], + "type": "MessageAction" + }, + { + "id": "1217033015", + "predicate": "messageActionChatAddUser", + "params": [ + { + "name": "users", + "type": "Vector" + } + ], + "type": "MessageAction" + }, + { + "id": "-1297179892", + "predicate": "messageActionChatDeleteUser", + "params": [ + { + "name": "user_id", + "type": "int" + } + ], + "type": "MessageAction" + }, + { + "id": "-455150117", + "predicate": "dialog", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "pinned", + "type": "flags.2?true" + }, + { + "name": "peer", + "type": "Peer" + }, + { + "name": "top_message", + "type": "int" + }, + { + "name": "read_inbox_max_id", + "type": "int" + }, + { + "name": "read_outbox_max_id", + "type": "int" + }, + { + "name": "unread_count", + "type": "int" + }, + { + "name": "unread_mentions_count", + "type": "int" + }, + { + "name": "notify_settings", + "type": "PeerNotifySettings" + }, + { + "name": "pts", + "type": "flags.0?int" + }, + { + "name": "draft", + "type": "flags.1?DraftMessage" + } + ], + "type": "Dialog" + }, + { + "id": "590459437", + "predicate": "photoEmpty", + "params": [ + { + "name": "id", + "type": "long" + } + ], + "type": "Photo" + }, + { + "id": "-1836524247", + "predicate": "photo", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "has_stickers", + "type": "flags.0?true" + }, + { + "name": "id", + "type": "long" + }, + { + "name": "access_hash", + "type": "long" + }, + { + "name": "date", + "type": "int" + }, + { + "name": "sizes", + "type": "Vector" + } + ], + "type": "Photo" + }, + { + "id": "236446268", + "predicate": "photoSizeEmpty", + "params": [ + { + "name": "type", + "type": "string" + } + ], + "type": "PhotoSize" + }, + { + "id": "2009052699", + "predicate": "photoSize", + "params": [ + { + "name": "type", + "type": "string" + }, + { + "name": "location", + "type": "FileLocation" + }, + { + "name": "w", + "type": "int" + }, + { + "name": "h", + "type": "int" + }, + { + "name": "size", + "type": "int" + } + ], + "type": "PhotoSize" + }, + { + "id": "-374917894", + "predicate": "photoCachedSize", + "params": [ + { + "name": "type", + "type": "string" + }, + { + "name": "location", + "type": "FileLocation" + }, + { + "name": "w", + "type": "int" + }, + { + "name": "h", + "type": "int" + }, + { + "name": "bytes", + "type": "bytes" + } + ], + "type": "PhotoSize" + }, + { + "id": "286776671", + "predicate": "geoPointEmpty", + "params": [], + "type": "GeoPoint" + }, + { + "id": "541710092", + "predicate": "geoPoint", + "params": [ + { + "name": "long", + "type": "double" + }, + { + "name": "lat", + "type": "double" + } + ], + "type": "GeoPoint" + }, + { + "id": "-2128698738", + "predicate": "auth.checkedPhone", + "params": [ + { + "name": "phone_registered", + "type": "Bool" + } + ], + "type": "auth.CheckedPhone" + }, + { + "id": "1577067778", + "predicate": "auth.sentCode", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "phone_registered", + "type": "flags.0?true" + }, + { + "name": "type", + "type": "auth.SentCodeType" + }, + { + "name": "phone_code_hash", + "type": "string" + }, + { + "name": "next_type", + "type": "flags.1?auth.CodeType" + }, + { + "name": "timeout", + "type": "flags.2?int" + } + ], + "type": "auth.SentCode" + }, + { + "id": "-855308010", + "predicate": "auth.authorization", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "tmp_sessions", + "type": "flags.0?int" + }, + { + "name": "user", + "type": "User" + } + ], + "type": "auth.Authorization" + }, + { + "id": "-543777747", + "predicate": "auth.exportedAuthorization", + "params": [ + { + "name": "id", + "type": "int" + }, + { + "name": "bytes", + "type": "bytes" + } + ], + "type": "auth.ExportedAuthorization" + }, + { + "id": "-1195615476", + "predicate": "inputNotifyPeer", + "params": [ + { + "name": "peer", + "type": "InputPeer" + } + ], + "type": "InputNotifyPeer" + }, + { + "id": "423314455", + "predicate": "inputNotifyUsers", + "params": [], + "type": "InputNotifyPeer" + }, + { + "id": "1251338318", + "predicate": "inputNotifyChats", + "params": [], + "type": "InputNotifyPeer" + }, + { + "id": "-1540769658", + "predicate": "inputNotifyAll", + "params": [], + "type": "InputNotifyPeer" + }, + { + "id": "949182130", + "predicate": "inputPeerNotifySettings", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "show_previews", + "type": "flags.0?true" + }, + { + "name": "silent", + "type": "flags.1?true" + }, + { + "name": "mute_until", + "type": "int" + }, + { + "name": "sound", + "type": "string" + } + ], + "type": "InputPeerNotifySettings" + }, + { + "id": "-1378534221", + "predicate": "peerNotifyEventsEmpty", + "params": [], + "type": "PeerNotifyEvents" + }, + { + "id": "1830677896", + "predicate": "peerNotifyEventsAll", + "params": [], + "type": "PeerNotifyEvents" + }, + { + "id": "1889961234", + "predicate": "peerNotifySettingsEmpty", + "params": [], + "type": "PeerNotifySettings" + }, + { + "id": "-1697798976", + "predicate": "peerNotifySettings", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "show_previews", + "type": "flags.0?true" + }, + { + "name": "silent", + "type": "flags.1?true" + }, + { + "name": "mute_until", + "type": "int" + }, + { + "name": "sound", + "type": "string" + } + ], + "type": "PeerNotifySettings" + }, + { + "id": "-860866985", + "predicate": "wallPaper", + "params": [ + { + "name": "id", + "type": "int" + }, + { + "name": "title", + "type": "string" + }, + { + "name": "sizes", + "type": "Vector" + }, + { + "name": "color", + "type": "int" + } + ], + "type": "WallPaper" + }, + { + "id": "253890367", + "predicate": "userFull", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "blocked", + "type": "flags.0?true" + }, + { + "name": "phone_calls_available", + "type": "flags.4?true" + }, + { + "name": "phone_calls_private", + "type": "flags.5?true" + }, + { + "name": "user", + "type": "User" + }, + { + "name": "about", + "type": "flags.1?string" + }, + { + "name": "link", + "type": "contacts.Link" + }, + { + "name": "profile_photo", + "type": "flags.2?Photo" + }, + { + "name": "notify_settings", + "type": "PeerNotifySettings" + }, + { + "name": "bot_info", + "type": "flags.3?BotInfo" + }, + { + "name": "common_chats_count", + "type": "int" + } + ], + "type": "UserFull" + }, + { + "id": "-116274796", + "predicate": "contact", + "params": [ + { + "name": "user_id", + "type": "int" + }, + { + "name": "mutual", + "type": "Bool" + } + ], + "type": "Contact" + }, + { + "id": "-805141448", + "predicate": "importedContact", + "params": [ + { + "name": "user_id", + "type": "int" + }, + { + "name": "client_id", + "type": "long" + } + ], + "type": "ImportedContact" + }, + { + "id": "1444661369", + "predicate": "contactBlocked", + "params": [ + { + "name": "user_id", + "type": "int" + }, + { + "name": "date", + "type": "int" + } + ], + "type": "ContactBlocked" + }, + { + "id": "-748155807", + "predicate": "contactStatus", + "params": [ + { + "name": "user_id", + "type": "int" + }, + { + "name": "status", + "type": "UserStatus" + } + ], + "type": "ContactStatus" + }, + { + "id": "986597452", + "predicate": "contacts.link", + "params": [ + { + "name": "my_link", + "type": "ContactLink" + }, + { + "name": "foreign_link", + "type": "ContactLink" + }, + { + "name": "user", + "type": "User" + } + ], + "type": "contacts.Link" + }, + { + "id": "-353862078", + "predicate": "contacts.contacts", + "params": [ + { + "name": "contacts", + "type": "Vector" + }, + { + "name": "saved_count", + "type": "int" + }, + { + "name": "users", + "type": "Vector" + } + ], + "type": "contacts.Contacts" + }, + { + "id": "-1219778094", + "predicate": "contacts.contactsNotModified", + "params": [], + "type": "contacts.Contacts" + }, + { + "id": "2010127419", + "predicate": "contacts.importedContacts", + "params": [ + { + "name": "imported", + "type": "Vector" + }, + { + "name": "popular_invites", + "type": "Vector" + }, + { + "name": "retry_contacts", + "type": "Vector" + }, + { + "name": "users", + "type": "Vector" + } + ], + "type": "contacts.ImportedContacts" + }, + { + "id": "471043349", + "predicate": "contacts.blocked", + "params": [ + { + "name": "blocked", + "type": "Vector" + }, + { + "name": "users", + "type": "Vector" + } + ], + "type": "contacts.Blocked" + }, + { + "id": "-1878523231", + "predicate": "contacts.blockedSlice", + "params": [ + { + "name": "count", + "type": "int" + }, + { + "name": "blocked", + "type": "Vector" + }, + { + "name": "users", + "type": "Vector" + } + ], + "type": "contacts.Blocked" + }, + { + "id": "-1290580579", + "predicate": "contacts.found", + "params": [ + { + "name": "my_results", + "type": "Vector" + }, + { + "name": "results", + "type": "Vector" + }, + { + "name": "chats", + "type": "Vector" + }, + { + "name": "users", + "type": "Vector" + } + ], + "type": "contacts.Found" + }, + { + "id": "364538944", + "predicate": "messages.dialogs", + "params": [ + { + "name": "dialogs", + "type": "Vector" + }, + { + "name": "messages", + "type": "Vector" + }, + { + "name": "chats", + "type": "Vector" + }, + { + "name": "users", + "type": "Vector" + } + ], + "type": "messages.Dialogs" + }, + { + "id": "1910543603", + "predicate": "messages.dialogsSlice", + "params": [ + { + "name": "count", + "type": "int" + }, + { + "name": "dialogs", + "type": "Vector" + }, + { + "name": "messages", + "type": "Vector" + }, + { + "name": "chats", + "type": "Vector" + }, + { + "name": "users", + "type": "Vector" + } + ], + "type": "messages.Dialogs" + }, + { + "id": "-1938715001", + "predicate": "messages.messages", + "params": [ + { + "name": "messages", + "type": "Vector" + }, + { + "name": "chats", + "type": "Vector" + }, + { + "name": "users", + "type": "Vector" + } + ], + "type": "messages.Messages" + }, + { + "id": "189033187", + "predicate": "messages.messagesSlice", + "params": [ + { + "name": "count", + "type": "int" + }, + { + "name": "messages", + "type": "Vector" + }, + { + "name": "chats", + "type": "Vector" + }, + { + "name": "users", + "type": "Vector" + } + ], + "type": "messages.Messages" + }, + { + "id": "1694474197", + "predicate": "messages.chats", + "params": [ + { + "name": "chats", + "type": "Vector" + } + ], + "type": "messages.Chats" + }, + { + "id": "-438840932", + "predicate": "messages.chatFull", + "params": [ + { + "name": "full_chat", + "type": "ChatFull" + }, + { + "name": "chats", + "type": "Vector" + }, + { + "name": "users", + "type": "Vector" + } + ], + "type": "messages.ChatFull" + }, + { + "id": "-1269012015", + "predicate": "messages.affectedHistory", + "params": [ + { + "name": "pts", + "type": "int" + }, + { + "name": "pts_count", + "type": "int" + }, + { + "name": "offset", + "type": "int" + } + ], + "type": "messages.AffectedHistory" + }, + { + "id": "1474492012", + "predicate": "inputMessagesFilterEmpty", + "params": [], + "type": "MessagesFilter" + }, + { + "id": "-1777752804", + "predicate": "inputMessagesFilterPhotos", + "params": [], + "type": "MessagesFilter" + }, + { + "id": "-1614803355", + "predicate": "inputMessagesFilterVideo", + "params": [], + "type": "MessagesFilter" + }, + { + "id": "1458172132", + "predicate": "inputMessagesFilterPhotoVideo", + "params": [], + "type": "MessagesFilter" + }, + { + "id": "522914557", + "predicate": "updateNewMessage", + "params": [ + { + "name": "message", + "type": "Message" + }, + { + "name": "pts", + "type": "int" + }, + { + "name": "pts_count", + "type": "int" + } + ], + "type": "Update" + }, + { + "id": "1318109142", + "predicate": "updateMessageID", + "params": [ + { + "name": "id", + "type": "int" + }, + { + "name": "random_id", + "type": "long" + } + ], + "type": "Update" + }, + { + "id": "-1576161051", + "predicate": "updateDeleteMessages", + "params": [ + { + "name": "messages", + "type": "Vector" + }, + { + "name": "pts", + "type": "int" + }, + { + "name": "pts_count", + "type": "int" + } + ], + "type": "Update" + }, + { + "id": "1548249383", + "predicate": "updateUserTyping", + "params": [ + { + "name": "user_id", + "type": "int" + }, + { + "name": "action", + "type": "SendMessageAction" + } + ], + "type": "Update" + }, + { + "id": "-1704596961", + "predicate": "updateChatUserTyping", + "params": [ + { + "name": "chat_id", + "type": "int" + }, + { + "name": "user_id", + "type": "int" + }, + { + "name": "action", + "type": "SendMessageAction" + } + ], + "type": "Update" + }, + { + "id": "125178264", + "predicate": "updateChatParticipants", + "params": [ + { + "name": "participants", + "type": "ChatParticipants" + } + ], + "type": "Update" + }, + { + "id": "469489699", + "predicate": "updateUserStatus", + "params": [ + { + "name": "user_id", + "type": "int" + }, + { + "name": "status", + "type": "UserStatus" + } + ], + "type": "Update" + }, + { + "id": "-1489818765", + "predicate": "updateUserName", + "params": [ + { + "name": "user_id", + "type": "int" + }, + { + "name": "first_name", + "type": "string" + }, + { + "name": "last_name", + "type": "string" + }, + { + "name": "username", + "type": "string" + } + ], + "type": "Update" + }, + { + "id": "-1791935732", + "predicate": "updateUserPhoto", + "params": [ + { + "name": "user_id", + "type": "int" + }, + { + "name": "date", + "type": "int" + }, + { + "name": "photo", + "type": "UserProfilePhoto" + }, + { + "name": "previous", + "type": "Bool" + } + ], + "type": "Update" + }, + { + "id": "628472761", + "predicate": "updateContactRegistered", + "params": [ + { + "name": "user_id", + "type": "int" + }, + { + "name": "date", + "type": "int" + } + ], + "type": "Update" + }, + { + "id": "-1657903163", + "predicate": "updateContactLink", + "params": [ + { + "name": "user_id", + "type": "int" + }, + { + "name": "my_link", + "type": "ContactLink" + }, + { + "name": "foreign_link", + "type": "ContactLink" + } + ], + "type": "Update" + }, + { + "id": "-1519637954", + "predicate": "updates.state", + "params": [ + { + "name": "pts", + "type": "int" + }, + { + "name": "qts", + "type": "int" + }, + { + "name": "date", + "type": "int" + }, + { + "name": "seq", + "type": "int" + }, + { + "name": "unread_count", + "type": "int" + } + ], + "type": "updates.State" + }, + { + "id": "1567990072", + "predicate": "updates.differenceEmpty", + "params": [ + { + "name": "date", + "type": "int" + }, + { + "name": "seq", + "type": "int" + } + ], + "type": "updates.Difference" + }, + { + "id": "16030880", + "predicate": "updates.difference", + "params": [ + { + "name": "new_messages", + "type": "Vector" + }, + { + "name": "new_encrypted_messages", + "type": "Vector" + }, + { + "name": "other_updates", + "type": "Vector" + }, + { + "name": "chats", + "type": "Vector" + }, + { + "name": "users", + "type": "Vector" + }, + { + "name": "state", + "type": "updates.State" + } + ], + "type": "updates.Difference" + }, + { + "id": "-1459938943", + "predicate": "updates.differenceSlice", + "params": [ + { + "name": "new_messages", + "type": "Vector" + }, + { + "name": "new_encrypted_messages", + "type": "Vector" + }, + { + "name": "other_updates", + "type": "Vector" + }, + { + "name": "chats", + "type": "Vector" + }, + { + "name": "users", + "type": "Vector" + }, + { + "name": "intermediate_state", + "type": "updates.State" + } + ], + "type": "updates.Difference" + }, + { + "id": "-484987010", + "predicate": "updatesTooLong", + "params": [], + "type": "Updates" + }, + { + "id": "-1857044719", + "predicate": "updateShortMessage", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "out", + "type": "flags.1?true" + }, + { + "name": "mentioned", + "type": "flags.4?true" + }, + { + "name": "media_unread", + "type": "flags.5?true" + }, + { + "name": "silent", + "type": "flags.13?true" + }, + { + "name": "id", + "type": "int" + }, + { + "name": "user_id", + "type": "int" + }, + { + "name": "message", + "type": "string" + }, + { + "name": "pts", + "type": "int" + }, + { + "name": "pts_count", + "type": "int" + }, + { + "name": "date", + "type": "int" + }, + { + "name": "fwd_from", + "type": "flags.2?MessageFwdHeader" + }, + { + "name": "via_bot_id", + "type": "flags.11?int" + }, + { + "name": "reply_to_msg_id", + "type": "flags.3?int" + }, + { + "name": "entities", + "type": "flags.7?Vector" + } + ], + "type": "Updates" + }, + { + "id": "377562760", + "predicate": "updateShortChatMessage", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "out", + "type": "flags.1?true" + }, + { + "name": "mentioned", + "type": "flags.4?true" + }, + { + "name": "media_unread", + "type": "flags.5?true" + }, + { + "name": "silent", + "type": "flags.13?true" + }, + { + "name": "id", + "type": "int" + }, + { + "name": "from_id", + "type": "int" + }, + { + "name": "chat_id", + "type": "int" + }, + { + "name": "message", + "type": "string" + }, + { + "name": "pts", + "type": "int" + }, + { + "name": "pts_count", + "type": "int" + }, + { + "name": "date", + "type": "int" + }, + { + "name": "fwd_from", + "type": "flags.2?MessageFwdHeader" + }, + { + "name": "via_bot_id", + "type": "flags.11?int" + }, + { + "name": "reply_to_msg_id", + "type": "flags.3?int" + }, + { + "name": "entities", + "type": "flags.7?Vector" + } + ], + "type": "Updates" + }, + { + "id": "2027216577", + "predicate": "updateShort", + "params": [ + { + "name": "update", + "type": "Update" + }, + { + "name": "date", + "type": "int" + } + ], + "type": "Updates" + }, + { + "id": "1918567619", + "predicate": "updatesCombined", + "params": [ + { + "name": "updates", + "type": "Vector" + }, + { + "name": "users", + "type": "Vector" + }, + { + "name": "chats", + "type": "Vector" + }, + { + "name": "date", + "type": "int" + }, + { + "name": "seq_start", + "type": "int" + }, + { + "name": "seq", + "type": "int" + } + ], + "type": "Updates" + }, + { + "id": "1957577280", + "predicate": "updates", + "params": [ + { + "name": "updates", + "type": "Vector" + }, + { + "name": "users", + "type": "Vector" + }, + { + "name": "chats", + "type": "Vector" + }, + { + "name": "date", + "type": "int" + }, + { + "name": "seq", + "type": "int" + } + ], + "type": "Updates" + }, + { + "id": "539045032", + "predicate": "photos.photo", + "params": [ + { + "name": "photo", + "type": "Photo" + }, + { + "name": "users", + "type": "Vector" + } + ], + "type": "photos.Photo" + }, + { + "id": "157948117", + "predicate": "upload.file", + "params": [ + { + "name": "type", + "type": "storage.FileType" + }, + { + "name": "mtime", + "type": "int" + }, + { + "name": "bytes", + "type": "bytes" + } + ], + "type": "upload.File" + }, + { + "id": "98092748", + "predicate": "dcOption", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "ipv6", + "type": "flags.0?true" + }, + { + "name": "media_only", + "type": "flags.1?true" + }, + { + "name": "tcpo_only", + "type": "flags.2?true" + }, + { + "name": "cdn", + "type": "flags.3?true" + }, + { + "name": "static", + "type": "flags.4?true" + }, + { + "name": "id", + "type": "int" + }, + { + "name": "ip_address", + "type": "string" + }, + { + "name": "port", + "type": "int" + } + ], + "type": "DcOption" + }, + { + "id": "-1669068444", + "predicate": "config", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "phonecalls_enabled", + "type": "flags.1?true" + }, + { + "name": "default_p2p_contacts", + "type": "flags.3?true" + }, + { + "name": "date", + "type": "int" + }, + { + "name": "expires", + "type": "int" + }, + { + "name": "test_mode", + "type": "Bool" + }, + { + "name": "this_dc", + "type": "int" + }, + { + "name": "dc_options", + "type": "Vector" + }, + { + "name": "chat_size_max", + "type": "int" + }, + { + "name": "megagroup_size_max", + "type": "int" + }, + { + "name": "forwarded_count_max", + "type": "int" + }, + { + "name": "online_update_period_ms", + "type": "int" + }, + { + "name": "offline_blur_timeout_ms", + "type": "int" + }, + { + "name": "offline_idle_timeout_ms", + "type": "int" + }, + { + "name": "online_cloud_timeout_ms", + "type": "int" + }, + { + "name": "notify_cloud_delay_ms", + "type": "int" + }, + { + "name": "notify_default_delay_ms", + "type": "int" + }, + { + "name": "chat_big_size", + "type": "int" + }, + { + "name": "push_chat_period_ms", + "type": "int" + }, + { + "name": "push_chat_limit", + "type": "int" + }, + { + "name": "saved_gifs_limit", + "type": "int" + }, + { + "name": "edit_time_limit", + "type": "int" + }, + { + "name": "rating_e_decay", + "type": "int" + }, + { + "name": "stickers_recent_limit", + "type": "int" + }, + { + "name": "stickers_faved_limit", + "type": "int" + }, + { + "name": "channels_read_media_period", + "type": "int" + }, + { + "name": "tmp_sessions", + "type": "flags.0?int" + }, + { + "name": "pinned_dialogs_count_max", + "type": "int" + }, + { + "name": "call_receive_timeout_ms", + "type": "int" + }, + { + "name": "call_ring_timeout_ms", + "type": "int" + }, + { + "name": "call_connect_timeout_ms", + "type": "int" + }, + { + "name": "call_packet_timeout_ms", + "type": "int" + }, + { + "name": "me_url_prefix", + "type": "string" + }, + { + "name": "suggested_lang_code", + "type": "flags.2?string" + }, + { + "name": "lang_pack_version", + "type": "flags.2?int" + }, + { + "name": "disabled_features", + "type": "Vector" + } + ], + "type": "Config" + }, + { + "id": "-1910892683", + "predicate": "nearestDc", + "params": [ + { + "name": "country", + "type": "string" + }, + { + "name": "this_dc", + "type": "int" + }, + { + "name": "nearest_dc", + "type": "int" + } + ], + "type": "NearestDc" + }, + { + "id": "-1987579119", + "predicate": "help.appUpdate", + "params": [ + { + "name": "id", + "type": "int" + }, + { + "name": "critical", + "type": "Bool" + }, + { + "name": "url", + "type": "string" + }, + { + "name": "text", + "type": "string" + } + ], + "type": "help.AppUpdate" + }, + { + "id": "-1000708810", + "predicate": "help.noAppUpdate", + "params": [], + "type": "help.AppUpdate" + }, + { + "id": "415997816", + "predicate": "help.inviteText", + "params": [ + { + "name": "message", + "type": "string" + } + ], + "type": "help.InviteText" + }, + { + "id": "-265263912", + "predicate": "inputPeerNotifyEventsEmpty", + "params": [], + "type": "InputPeerNotifyEvents" + }, + { + "id": "-395694988", + "predicate": "inputPeerNotifyEventsAll", + "params": [], + "type": "InputPeerNotifyEvents" + }, + { + "id": "-1916114267", + "predicate": "photos.photos", + "params": [ + { + "name": "photos", + "type": "Vector" + }, + { + "name": "users", + "type": "Vector" + } + ], + "type": "photos.Photos" + }, + { + "id": "352657236", + "predicate": "photos.photosSlice", + "params": [ + { + "name": "count", + "type": "int" + }, + { + "name": "photos", + "type": "Vector" + }, + { + "name": "users", + "type": "Vector" + } + ], + "type": "photos.Photos" + }, + { + "id": "1662091044", + "predicate": "wallPaperSolid", + "params": [ + { + "name": "id", + "type": "int" + }, + { + "name": "title", + "type": "string" + }, + { + "name": "bg_color", + "type": "int" + }, + { + "name": "color", + "type": "int" + } + ], + "type": "WallPaper" + }, + { + "id": "314359194", + "predicate": "updateNewEncryptedMessage", + "params": [ + { + "name": "message", + "type": "EncryptedMessage" + }, + { + "name": "qts", + "type": "int" + } + ], + "type": "Update" + }, + { + "id": "386986326", + "predicate": "updateEncryptedChatTyping", + "params": [ + { + "name": "chat_id", + "type": "int" + } + ], + "type": "Update" + }, + { + "id": "-1264392051", + "predicate": "updateEncryption", + "params": [ + { + "name": "chat", + "type": "EncryptedChat" + }, + { + "name": "date", + "type": "int" + } + ], + "type": "Update" + }, + { + "id": "956179895", + "predicate": "updateEncryptedMessagesRead", + "params": [ + { + "name": "chat_id", + "type": "int" + }, + { + "name": "max_date", + "type": "int" + }, + { + "name": "date", + "type": "int" + } + ], + "type": "Update" + }, + { + "id": "-1417756512", + "predicate": "encryptedChatEmpty", + "params": [ + { + "name": "id", + "type": "int" + } + ], + "type": "EncryptedChat" + }, + { + "id": "1006044124", + "predicate": "encryptedChatWaiting", + "params": [ + { + "name": "id", + "type": "int" + }, + { + "name": "access_hash", + "type": "long" + }, + { + "name": "date", + "type": "int" + }, + { + "name": "admin_id", + "type": "int" + }, + { + "name": "participant_id", + "type": "int" + } + ], + "type": "EncryptedChat" + }, + { + "id": "-931638658", + "predicate": "encryptedChatRequested", + "params": [ + { + "name": "id", + "type": "int" + }, + { + "name": "access_hash", + "type": "long" + }, + { + "name": "date", + "type": "int" + }, + { + "name": "admin_id", + "type": "int" + }, + { + "name": "participant_id", + "type": "int" + }, + { + "name": "g_a", + "type": "bytes" + } + ], + "type": "EncryptedChat" + }, + { + "id": "-94974410", + "predicate": "encryptedChat", + "params": [ + { + "name": "id", + "type": "int" + }, + { + "name": "access_hash", + "type": "long" + }, + { + "name": "date", + "type": "int" + }, + { + "name": "admin_id", + "type": "int" + }, + { + "name": "participant_id", + "type": "int" + }, + { + "name": "g_a_or_b", + "type": "bytes" + }, + { + "name": "key_fingerprint", + "type": "long" + } + ], + "type": "EncryptedChat" + }, + { + "id": "332848423", + "predicate": "encryptedChatDiscarded", + "params": [ + { + "name": "id", + "type": "int" + } + ], + "type": "EncryptedChat" + }, + { + "id": "-247351839", + "predicate": "inputEncryptedChat", + "params": [ + { + "name": "chat_id", + "type": "int" + }, + { + "name": "access_hash", + "type": "long" + } + ], + "type": "InputEncryptedChat" + }, + { + "id": "-1038136962", + "predicate": "encryptedFileEmpty", + "params": [], + "type": "EncryptedFile" + }, + { + "id": "1248893260", + "predicate": "encryptedFile", + "params": [ + { + "name": "id", + "type": "long" + }, + { + "name": "access_hash", + "type": "long" + }, + { + "name": "size", + "type": "int" + }, + { + "name": "dc_id", + "type": "int" + }, + { + "name": "key_fingerprint", + "type": "int" + } + ], + "type": "EncryptedFile" + }, + { + "id": "406307684", + "predicate": "inputEncryptedFileEmpty", + "params": [], + "type": "InputEncryptedFile" + }, + { + "id": "1690108678", + "predicate": "inputEncryptedFileUploaded", + "params": [ + { + "name": "id", + "type": "long" + }, + { + "name": "parts", + "type": "int" + }, + { + "name": "md5_checksum", + "type": "string" + }, + { + "name": "key_fingerprint", + "type": "int" + } + ], + "type": "InputEncryptedFile" + }, + { + "id": "1511503333", + "predicate": "inputEncryptedFile", + "params": [ + { + "name": "id", + "type": "long" + }, + { + "name": "access_hash", + "type": "long" + } + ], + "type": "InputEncryptedFile" + }, + { + "id": "-182231723", + "predicate": "inputEncryptedFileLocation", + "params": [ + { + "name": "id", + "type": "long" + }, + { + "name": "access_hash", + "type": "long" + } + ], + "type": "InputFileLocation" + }, + { + "id": "-317144808", + "predicate": "encryptedMessage", + "params": [ + { + "name": "random_id", + "type": "long" + }, + { + "name": "chat_id", + "type": "int" + }, + { + "name": "date", + "type": "int" + }, + { + "name": "bytes", + "type": "bytes" + }, + { + "name": "file", + "type": "EncryptedFile" + } + ], + "type": "EncryptedMessage" + }, + { + "id": "594758406", + "predicate": "encryptedMessageService", + "params": [ + { + "name": "random_id", + "type": "long" + }, + { + "name": "chat_id", + "type": "int" + }, + { + "name": "date", + "type": "int" + }, + { + "name": "bytes", + "type": "bytes" + } + ], + "type": "EncryptedMessage" + }, + { + "id": "-1058912715", + "predicate": "messages.dhConfigNotModified", + "params": [ + { + "name": "random", + "type": "bytes" + } + ], + "type": "messages.DhConfig" + }, + { + "id": "740433629", + "predicate": "messages.dhConfig", + "params": [ + { + "name": "g", + "type": "int" + }, + { + "name": "p", + "type": "bytes" + }, + { + "name": "version", + "type": "int" + }, + { + "name": "random", + "type": "bytes" + } + ], + "type": "messages.DhConfig" + }, + { + "id": "1443858741", + "predicate": "messages.sentEncryptedMessage", + "params": [ + { + "name": "date", + "type": "int" + } + ], + "type": "messages.SentEncryptedMessage" + }, + { + "id": "-1802240206", + "predicate": "messages.sentEncryptedFile", + "params": [ + { + "name": "date", + "type": "int" + }, + { + "name": "file", + "type": "EncryptedFile" + } + ], + "type": "messages.SentEncryptedMessage" + }, + { + "id": "-95482955", + "predicate": "inputFileBig", + "params": [ + { + "name": "id", + "type": "long" + }, + { + "name": "parts", + "type": "int" + }, + { + "name": "name", + "type": "string" + } + ], + "type": "InputFile" + }, + { + "id": "767652808", + "predicate": "inputEncryptedFileBigUploaded", + "params": [ + { + "name": "id", + "type": "long" + }, + { + "name": "parts", + "type": "int" + }, + { + "name": "key_fingerprint", + "type": "int" + } + ], + "type": "InputEncryptedFile" + }, + { + "id": "-1373745011", + "predicate": "storage.filePdf", + "params": [], + "type": "storage.FileType" + }, + { + "id": "-1629621880", + "predicate": "inputMessagesFilterDocument", + "params": [], + "type": "MessagesFilter" + }, + { + "id": "-364179876", + "predicate": "updateChatParticipantAdd", + "params": [ + { + "name": "chat_id", + "type": "int" + }, + { + "name": "user_id", + "type": "int" + }, + { + "name": "inviter_id", + "type": "int" + }, + { + "name": "date", + "type": "int" + }, + { + "name": "version", + "type": "int" + } + ], + "type": "Update" + }, + { + "id": "1851755554", + "predicate": "updateChatParticipantDelete", + "params": [ + { + "name": "chat_id", + "type": "int" + }, + { + "name": "user_id", + "type": "int" + }, + { + "name": "version", + "type": "int" + } + ], + "type": "Update" + }, + { + "id": "-1906403213", + "predicate": "updateDcOptions", + "params": [ + { + "name": "dc_options", + "type": "Vector" + } + ], + "type": "Update" + }, + { + "id": "-476700163", + "predicate": "inputMediaUploadedDocument", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "file", + "type": "InputFile" + }, + { + "name": "thumb", + "type": "flags.2?InputFile" + }, + { + "name": "mime_type", + "type": "string" + }, + { + "name": "attributes", + "type": "Vector" + }, + { + "name": "caption", + "type": "string" + }, + { + "name": "stickers", + "type": "flags.0?Vector" + }, + { + "name": "ttl_seconds", + "type": "flags.1?int" + }, + { + "name": "nosound_video", + "type": "flags.3?true" + } + ], + "type": "InputMedia" + }, + { + "id": "1523279502", + "predicate": "inputMediaDocument", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "id", + "type": "InputDocument" + }, + { + "name": "caption", + "type": "string" + }, + { + "name": "ttl_seconds", + "type": "flags.0?int" + } + ], + "type": "InputMedia" + }, + { + "id": "2084836563", + "predicate": "messageMediaDocument", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "document", + "type": "flags.0?Document" + }, + { + "name": "caption", + "type": "flags.1?string" + }, + { + "name": "ttl_seconds", + "type": "flags.2?int" + } + ], + "type": "MessageMedia" + }, + { + "id": "1928391342", + "predicate": "inputDocumentEmpty", + "params": [], + "type": "InputDocument" + }, + { + "id": "410618194", + "predicate": "inputDocument", + "params": [ + { + "name": "id", + "type": "long" + }, + { + "name": "access_hash", + "type": "long" + } + ], + "type": "InputDocument" + }, + { + "id": "1125058340", + "predicate": "inputDocumentFileLocation", + "params": [ + { + "name": "id", + "type": "long" + }, + { + "name": "access_hash", + "type": "long" + }, + { + "name": "version", + "type": "int" + } + ], + "type": "InputFileLocation" + }, + { + "id": "922273905", + "predicate": "documentEmpty", + "params": [ + { + "name": "id", + "type": "long" + } + ], + "type": "Document" + }, + { + "id": "-2027738169", + "predicate": "document", + "params": [ + { + "name": "id", + "type": "long" + }, + { + "name": "access_hash", + "type": "long" + }, + { + "name": "date", + "type": "int" + }, + { + "name": "mime_type", + "type": "string" + }, + { + "name": "size", + "type": "int" + }, + { + "name": "thumb", + "type": "PhotoSize" + }, + { + "name": "dc_id", + "type": "int" + }, + { + "name": "version", + "type": "int" + }, + { + "name": "attributes", + "type": "Vector" + } + ], + "type": "Document" + }, + { + "id": "398898678", + "predicate": "help.support", + "params": [ + { + "name": "phone_number", + "type": "string" + }, + { + "name": "user", + "type": "User" + } + ], + "type": "help.Support" + }, + { + "id": "1959820384", + "predicate": "notifyAll", + "params": [], + "type": "NotifyPeer" + }, + { + "id": "-1073230141", + "predicate": "notifyChats", + "params": [], + "type": "NotifyPeer" + }, + { + "id": "-1613493288", + "predicate": "notifyPeer", + "params": [ + { + "name": "peer", + "type": "Peer" + } + ], + "type": "NotifyPeer" + }, + { + "id": "-1261946036", + "predicate": "notifyUsers", + "params": [], + "type": "NotifyPeer" + }, + { + "id": "-2131957734", + "predicate": "updateUserBlocked", + "params": [ + { + "name": "user_id", + "type": "int" + }, + { + "name": "blocked", + "type": "Bool" + } + ], + "type": "Update" + }, + { + "id": "-1094555409", + "predicate": "updateNotifySettings", + "params": [ + { + "name": "peer", + "type": "NotifyPeer" + }, + { + "name": "notify_settings", + "type": "PeerNotifySettings" + } + ], + "type": "Update" + }, + { + "id": "381645902", + "predicate": "sendMessageTypingAction", + "params": [], + "type": "SendMessageAction" + }, + { + "id": "-44119819", + "predicate": "sendMessageCancelAction", + "params": [], + "type": "SendMessageAction" + }, + { + "id": "-1584933265", + "predicate": "sendMessageRecordVideoAction", + "params": [], + "type": "SendMessageAction" + }, + { + "id": "-378127636", + "predicate": "sendMessageUploadVideoAction", + "params": [ + { + "name": "progress", + "type": "int" + } + ], + "type": "SendMessageAction" + }, + { + "id": "-718310409", + "predicate": "sendMessageRecordAudioAction", + "params": [], + "type": "SendMessageAction" + }, + { + "id": "-212740181", + "predicate": "sendMessageUploadAudioAction", + "params": [ + { + "name": "progress", + "type": "int" + } + ], + "type": "SendMessageAction" + }, + { + "id": "-774682074", + "predicate": "sendMessageUploadPhotoAction", + "params": [ + { + "name": "progress", + "type": "int" + } + ], + "type": "SendMessageAction" + }, + { + "id": "-1441998364", + "predicate": "sendMessageUploadDocumentAction", + "params": [ + { + "name": "progress", + "type": "int" + } + ], + "type": "SendMessageAction" + }, + { + "id": "393186209", + "predicate": "sendMessageGeoLocationAction", + "params": [], + "type": "SendMessageAction" + }, + { + "id": "1653390447", + "predicate": "sendMessageChooseContactAction", + "params": [], + "type": "SendMessageAction" + }, + { + "id": "-337352679", + "predicate": "updateServiceNotification", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "popup", + "type": "flags.0?true" + }, + { + "name": "inbox_date", + "type": "flags.1?int" + }, + { + "name": "type", + "type": "string" + }, + { + "name": "message", + "type": "string" + }, + { + "name": "media", + "type": "MessageMedia" + }, + { + "name": "entities", + "type": "Vector" + } + ], + "type": "Update" + }, + { + "id": "-496024847", + "predicate": "userStatusRecently", + "params": [], + "type": "UserStatus" + }, + { + "id": "129960444", + "predicate": "userStatusLastWeek", + "params": [], + "type": "UserStatus" + }, + { + "id": "2011940674", + "predicate": "userStatusLastMonth", + "params": [], + "type": "UserStatus" + }, + { + "id": "-298113238", + "predicate": "updatePrivacy", + "params": [ + { + "name": "key", + "type": "PrivacyKey" + }, + { + "name": "rules", + "type": "Vector" + } + ], + "type": "Update" + }, + { + "id": "1335282456", + "predicate": "inputPrivacyKeyStatusTimestamp", + "params": [], + "type": "InputPrivacyKey" + }, + { + "id": "-1137792208", + "predicate": "privacyKeyStatusTimestamp", + "params": [], + "type": "PrivacyKey" + }, + { + "id": "218751099", + "predicate": "inputPrivacyValueAllowContacts", + "params": [], + "type": "InputPrivacyRule" + }, + { + "id": "407582158", + "predicate": "inputPrivacyValueAllowAll", + "params": [], + "type": "InputPrivacyRule" + }, + { + "id": "320652927", + "predicate": "inputPrivacyValueAllowUsers", + "params": [ + { + "name": "users", + "type": "Vector" + } + ], + "type": "InputPrivacyRule" + }, + { + "id": "195371015", + "predicate": "inputPrivacyValueDisallowContacts", + "params": [], + "type": "InputPrivacyRule" + }, + { + "id": "-697604407", + "predicate": "inputPrivacyValueDisallowAll", + "params": [], + "type": "InputPrivacyRule" + }, + { + "id": "-1877932953", + "predicate": "inputPrivacyValueDisallowUsers", + "params": [ + { + "name": "users", + "type": "Vector" + } + ], + "type": "InputPrivacyRule" + }, + { + "id": "-123988", + "predicate": "privacyValueAllowContacts", + "params": [], + "type": "PrivacyRule" + }, + { + "id": "1698855810", + "predicate": "privacyValueAllowAll", + "params": [], + "type": "PrivacyRule" + }, + { + "id": "1297858060", + "predicate": "privacyValueAllowUsers", + "params": [ + { + "name": "users", + "type": "Vector" + } + ], + "type": "PrivacyRule" + }, + { + "id": "-125240806", + "predicate": "privacyValueDisallowContacts", + "params": [], + "type": "PrivacyRule" + }, + { + "id": "-1955338397", + "predicate": "privacyValueDisallowAll", + "params": [], + "type": "PrivacyRule" + }, + { + "id": "209668535", + "predicate": "privacyValueDisallowUsers", + "params": [ + { + "name": "users", + "type": "Vector" + } + ], + "type": "PrivacyRule" + }, + { + "id": "1430961007", + "predicate": "account.privacyRules", + "params": [ + { + "name": "rules", + "type": "Vector" + }, + { + "name": "users", + "type": "Vector" + } + ], + "type": "account.PrivacyRules" + }, + { + "id": "-1194283041", + "predicate": "accountDaysTTL", + "params": [ + { + "name": "days", + "type": "int" + } + ], + "type": "AccountDaysTTL" + }, + { + "id": "314130811", + "predicate": "updateUserPhone", + "params": [ + { + "name": "user_id", + "type": "int" + }, + { + "name": "phone", + "type": "string" + } + ], + "type": "Update" + }, + { + "id": "-1369215196", + "predicate": "disabledFeature", + "params": [ + { + "name": "feature", + "type": "string" + }, + { + "name": "description", + "type": "string" + } + ], + "type": "DisabledFeature" + }, + { + "id": "1815593308", + "predicate": "documentAttributeImageSize", + "params": [ + { + "name": "w", + "type": "int" + }, + { + "name": "h", + "type": "int" + } + ], + "type": "DocumentAttribute" + }, + { + "id": "297109817", + "predicate": "documentAttributeAnimated", + "params": [], + "type": "DocumentAttribute" + }, + { + "id": "1662637586", + "predicate": "documentAttributeSticker", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "mask", + "type": "flags.1?true" + }, + { + "name": "alt", + "type": "string" + }, + { + "name": "stickerset", + "type": "InputStickerSet" + }, + { + "name": "mask_coords", + "type": "flags.0?MaskCoords" + } + ], + "type": "DocumentAttribute" + }, + { + "id": "250621158", + "predicate": "documentAttributeVideo", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "round_message", + "type": "flags.0?true" + }, + { + "name": "duration", + "type": "int" + }, + { + "name": "w", + "type": "int" + }, + { + "name": "h", + "type": "int" + } + ], + "type": "DocumentAttribute" + }, + { + "id": "-1739392570", + "predicate": "documentAttributeAudio", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "voice", + "type": "flags.10?true" + }, + { + "name": "duration", + "type": "int" + }, + { + "name": "title", + "type": "flags.0?string" + }, + { + "name": "performer", + "type": "flags.1?string" + }, + { + "name": "waveform", + "type": "flags.2?bytes" + } + ], + "type": "DocumentAttribute" + }, + { + "id": "358154344", + "predicate": "documentAttributeFilename", + "params": [ + { + "name": "file_name", + "type": "string" + } + ], + "type": "DocumentAttribute" + }, + { + "id": "-244016606", + "predicate": "messages.stickersNotModified", + "params": [], + "type": "messages.Stickers" + }, + { + "id": "-1970352846", + "predicate": "messages.stickers", + "params": [ + { + "name": "hash", + "type": "string" + }, + { + "name": "stickers", + "type": "Vector" + } + ], + "type": "messages.Stickers" + }, + { + "id": "313694676", + "predicate": "stickerPack", + "params": [ + { + "name": "emoticon", + "type": "string" + }, + { + "name": "documents", + "type": "Vector" + } + ], + "type": "StickerPack" + }, + { + "id": "-395967805", + "predicate": "messages.allStickersNotModified", + "params": [], + "type": "messages.AllStickers" + }, + { + "id": "-302170017", + "predicate": "messages.allStickers", + "params": [ + { + "name": "hash", + "type": "int" + }, + { + "name": "sets", + "type": "Vector" + } + ], + "type": "messages.AllStickers" + }, + { + "id": "-1764049896", + "predicate": "account.noPassword", + "params": [ + { + "name": "new_salt", + "type": "bytes" + }, + { + "name": "email_unconfirmed_pattern", + "type": "string" + } + ], + "type": "account.Password" + }, + { + "id": "2081952796", + "predicate": "account.password", + "params": [ + { + "name": "current_salt", + "type": "bytes" + }, + { + "name": "new_salt", + "type": "bytes" + }, + { + "name": "hint", + "type": "string" + }, + { + "name": "has_recovery", + "type": "Bool" + }, + { + "name": "email_unconfirmed_pattern", + "type": "string" + } + ], + "type": "account.Password" + }, + { + "id": "-1721631396", + "predicate": "updateReadHistoryInbox", + "params": [ + { + "name": "peer", + "type": "Peer" + }, + { + "name": "max_id", + "type": "int" + }, + { + "name": "pts", + "type": "int" + }, + { + "name": "pts_count", + "type": "int" + } + ], + "type": "Update" + }, + { + "id": "791617983", + "predicate": "updateReadHistoryOutbox", + "params": [ + { + "name": "peer", + "type": "Peer" + }, + { + "name": "max_id", + "type": "int" + }, + { + "name": "pts", + "type": "int" + }, + { + "name": "pts_count", + "type": "int" + } + ], + "type": "Update" + }, + { + "id": "-2066640507", + "predicate": "messages.affectedMessages", + "params": [ + { + "name": "pts", + "type": "int" + }, + { + "name": "pts_count", + "type": "int" + } + ], + "type": "messages.AffectedMessages" + }, + { + "id": "1599050311", + "predicate": "contactLinkUnknown", + "params": [], + "type": "ContactLink" + }, + { + "id": "-17968211", + "predicate": "contactLinkNone", + "params": [], + "type": "ContactLink" + }, + { + "id": "646922073", + "predicate": "contactLinkHasPhone", + "params": [], + "type": "ContactLink" + }, + { + "id": "-721239344", + "predicate": "contactLinkContact", + "params": [], + "type": "ContactLink" + }, + { + "id": "2139689491", + "predicate": "updateWebPage", + "params": [ + { + "name": "webpage", + "type": "WebPage" + }, + { + "name": "pts", + "type": "int" + }, + { + "name": "pts_count", + "type": "int" + } + ], + "type": "Update" + }, + { + "id": "-350980120", + "predicate": "webPageEmpty", + "params": [ + { + "name": "id", + "type": "long" + } + ], + "type": "WebPage" + }, + { + "id": "-981018084", + "predicate": "webPagePending", + "params": [ + { + "name": "id", + "type": "long" + }, + { + "name": "date", + "type": "int" + } + ], + "type": "WebPage" + }, + { + "id": "1594340540", + "predicate": "webPage", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "id", + "type": "long" + }, + { + "name": "url", + "type": "string" + }, + { + "name": "display_url", + "type": "string" + }, + { + "name": "hash", + "type": "int" + }, + { + "name": "type", + "type": "flags.0?string" + }, + { + "name": "site_name", + "type": "flags.1?string" + }, + { + "name": "title", + "type": "flags.2?string" + }, + { + "name": "description", + "type": "flags.3?string" + }, + { + "name": "photo", + "type": "flags.4?Photo" + }, + { + "name": "embed_url", + "type": "flags.5?string" + }, + { + "name": "embed_type", + "type": "flags.5?string" + }, + { + "name": "embed_width", + "type": "flags.6?int" + }, + { + "name": "embed_height", + "type": "flags.6?int" + }, + { + "name": "duration", + "type": "flags.7?int" + }, + { + "name": "author", + "type": "flags.8?string" + }, + { + "name": "document", + "type": "flags.9?Document" + }, + { + "name": "cached_page", + "type": "flags.10?Page" + } + ], + "type": "WebPage" + }, + { + "id": "-1557277184", + "predicate": "messageMediaWebPage", + "params": [ + { + "name": "webpage", + "type": "WebPage" + } + ], + "type": "MessageMedia" + }, + { + "id": "2079516406", + "predicate": "authorization", + "params": [ + { + "name": "hash", + "type": "long" + }, + { + "name": "flags", + "type": "int" + }, + { + "name": "device_model", + "type": "string" + }, + { + "name": "platform", + "type": "string" + }, + { + "name": "system_version", + "type": "string" + }, + { + "name": "api_id", + "type": "int" + }, + { + "name": "app_name", + "type": "string" + }, + { + "name": "app_version", + "type": "string" + }, + { + "name": "date_created", + "type": "int" + }, + { + "name": "date_active", + "type": "int" + }, + { + "name": "ip", + "type": "string" + }, + { + "name": "country", + "type": "string" + }, + { + "name": "region", + "type": "string" + } + ], + "type": "Authorization" + }, + { + "id": "307276766", + "predicate": "account.authorizations", + "params": [ + { + "name": "authorizations", + "type": "Vector" + } + ], + "type": "account.Authorizations" + }, + { + "id": "-1212732749", + "predicate": "account.passwordSettings", + "params": [ + { + "name": "email", + "type": "string" + } + ], + "type": "account.PasswordSettings" + }, + { + "id": "-2037289493", + "predicate": "account.passwordInputSettings", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "new_salt", + "type": "flags.0?bytes" + }, + { + "name": "new_password_hash", + "type": "flags.0?bytes" + }, + { + "name": "hint", + "type": "flags.0?string" + }, + { + "name": "email", + "type": "flags.1?string" + } + ], + "type": "account.PasswordInputSettings" + }, + { + "id": "326715557", + "predicate": "auth.passwordRecovery", + "params": [ + { + "name": "email_pattern", + "type": "string" + } + ], + "type": "auth.PasswordRecovery" + }, + { + "id": "-1052959727", + "predicate": "inputMediaVenue", + "params": [ + { + "name": "geo_point", + "type": "InputGeoPoint" + }, + { + "name": "title", + "type": "string" + }, + { + "name": "address", + "type": "string" + }, + { + "name": "provider", + "type": "string" + }, + { + "name": "venue_id", + "type": "string" + }, + { + "name": "venue_type", + "type": "string" + } + ], + "type": "InputMedia" + }, + { + "id": "784356159", + "predicate": "messageMediaVenue", + "params": [ + { + "name": "geo", + "type": "GeoPoint" + }, + { + "name": "title", + "type": "string" + }, + { + "name": "address", + "type": "string" + }, + { + "name": "provider", + "type": "string" + }, + { + "name": "venue_id", + "type": "string" + }, + { + "name": "venue_type", + "type": "string" + } + ], + "type": "MessageMedia" + }, + { + "id": "-1551583367", + "predicate": "receivedNotifyMessage", + "params": [ + { + "name": "id", + "type": "int" + }, + { + "name": "flags", + "type": "int" + } + ], + "type": "ReceivedNotifyMessage" + }, + { + "id": "1776236393", + "predicate": "chatInviteEmpty", + "params": [], + "type": "ExportedChatInvite" + }, + { + "id": "-64092740", + "predicate": "chatInviteExported", + "params": [ + { + "name": "link", + "type": "string" + } + ], + "type": "ExportedChatInvite" + }, + { + "id": "1516793212", + "predicate": "chatInviteAlready", + "params": [ + { + "name": "chat", + "type": "Chat" + } + ], + "type": "ChatInvite" + }, + { + "id": "-613092008", + "predicate": "chatInvite", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "channel", + "type": "flags.0?true" + }, + { + "name": "broadcast", + "type": "flags.1?true" + }, + { + "name": "public", + "type": "flags.2?true" + }, + { + "name": "megagroup", + "type": "flags.3?true" + }, + { + "name": "title", + "type": "string" + }, + { + "name": "photo", + "type": "ChatPhoto" + }, + { + "name": "participants_count", + "type": "int" + }, + { + "name": "participants", + "type": "flags.4?Vector" + } + ], + "type": "ChatInvite" + }, + { + "id": "-123931160", + "predicate": "messageActionChatJoinedByLink", + "params": [ + { + "name": "inviter_id", + "type": "int" + } + ], + "type": "MessageAction" + }, + { + "id": "1757493555", + "predicate": "updateReadMessagesContents", + "params": [ + { + "name": "messages", + "type": "Vector" + }, + { + "name": "pts", + "type": "int" + }, + { + "name": "pts_count", + "type": "int" + } + ], + "type": "Update" + }, + { + "id": "-4838507", + "predicate": "inputStickerSetEmpty", + "params": [], + "type": "InputStickerSet" + }, + { + "id": "-1645763991", + "predicate": "inputStickerSetID", + "params": [ + { + "name": "id", + "type": "long" + }, + { + "name": "access_hash", + "type": "long" + } + ], + "type": "InputStickerSet" + }, + { + "id": "-2044933984", + "predicate": "inputStickerSetShortName", + "params": [ + { + "name": "short_name", + "type": "string" + } + ], + "type": "InputStickerSet" + }, + { + "id": "-852477119", + "predicate": "stickerSet", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "installed", + "type": "flags.0?true" + }, + { + "name": "archived", + "type": "flags.1?true" + }, + { + "name": "official", + "type": "flags.2?true" + }, + { + "name": "masks", + "type": "flags.3?true" + }, + { + "name": "id", + "type": "long" + }, + { + "name": "access_hash", + "type": "long" + }, + { + "name": "title", + "type": "string" + }, + { + "name": "short_name", + "type": "string" + }, + { + "name": "count", + "type": "int" + }, + { + "name": "hash", + "type": "int" + } + ], + "type": "StickerSet" + }, + { + "id": "-1240849242", + "predicate": "messages.stickerSet", + "params": [ + { + "name": "set", + "type": "StickerSet" + }, + { + "name": "packs", + "type": "Vector" + }, + { + "name": "documents", + "type": "Vector" + } + ], + "type": "messages.StickerSet" + }, + { + "id": "773059779", + "predicate": "user", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "self", + "type": "flags.10?true" + }, + { + "name": "contact", + "type": "flags.11?true" + }, + { + "name": "mutual_contact", + "type": "flags.12?true" + }, + { + "name": "deleted", + "type": "flags.13?true" + }, + { + "name": "bot", + "type": "flags.14?true" + }, + { + "name": "bot_chat_history", + "type": "flags.15?true" + }, + { + "name": "bot_nochats", + "type": "flags.16?true" + }, + { + "name": "verified", + "type": "flags.17?true" + }, + { + "name": "restricted", + "type": "flags.18?true" + }, + { + "name": "min", + "type": "flags.20?true" + }, + { + "name": "bot_inline_geo", + "type": "flags.21?true" + }, + { + "name": "id", + "type": "int" + }, + { + "name": "access_hash", + "type": "flags.0?long" + }, + { + "name": "first_name", + "type": "flags.1?string" + }, + { + "name": "last_name", + "type": "flags.2?string" + }, + { + "name": "username", + "type": "flags.3?string" + }, + { + "name": "phone", + "type": "flags.4?string" + }, + { + "name": "photo", + "type": "flags.5?UserProfilePhoto" + }, + { + "name": "status", + "type": "flags.6?UserStatus" + }, + { + "name": "bot_info_version", + "type": "flags.14?int" + }, + { + "name": "restriction_reason", + "type": "flags.18?string" + }, + { + "name": "bot_inline_placeholder", + "type": "flags.19?string" + }, + { + "name": "lang_code", + "type": "flags.22?string" + } + ], + "type": "User" + }, + { + "id": "-1032140601", + "predicate": "botCommand", + "params": [ + { + "name": "command", + "type": "string" + }, + { + "name": "description", + "type": "string" + } + ], + "type": "BotCommand" + }, + { + "id": "-1729618630", + "predicate": "botInfo", + "params": [ + { + "name": "user_id", + "type": "int" + }, + { + "name": "description", + "type": "string" + }, + { + "name": "commands", + "type": "Vector" + } + ], + "type": "BotInfo" + }, + { + "id": "-1560655744", + "predicate": "keyboardButton", + "params": [ + { + "name": "text", + "type": "string" + } + ], + "type": "KeyboardButton" + }, + { + "id": "2002815875", + "predicate": "keyboardButtonRow", + "params": [ + { + "name": "buttons", + "type": "Vector" + } + ], + "type": "KeyboardButtonRow" + }, + { + "id": "-1606526075", + "predicate": "replyKeyboardHide", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "selective", + "type": "flags.2?true" + } + ], + "type": "ReplyMarkup" + }, + { + "id": "-200242528", + "predicate": "replyKeyboardForceReply", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "single_use", + "type": "flags.1?true" + }, + { + "name": "selective", + "type": "flags.2?true" + } + ], + "type": "ReplyMarkup" + }, + { + "id": "889353612", + "predicate": "replyKeyboardMarkup", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "resize", + "type": "flags.0?true" + }, + { + "name": "single_use", + "type": "flags.1?true" + }, + { + "name": "selective", + "type": "flags.2?true" + }, + { + "name": "rows", + "type": "Vector" + } + ], + "type": "ReplyMarkup" + }, + { + "id": "2129714567", + "predicate": "inputMessagesFilterUrl", + "params": [], + "type": "MessagesFilter" + }, + { + "id": "2072935910", + "predicate": "inputPeerUser", + "params": [ + { + "name": "user_id", + "type": "int" + }, + { + "name": "access_hash", + "type": "long" + } + ], + "type": "InputPeer" + }, + { + "id": "-668391402", + "predicate": "inputUser", + "params": [ + { + "name": "user_id", + "type": "int" + }, + { + "name": "access_hash", + "type": "long" + } + ], + "type": "InputUser" + }, + { + "id": "-1148011883", + "predicate": "messageEntityUnknown", + "params": [ + { + "name": "offset", + "type": "int" + }, + { + "name": "length", + "type": "int" + } + ], + "type": "MessageEntity" + }, + { + "id": "-100378723", + "predicate": "messageEntityMention", + "params": [ + { + "name": "offset", + "type": "int" + }, + { + "name": "length", + "type": "int" + } + ], + "type": "MessageEntity" + }, + { + "id": "1868782349", + "predicate": "messageEntityHashtag", + "params": [ + { + "name": "offset", + "type": "int" + }, + { + "name": "length", + "type": "int" + } + ], + "type": "MessageEntity" + }, + { + "id": "1827637959", + "predicate": "messageEntityBotCommand", + "params": [ + { + "name": "offset", + "type": "int" + }, + { + "name": "length", + "type": "int" + } + ], + "type": "MessageEntity" + }, + { + "id": "1859134776", + "predicate": "messageEntityUrl", + "params": [ + { + "name": "offset", + "type": "int" + }, + { + "name": "length", + "type": "int" + } + ], + "type": "MessageEntity" + }, + { + "id": "1692693954", + "predicate": "messageEntityEmail", + "params": [ + { + "name": "offset", + "type": "int" + }, + { + "name": "length", + "type": "int" + } + ], + "type": "MessageEntity" + }, + { + "id": "-1117713463", + "predicate": "messageEntityBold", + "params": [ + { + "name": "offset", + "type": "int" + }, + { + "name": "length", + "type": "int" + } + ], + "type": "MessageEntity" + }, + { + "id": "-2106619040", + "predicate": "messageEntityItalic", + "params": [ + { + "name": "offset", + "type": "int" + }, + { + "name": "length", + "type": "int" + } + ], + "type": "MessageEntity" + }, + { + "id": "681706865", + "predicate": "messageEntityCode", + "params": [ + { + "name": "offset", + "type": "int" + }, + { + "name": "length", + "type": "int" + } + ], + "type": "MessageEntity" + }, + { + "id": "1938967520", + "predicate": "messageEntityPre", + "params": [ + { + "name": "offset", + "type": "int" + }, + { + "name": "length", + "type": "int" + }, + { + "name": "language", + "type": "string" + } + ], + "type": "MessageEntity" + }, + { + "id": "1990644519", + "predicate": "messageEntityTextUrl", + "params": [ + { + "name": "offset", + "type": "int" + }, + { + "name": "length", + "type": "int" + }, + { + "name": "url", + "type": "string" + } + ], + "type": "MessageEntity" + }, + { + "id": "301019932", + "predicate": "updateShortSentMessage", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "out", + "type": "flags.1?true" + }, + { + "name": "id", + "type": "int" + }, + { + "name": "pts", + "type": "int" + }, + { + "name": "pts_count", + "type": "int" + }, + { + "name": "date", + "type": "int" + }, + { + "name": "media", + "type": "flags.9?MessageMedia" + }, + { + "name": "entities", + "type": "flags.7?Vector" + } + ], + "type": "Updates" + }, + { + "id": "548253432", + "predicate": "inputPeerChannel", + "params": [ + { + "name": "channel_id", + "type": "int" + }, + { + "name": "access_hash", + "type": "long" + } + ], + "type": "InputPeer" + }, + { + "id": "-1109531342", + "predicate": "peerChannel", + "params": [ + { + "name": "channel_id", + "type": "int" + } + ], + "type": "Peer" + }, + { + "id": "1158377749", + "predicate": "channel", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "creator", + "type": "flags.0?true" + }, + { + "name": "left", + "type": "flags.2?true" + }, + { + "name": "editor", + "type": "flags.3?true" + }, + { + "name": "broadcast", + "type": "flags.5?true" + }, + { + "name": "verified", + "type": "flags.7?true" + }, + { + "name": "megagroup", + "type": "flags.8?true" + }, + { + "name": "restricted", + "type": "flags.9?true" + }, + { + "name": "democracy", + "type": "flags.10?true" + }, + { + "name": "signatures", + "type": "flags.11?true" + }, + { + "name": "min", + "type": "flags.12?true" + }, + { + "name": "id", + "type": "int" + }, + { + "name": "access_hash", + "type": "flags.13?long" + }, + { + "name": "title", + "type": "string" + }, + { + "name": "username", + "type": "flags.6?string" + }, + { + "name": "photo", + "type": "ChatPhoto" + }, + { + "name": "date", + "type": "int" + }, + { + "name": "version", + "type": "int" + }, + { + "name": "restriction_reason", + "type": "flags.9?string" + }, + { + "name": "admin_rights", + "type": "flags.14?ChannelAdminRights" + }, + { + "name": "banned_rights", + "type": "flags.15?ChannelBannedRights" + }, + { + "name": "participants_count", + "type": "flags.17?int" + } + ], + "type": "Chat" + }, + { + "id": "681420594", + "predicate": "channelForbidden", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "broadcast", + "type": "flags.5?true" + }, + { + "name": "megagroup", + "type": "flags.8?true" + }, + { + "name": "id", + "type": "int" + }, + { + "name": "access_hash", + "type": "long" + }, + { + "name": "title", + "type": "string" + }, + { + "name": "until_date", + "type": "flags.16?int" + } + ], + "type": "Chat" + }, + { + "id": "1991201921", + "predicate": "channelFull", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "can_view_participants", + "type": "flags.3?true" + }, + { + "name": "can_set_username", + "type": "flags.6?true" + }, + { + "name": "can_set_stickers", + "type": "flags.7?true" + }, + { + "name": "hidden_prehistory", + "type": "flags.10?true" + }, + { + "name": "id", + "type": "int" + }, + { + "name": "about", + "type": "string" + }, + { + "name": "participants_count", + "type": "flags.0?int" + }, + { + "name": "admins_count", + "type": "flags.1?int" + }, + { + "name": "kicked_count", + "type": "flags.2?int" + }, + { + "name": "banned_count", + "type": "flags.2?int" + }, + { + "name": "read_inbox_max_id", + "type": "int" + }, + { + "name": "read_outbox_max_id", + "type": "int" + }, + { + "name": "unread_count", + "type": "int" + }, + { + "name": "chat_photo", + "type": "Photo" + }, + { + "name": "notify_settings", + "type": "PeerNotifySettings" + }, + { + "name": "exported_invite", + "type": "ExportedChatInvite" + }, + { + "name": "bot_info", + "type": "Vector" + }, + { + "name": "migrated_from_chat_id", + "type": "flags.4?int" + }, + { + "name": "migrated_from_max_id", + "type": "flags.4?int" + }, + { + "name": "pinned_msg_id", + "type": "flags.5?int" + }, + { + "name": "stickerset", + "type": "flags.8?StickerSet" + }, + { + "name": "available_min_id", + "type": "flags.9?int" + } + ], + "type": "ChatFull" + }, + { + "id": "-1781355374", + "predicate": "messageActionChannelCreate", + "params": [ + { + "name": "title", + "type": "string" + } + ], + "type": "MessageAction" + }, + { + "id": "-1725551049", + "predicate": "messages.channelMessages", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "pts", + "type": "int" + }, + { + "name": "count", + "type": "int" + }, + { + "name": "messages", + "type": "Vector" + }, + { + "name": "chats", + "type": "Vector" + }, + { + "name": "users", + "type": "Vector" + } + ], + "type": "messages.Messages" + }, + { + "id": "-352032773", + "predicate": "updateChannelTooLong", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "channel_id", + "type": "int" + }, + { + "name": "pts", + "type": "flags.0?int" + } + ], + "type": "Update" + }, + { + "id": "-1227598250", + "predicate": "updateChannel", + "params": [ + { + "name": "channel_id", + "type": "int" + } + ], + "type": "Update" + }, + { + "id": "1656358105", + "predicate": "updateNewChannelMessage", + "params": [ + { + "name": "message", + "type": "Message" + }, + { + "name": "pts", + "type": "int" + }, + { + "name": "pts_count", + "type": "int" + } + ], + "type": "Update" + }, + { + "id": "1108669311", + "predicate": "updateReadChannelInbox", + "params": [ + { + "name": "channel_id", + "type": "int" + }, + { + "name": "max_id", + "type": "int" + } + ], + "type": "Update" + }, + { + "id": "-1015733815", + "predicate": "updateDeleteChannelMessages", + "params": [ + { + "name": "channel_id", + "type": "int" + }, + { + "name": "messages", + "type": "Vector" + }, + { + "name": "pts", + "type": "int" + }, + { + "name": "pts_count", + "type": "int" + } + ], + "type": "Update" + }, + { + "id": "-1734268085", + "predicate": "updateChannelMessageViews", + "params": [ + { + "name": "channel_id", + "type": "int" + }, + { + "name": "id", + "type": "int" + }, + { + "name": "views", + "type": "int" + } + ], + "type": "Update" + }, + { + "id": "-292807034", + "predicate": "inputChannelEmpty", + "params": [], + "type": "InputChannel" + }, + { + "id": "-1343524562", + "predicate": "inputChannel", + "params": [ + { + "name": "channel_id", + "type": "int" + }, + { + "name": "access_hash", + "type": "long" + } + ], + "type": "InputChannel" + }, + { + "id": "2131196633", + "predicate": "contacts.resolvedPeer", + "params": [ + { + "name": "peer", + "type": "Peer" + }, + { + "name": "chats", + "type": "Vector" + }, + { + "name": "users", + "type": "Vector" + } + ], + "type": "contacts.ResolvedPeer" + }, + { + "id": "182649427", + "predicate": "messageRange", + "params": [ + { + "name": "min_id", + "type": "int" + }, + { + "name": "max_id", + "type": "int" + } + ], + "type": "MessageRange" + }, + { + "id": "1041346555", + "predicate": "updates.channelDifferenceEmpty", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "final", + "type": "flags.0?true" + }, + { + "name": "pts", + "type": "int" + }, + { + "name": "timeout", + "type": "flags.1?int" + } + ], + "type": "updates.ChannelDifference" + }, + { + "id": "1788705589", + "predicate": "updates.channelDifferenceTooLong", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "final", + "type": "flags.0?true" + }, + { + "name": "pts", + "type": "int" + }, + { + "name": "timeout", + "type": "flags.1?int" + }, + { + "name": "top_message", + "type": "int" + }, + { + "name": "read_inbox_max_id", + "type": "int" + }, + { + "name": "read_outbox_max_id", + "type": "int" + }, + { + "name": "unread_count", + "type": "int" + }, + { + "name": "unread_mentions_count", + "type": "int" + }, + { + "name": "messages", + "type": "Vector" + }, + { + "name": "chats", + "type": "Vector" + }, + { + "name": "users", + "type": "Vector" + } + ], + "type": "updates.ChannelDifference" + }, + { + "id": "543450958", + "predicate": "updates.channelDifference", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "final", + "type": "flags.0?true" + }, + { + "name": "pts", + "type": "int" + }, + { + "name": "timeout", + "type": "flags.1?int" + }, + { + "name": "new_messages", + "type": "Vector" + }, + { + "name": "other_updates", + "type": "Vector" + }, + { + "name": "chats", + "type": "Vector" + }, + { + "name": "users", + "type": "Vector" + } + ], + "type": "updates.ChannelDifference" + }, + { + "id": "-1798033689", + "predicate": "channelMessagesFilterEmpty", + "params": [], + "type": "ChannelMessagesFilter" + }, + { + "id": "-847783593", + "predicate": "channelMessagesFilter", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "exclude_new_messages", + "type": "flags.1?true" + }, + { + "name": "ranges", + "type": "Vector" + } + ], + "type": "ChannelMessagesFilter" + }, + { + "id": "367766557", + "predicate": "channelParticipant", + "params": [ + { + "name": "user_id", + "type": "int" + }, + { + "name": "date", + "type": "int" + } + ], + "type": "ChannelParticipant" + }, + { + "id": "-1557620115", + "predicate": "channelParticipantSelf", + "params": [ + { + "name": "user_id", + "type": "int" + }, + { + "name": "inviter_id", + "type": "int" + }, + { + "name": "date", + "type": "int" + } + ], + "type": "ChannelParticipant" + }, + { + "id": "-471670279", + "predicate": "channelParticipantCreator", + "params": [ + { + "name": "user_id", + "type": "int" + } + ], + "type": "ChannelParticipant" + }, + { + "id": "-566281095", + "predicate": "channelParticipantsRecent", + "params": [], + "type": "ChannelParticipantsFilter" + }, + { + "id": "-1268741783", + "predicate": "channelParticipantsAdmins", + "params": [], + "type": "ChannelParticipantsFilter" + }, + { + "id": "-1548400251", + "predicate": "channelParticipantsKicked", + "params": [ + { + "name": "q", + "type": "string" + } + ], + "type": "ChannelParticipantsFilter" + }, + { + "id": "-177282392", + "predicate": "channels.channelParticipants", + "params": [ + { + "name": "count", + "type": "int" + }, + { + "name": "participants", + "type": "Vector" + }, + { + "name": "users", + "type": "Vector" + } + ], + "type": "channels.ChannelParticipants" + }, + { + "id": "-791039645", + "predicate": "channels.channelParticipant", + "params": [ + { + "name": "participant", + "type": "ChannelParticipant" + }, + { + "name": "users", + "type": "Vector" + } + ], + "type": "channels.ChannelParticipant" + }, + { + "id": "1072550713", + "predicate": "true", + "params": [], + "type": "True" + }, + { + "id": "-636267638", + "predicate": "chatParticipantCreator", + "params": [ + { + "name": "user_id", + "type": "int" + } + ], + "type": "ChatParticipant" + }, + { + "id": "-489233354", + "predicate": "chatParticipantAdmin", + "params": [ + { + "name": "user_id", + "type": "int" + }, + { + "name": "inviter_id", + "type": "int" + }, + { + "name": "date", + "type": "int" + } + ], + "type": "ChatParticipant" + }, + { + "id": "1855224129", + "predicate": "updateChatAdmins", + "params": [ + { + "name": "chat_id", + "type": "int" + }, + { + "name": "enabled", + "type": "Bool" + }, + { + "name": "version", + "type": "int" + } + ], + "type": "Update" + }, + { + "id": "-1232070311", + "predicate": "updateChatParticipantAdmin", + "params": [ + { + "name": "chat_id", + "type": "int" + }, + { + "name": "user_id", + "type": "int" + }, + { + "name": "is_admin", + "type": "Bool" + }, + { + "name": "version", + "type": "int" + } + ], + "type": "Update" + }, + { + "id": "1371385889", + "predicate": "messageActionChatMigrateTo", + "params": [ + { + "name": "channel_id", + "type": "int" + } + ], + "type": "MessageAction" + }, + { + "id": "-1336546578", + "predicate": "messageActionChannelMigrateFrom", + "params": [ + { + "name": "title", + "type": "string" + }, + { + "name": "chat_id", + "type": "int" + } + ], + "type": "MessageAction" + }, + { + "id": "-1328445861", + "predicate": "channelParticipantsBots", + "params": [], + "type": "ChannelParticipantsFilter" + }, + { + "id": "1490799288", + "predicate": "inputReportReasonSpam", + "params": [], + "type": "ReportReason" + }, + { + "id": "505595789", + "predicate": "inputReportReasonViolence", + "params": [], + "type": "ReportReason" + }, + { + "id": "777640226", + "predicate": "inputReportReasonPornography", + "params": [], + "type": "ReportReason" + }, + { + "id": "-512463606", + "predicate": "inputReportReasonOther", + "params": [ + { + "name": "text", + "type": "string" + } + ], + "type": "ReportReason" + }, + { + "id": "1753886890", + "predicate": "updateNewStickerSet", + "params": [ + { + "name": "stickerset", + "type": "messages.StickerSet" + } + ], + "type": "Update" + }, + { + "id": "196268545", + "predicate": "updateStickerSetsOrder", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "masks", + "type": "flags.0?true" + }, + { + "name": "order", + "type": "Vector" + } + ], + "type": "Update" + }, + { + "id": "1135492588", + "predicate": "updateStickerSets", + "params": [], + "type": "Update" + }, + { + "id": "-236044656", + "predicate": "help.termsOfService", + "params": [ + { + "name": "text", + "type": "string" + } + ], + "type": "help.TermsOfService" + }, + { + "id": "372165663", + "predicate": "foundGif", + "params": [ + { + "name": "url", + "type": "string" + }, + { + "name": "thumb_url", + "type": "string" + }, + { + "name": "content_url", + "type": "string" + }, + { + "name": "content_type", + "type": "string" + }, + { + "name": "w", + "type": "int" + }, + { + "name": "h", + "type": "int" + } + ], + "type": "FoundGif" + }, + { + "id": "1212395773", + "predicate": "inputMediaGifExternal", + "params": [ + { + "name": "url", + "type": "string" + }, + { + "name": "q", + "type": "string" + } + ], + "type": "InputMedia" + }, + { + "id": "1158290442", + "predicate": "messages.foundGifs", + "params": [ + { + "name": "next_offset", + "type": "int" + }, + { + "name": "results", + "type": "Vector" + } + ], + "type": "messages.FoundGifs" + }, + { + "id": "-3644025", + "predicate": "inputMessagesFilterGif", + "params": [], + "type": "MessagesFilter" + }, + { + "id": "-1821035490", + "predicate": "updateSavedGifs", + "params": [], + "type": "Update" + }, + { + "id": "1417832080", + "predicate": "updateBotInlineQuery", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "query_id", + "type": "long" + }, + { + "name": "user_id", + "type": "int" + }, + { + "name": "query", + "type": "string" + }, + { + "name": "geo", + "type": "flags.0?GeoPoint" + }, + { + "name": "offset", + "type": "string" + } + ], + "type": "Update" + }, + { + "id": "-1670052855", + "predicate": "foundGifCached", + "params": [ + { + "name": "url", + "type": "string" + }, + { + "name": "photo", + "type": "Photo" + }, + { + "name": "document", + "type": "Document" + } + ], + "type": "FoundGif" + }, + { + "id": "-402498398", + "predicate": "messages.savedGifsNotModified", + "params": [], + "type": "messages.SavedGifs" + }, + { + "id": "772213157", + "predicate": "messages.savedGifs", + "params": [ + { + "name": "hash", + "type": "int" + }, + { + "name": "gifs", + "type": "Vector" + } + ], + "type": "messages.SavedGifs" + }, + { + "id": "691006739", + "predicate": "inputBotInlineMessageMediaAuto", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "caption", + "type": "string" + }, + { + "name": "reply_markup", + "type": "flags.2?ReplyMarkup" + } + ], + "type": "InputBotInlineMessage" + }, + { + "id": "1036876423", + "predicate": "inputBotInlineMessageText", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "no_webpage", + "type": "flags.0?true" + }, + { + "name": "message", + "type": "string" + }, + { + "name": "entities", + "type": "flags.1?Vector" + }, + { + "name": "reply_markup", + "type": "flags.2?ReplyMarkup" + } + ], + "type": "InputBotInlineMessage" + }, + { + "id": "750510426", + "predicate": "inputBotInlineResult", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "id", + "type": "string" + }, + { + "name": "type", + "type": "string" + }, + { + "name": "title", + "type": "flags.1?string" + }, + { + "name": "description", + "type": "flags.2?string" + }, + { + "name": "url", + "type": "flags.3?string" + }, + { + "name": "thumb_url", + "type": "flags.4?string" + }, + { + "name": "content_url", + "type": "flags.5?string" + }, + { + "name": "content_type", + "type": "flags.5?string" + }, + { + "name": "w", + "type": "flags.6?int" + }, + { + "name": "h", + "type": "flags.6?int" + }, + { + "name": "duration", + "type": "flags.7?int" + }, + { + "name": "send_message", + "type": "InputBotInlineMessage" + } + ], + "type": "InputBotInlineResult" + }, + { + "id": "175419739", + "predicate": "botInlineMessageMediaAuto", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "caption", + "type": "string" + }, + { + "name": "reply_markup", + "type": "flags.2?ReplyMarkup" + } + ], + "type": "BotInlineMessage" + }, + { + "id": "-1937807902", + "predicate": "botInlineMessageText", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "no_webpage", + "type": "flags.0?true" + }, + { + "name": "message", + "type": "string" + }, + { + "name": "entities", + "type": "flags.1?Vector" + }, + { + "name": "reply_markup", + "type": "flags.2?ReplyMarkup" + } + ], + "type": "BotInlineMessage" + }, + { + "id": "-1679053127", + "predicate": "botInlineResult", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "id", + "type": "string" + }, + { + "name": "type", + "type": "string" + }, + { + "name": "title", + "type": "flags.1?string" + }, + { + "name": "description", + "type": "flags.2?string" + }, + { + "name": "url", + "type": "flags.3?string" + }, + { + "name": "thumb_url", + "type": "flags.4?string" + }, + { + "name": "content_url", + "type": "flags.5?string" + }, + { + "name": "content_type", + "type": "flags.5?string" + }, + { + "name": "w", + "type": "flags.6?int" + }, + { + "name": "h", + "type": "flags.6?int" + }, + { + "name": "duration", + "type": "flags.7?int" + }, + { + "name": "send_message", + "type": "BotInlineMessage" + } + ], + "type": "BotInlineResult" + }, + { + "id": "-1803769784", + "predicate": "messages.botResults", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "gallery", + "type": "flags.0?true" + }, + { + "name": "query_id", + "type": "long" + }, + { + "name": "next_offset", + "type": "flags.1?string" + }, + { + "name": "switch_pm", + "type": "flags.2?InlineBotSwitchPM" + }, + { + "name": "results", + "type": "Vector" + }, + { + "name": "cache_time", + "type": "int" + }, + { + "name": "users", + "type": "Vector" + } + ], + "type": "messages.BotResults" + }, + { + "id": "1358283666", + "predicate": "inputMessagesFilterVoice", + "params": [], + "type": "MessagesFilter" + }, + { + "id": "928101534", + "predicate": "inputMessagesFilterMusic", + "params": [], + "type": "MessagesFilter" + }, + { + "id": "239663460", + "predicate": "updateBotInlineSend", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "user_id", + "type": "int" + }, + { + "name": "query", + "type": "string" + }, + { + "name": "geo", + "type": "flags.0?GeoPoint" + }, + { + "name": "id", + "type": "string" + }, + { + "name": "msg_id", + "type": "flags.1?InputBotInlineMessageID" + } + ], + "type": "Update" + }, + { + "id": "-1107622874", + "predicate": "inputPrivacyKeyChatInvite", + "params": [], + "type": "InputPrivacyKey" + }, + { + "id": "1343122938", + "predicate": "privacyKeyChatInvite", + "params": [], + "type": "PrivacyKey" + }, + { + "id": "457133559", + "predicate": "updateEditChannelMessage", + "params": [ + { + "name": "message", + "type": "Message" + }, + { + "name": "pts", + "type": "int" + }, + { + "name": "pts_count", + "type": "int" + } + ], + "type": "Update" + }, + { + "id": "524838915", + "predicate": "exportedMessageLink", + "params": [ + { + "name": "link", + "type": "string" + } + ], + "type": "ExportedMessageLink" + }, + { + "id": "1436466797", + "predicate": "messageFwdHeader", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "from_id", + "type": "flags.0?int" + }, + { + "name": "date", + "type": "int" + }, + { + "name": "channel_id", + "type": "flags.1?int" + }, + { + "name": "channel_post", + "type": "flags.2?int" + }, + { + "name": "post_author", + "type": "flags.3?string" + }, + { + "name": "saved_from_peer", + "type": "flags.4?Peer" + }, + { + "name": "saved_from_msg_id", + "type": "flags.4?int" + } + ], + "type": "MessageFwdHeader" + }, + { + "id": "-1799538451", + "predicate": "messageActionPinMessage", + "params": [], + "type": "MessageAction" + }, + { + "id": "-2122045747", + "predicate": "peerSettings", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "report_spam", + "type": "flags.0?true" + } + ], + "type": "PeerSettings" + }, + { + "id": "-1738988427", + "predicate": "updateChannelPinnedMessage", + "params": [ + { + "name": "channel_id", + "type": "int" + }, + { + "name": "id", + "type": "int" + } + ], + "type": "Update" + }, + { + "id": "629866245", + "predicate": "keyboardButtonUrl", + "params": [ + { + "name": "text", + "type": "string" + }, + { + "name": "url", + "type": "string" + } + ], + "type": "KeyboardButton" + }, + { + "id": "1748655686", + "predicate": "keyboardButtonCallback", + "params": [ + { + "name": "text", + "type": "string" + }, + { + "name": "data", + "type": "bytes" + } + ], + "type": "KeyboardButton" + }, + { + "id": "-1318425559", + "predicate": "keyboardButtonRequestPhone", + "params": [ + { + "name": "text", + "type": "string" + } + ], + "type": "KeyboardButton" + }, + { + "id": "-59151553", + "predicate": "keyboardButtonRequestGeoLocation", + "params": [ + { + "name": "text", + "type": "string" + } + ], + "type": "KeyboardButton" + }, + { + "id": "1923290508", + "predicate": "auth.codeTypeSms", + "params": [], + "type": "auth.CodeType" + }, + { + "id": "1948046307", + "predicate": "auth.codeTypeCall", + "params": [], + "type": "auth.CodeType" + }, + { + "id": "577556219", + "predicate": "auth.codeTypeFlashCall", + "params": [], + "type": "auth.CodeType" + }, + { + "id": "1035688326", + "predicate": "auth.sentCodeTypeApp", + "params": [ + { + "name": "length", + "type": "int" + } + ], + "type": "auth.SentCodeType" + }, + { + "id": "-1073693790", + "predicate": "auth.sentCodeTypeSms", + "params": [ + { + "name": "length", + "type": "int" + } + ], + "type": "auth.SentCodeType" + }, + { + "id": "1398007207", + "predicate": "auth.sentCodeTypeCall", + "params": [ + { + "name": "length", + "type": "int" + } + ], + "type": "auth.SentCodeType" + }, + { + "id": "-1425815847", + "predicate": "auth.sentCodeTypeFlashCall", + "params": [ + { + "name": "pattern", + "type": "string" + } + ], + "type": "auth.SentCodeType" + }, + { + "id": "90744648", + "predicate": "keyboardButtonSwitchInline", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "same_peer", + "type": "flags.0?true" + }, + { + "name": "text", + "type": "string" + }, + { + "name": "query", + "type": "string" + } + ], + "type": "KeyboardButton" + }, + { + "id": "1218642516", + "predicate": "replyInlineMarkup", + "params": [ + { + "name": "rows", + "type": "Vector" + } + ], + "type": "ReplyMarkup" + }, + { + "id": "911761060", + "predicate": "messages.botCallbackAnswer", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "alert", + "type": "flags.1?true" + }, + { + "name": "has_url", + "type": "flags.3?true" + }, + { + "name": "native_ui", + "type": "flags.4?true" + }, + { + "name": "message", + "type": "flags.0?string" + }, + { + "name": "url", + "type": "flags.2?string" + }, + { + "name": "cache_time", + "type": "int" + } + ], + "type": "messages.BotCallbackAnswer" + }, + { + "id": "-415938591", + "predicate": "updateBotCallbackQuery", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "query_id", + "type": "long" + }, + { + "name": "user_id", + "type": "int" + }, + { + "name": "peer", + "type": "Peer" + }, + { + "name": "msg_id", + "type": "int" + }, + { + "name": "chat_instance", + "type": "long" + }, + { + "name": "data", + "type": "flags.0?bytes" + }, + { + "name": "game_short_name", + "type": "flags.1?string" + } + ], + "type": "Update" + }, + { + "id": "649453030", + "predicate": "messages.messageEditData", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "caption", + "type": "flags.0?true" + } + ], + "type": "messages.MessageEditData" + }, + { + "id": "-469536605", + "predicate": "updateEditMessage", + "params": [ + { + "name": "message", + "type": "Message" + }, + { + "name": "pts", + "type": "int" + }, + { + "name": "pts_count", + "type": "int" + } + ], + "type": "Update" + }, + { + "id": "-1045340827", + "predicate": "inputBotInlineMessageMediaGeo", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "geo_point", + "type": "InputGeoPoint" + }, + { + "name": "period", + "type": "int" + }, + { + "name": "reply_markup", + "type": "flags.2?ReplyMarkup" + } + ], + "type": "InputBotInlineMessage" + }, + { + "id": "-1431327288", + "predicate": "inputBotInlineMessageMediaVenue", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "geo_point", + "type": "InputGeoPoint" + }, + { + "name": "title", + "type": "string" + }, + { + "name": "address", + "type": "string" + }, + { + "name": "provider", + "type": "string" + }, + { + "name": "venue_id", + "type": "string" + }, + { + "name": "reply_markup", + "type": "flags.2?ReplyMarkup" + } + ], + "type": "InputBotInlineMessage" + }, + { + "id": "766443943", + "predicate": "inputBotInlineMessageMediaContact", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "phone_number", + "type": "string" + }, + { + "name": "first_name", + "type": "string" + }, + { + "name": "last_name", + "type": "string" + }, + { + "name": "reply_markup", + "type": "flags.2?ReplyMarkup" + } + ], + "type": "InputBotInlineMessage" + }, + { + "id": "-1222451611", + "predicate": "botInlineMessageMediaGeo", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "geo", + "type": "GeoPoint" + }, + { + "name": "period", + "type": "int" + }, + { + "name": "reply_markup", + "type": "flags.2?ReplyMarkup" + } + ], + "type": "BotInlineMessage" + }, + { + "id": "1130767150", + "predicate": "botInlineMessageMediaVenue", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "geo", + "type": "GeoPoint" + }, + { + "name": "title", + "type": "string" + }, + { + "name": "address", + "type": "string" + }, + { + "name": "provider", + "type": "string" + }, + { + "name": "venue_id", + "type": "string" + }, + { + "name": "reply_markup", + "type": "flags.2?ReplyMarkup" + } + ], + "type": "BotInlineMessage" + }, + { + "id": "904770772", + "predicate": "botInlineMessageMediaContact", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "phone_number", + "type": "string" + }, + { + "name": "first_name", + "type": "string" + }, + { + "name": "last_name", + "type": "string" + }, + { + "name": "reply_markup", + "type": "flags.2?ReplyMarkup" + } + ], + "type": "BotInlineMessage" + }, + { + "id": "-1462213465", + "predicate": "inputBotInlineResultPhoto", + "params": [ + { + "name": "id", + "type": "string" + }, + { + "name": "type", + "type": "string" + }, + { + "name": "photo", + "type": "InputPhoto" + }, + { + "name": "send_message", + "type": "InputBotInlineMessage" + } + ], + "type": "InputBotInlineResult" + }, + { + "id": "-459324", + "predicate": "inputBotInlineResultDocument", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "id", + "type": "string" + }, + { + "name": "type", + "type": "string" + }, + { + "name": "title", + "type": "flags.1?string" + }, + { + "name": "description", + "type": "flags.2?string" + }, + { + "name": "document", + "type": "InputDocument" + }, + { + "name": "send_message", + "type": "InputBotInlineMessage" + } + ], + "type": "InputBotInlineResult" + }, + { + "id": "400266251", + "predicate": "botInlineMediaResult", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "id", + "type": "string" + }, + { + "name": "type", + "type": "string" + }, + { + "name": "photo", + "type": "flags.0?Photo" + }, + { + "name": "document", + "type": "flags.1?Document" + }, + { + "name": "title", + "type": "flags.2?string" + }, + { + "name": "description", + "type": "flags.3?string" + }, + { + "name": "send_message", + "type": "BotInlineMessage" + } + ], + "type": "BotInlineResult" + }, + { + "id": "-1995686519", + "predicate": "inputBotInlineMessageID", + "params": [ + { + "name": "dc_id", + "type": "int" + }, + { + "name": "id", + "type": "long" + }, + { + "name": "access_hash", + "type": "long" + } + ], + "type": "InputBotInlineMessageID" + }, + { + "id": "-103646630", + "predicate": "updateInlineBotCallbackQuery", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "query_id", + "type": "long" + }, + { + "name": "user_id", + "type": "int" + }, + { + "name": "msg_id", + "type": "InputBotInlineMessageID" + }, + { + "name": "chat_instance", + "type": "long" + }, + { + "name": "data", + "type": "flags.0?bytes" + }, + { + "name": "game_short_name", + "type": "flags.1?string" + } + ], + "type": "Update" + }, + { + "id": "1008755359", + "predicate": "inlineBotSwitchPM", + "params": [ + { + "name": "text", + "type": "string" + }, + { + "name": "start_param", + "type": "string" + } + ], + "type": "InlineBotSwitchPM" + }, + { + "id": "892193368", + "predicate": "messageEntityMentionName", + "params": [ + { + "name": "offset", + "type": "int" + }, + { + "name": "length", + "type": "int" + }, + { + "name": "user_id", + "type": "int" + } + ], + "type": "MessageEntity" + }, + { + "id": "546203849", + "predicate": "inputMessageEntityMentionName", + "params": [ + { + "name": "offset", + "type": "int" + }, + { + "name": "length", + "type": "int" + }, + { + "name": "user_id", + "type": "InputUser" + } + ], + "type": "MessageEntity" + }, + { + "id": "863093588", + "predicate": "messages.peerDialogs", + "params": [ + { + "name": "dialogs", + "type": "Vector" + }, + { + "name": "messages", + "type": "Vector" + }, + { + "name": "chats", + "type": "Vector" + }, + { + "name": "users", + "type": "Vector" + }, + { + "name": "state", + "type": "updates.State" + } + ], + "type": "messages.PeerDialogs" + }, + { + "id": "-305282981", + "predicate": "topPeer", + "params": [ + { + "name": "peer", + "type": "Peer" + }, + { + "name": "rating", + "type": "double" + } + ], + "type": "TopPeer" + }, + { + "id": "-1419371685", + "predicate": "topPeerCategoryBotsPM", + "params": [], + "type": "TopPeerCategory" + }, + { + "id": "344356834", + "predicate": "topPeerCategoryBotsInline", + "params": [], + "type": "TopPeerCategory" + }, + { + "id": "104314861", + "predicate": "topPeerCategoryCorrespondents", + "params": [], + "type": "TopPeerCategory" + }, + { + "id": "-1122524854", + "predicate": "topPeerCategoryGroups", + "params": [], + "type": "TopPeerCategory" + }, + { + "id": "371037736", + "predicate": "topPeerCategoryChannels", + "params": [], + "type": "TopPeerCategory" + }, + { + "id": "-75283823", + "predicate": "topPeerCategoryPeers", + "params": [ + { + "name": "category", + "type": "TopPeerCategory" + }, + { + "name": "count", + "type": "int" + }, + { + "name": "peers", + "type": "Vector" + } + ], + "type": "TopPeerCategoryPeers" + }, + { + "id": "-567906571", + "predicate": "contacts.topPeersNotModified", + "params": [], + "type": "contacts.TopPeers" + }, + { + "id": "1891070632", + "predicate": "contacts.topPeers", + "params": [ + { + "name": "categories", + "type": "Vector" + }, + { + "name": "chats", + "type": "Vector" + }, + { + "name": "users", + "type": "Vector" + } + ], + "type": "contacts.TopPeers" + }, + { + "id": "975236280", + "predicate": "inputMessagesFilterChatPhotos", + "params": [], + "type": "MessagesFilter" + }, + { + "id": "634833351", + "predicate": "updateReadChannelOutbox", + "params": [ + { + "name": "channel_id", + "type": "int" + }, + { + "name": "max_id", + "type": "int" + } + ], + "type": "Update" + }, + { + "id": "-299124375", + "predicate": "updateDraftMessage", + "params": [ + { + "name": "peer", + "type": "Peer" + }, + { + "name": "draft", + "type": "DraftMessage" + } + ], + "type": "Update" + }, + { + "id": "-1169445179", + "predicate": "draftMessageEmpty", + "params": [], + "type": "DraftMessage" + }, + { + "id": "-40996577", + "predicate": "draftMessage", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "no_webpage", + "type": "flags.1?true" + }, + { + "name": "reply_to_msg_id", + "type": "flags.0?int" + }, + { + "name": "message", + "type": "string" + }, + { + "name": "entities", + "type": "flags.3?Vector" + }, + { + "name": "date", + "type": "int" + } + ], + "type": "DraftMessage" + }, + { + "id": "-1615153660", + "predicate": "messageActionHistoryClear", + "params": [], + "type": "MessageAction" + }, + { + "id": "1461528386", + "predicate": "updateReadFeaturedStickers", + "params": [], + "type": "Update" + }, + { + "id": "-1706939360", + "predicate": "updateRecentStickers", + "params": [], + "type": "Update" + }, + { + "id": "82699215", + "predicate": "messages.featuredStickersNotModified", + "params": [], + "type": "messages.FeaturedStickers" + }, + { + "id": "-123893531", + "predicate": "messages.featuredStickers", + "params": [ + { + "name": "hash", + "type": "int" + }, + { + "name": "sets", + "type": "Vector" + }, + { + "name": "unread", + "type": "Vector" + } + ], + "type": "messages.FeaturedStickers" + }, + { + "id": "186120336", + "predicate": "messages.recentStickersNotModified", + "params": [], + "type": "messages.RecentStickers" + }, + { + "id": "1558317424", + "predicate": "messages.recentStickers", + "params": [ + { + "name": "hash", + "type": "int" + }, + { + "name": "stickers", + "type": "Vector" + } + ], + "type": "messages.RecentStickers" + }, + { + "id": "1338747336", + "predicate": "messages.archivedStickers", + "params": [ + { + "name": "count", + "type": "int" + }, + { + "name": "sets", + "type": "Vector" + } + ], + "type": "messages.ArchivedStickers" + }, + { + "id": "946083368", + "predicate": "messages.stickerSetInstallResultSuccess", + "params": [], + "type": "messages.StickerSetInstallResult" + }, + { + "id": "904138920", + "predicate": "messages.stickerSetInstallResultArchive", + "params": [ + { + "name": "sets", + "type": "Vector" + } + ], + "type": "messages.StickerSetInstallResult" + }, + { + "id": "1678812626", + "predicate": "stickerSetCovered", + "params": [ + { + "name": "set", + "type": "StickerSet" + }, + { + "name": "cover", + "type": "Document" + } + ], + "type": "StickerSetCovered" + }, + { + "id": "153267905", + "predicate": "inputMediaPhotoExternal", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "url", + "type": "string" + }, + { + "name": "caption", + "type": "string" + }, + { + "name": "ttl_seconds", + "type": "flags.0?int" + } + ], + "type": "InputMedia" + }, + { + "id": "-1225309387", + "predicate": "inputMediaDocumentExternal", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "url", + "type": "string" + }, + { + "name": "caption", + "type": "string" + }, + { + "name": "ttl_seconds", + "type": "flags.0?int" + } + ], + "type": "InputMedia" + }, + { + "id": "-1574314746", + "predicate": "updateConfig", + "params": [], + "type": "Update" + }, + { + "id": "861169551", + "predicate": "updatePtsChanged", + "params": [], + "type": "Update" + }, + { + "id": "-1834538890", + "predicate": "messageActionGameScore", + "params": [ + { + "name": "game_id", + "type": "long" + }, + { + "name": "score", + "type": "int" + } + ], + "type": "MessageAction" + }, + { + "id": "-1744710921", + "predicate": "documentAttributeHasStickers", + "params": [], + "type": "DocumentAttribute" + }, + { + "id": "1358175439", + "predicate": "keyboardButtonGame", + "params": [ + { + "name": "text", + "type": "string" + } + ], + "type": "KeyboardButton" + }, + { + "id": "872932635", + "predicate": "stickerSetMultiCovered", + "params": [ + { + "name": "set", + "type": "StickerSet" + }, + { + "name": "covers", + "type": "Vector" + } + ], + "type": "StickerSetCovered" + }, + { + "id": "-1361650766", + "predicate": "maskCoords", + "params": [ + { + "name": "n", + "type": "int" + }, + { + "name": "x", + "type": "double" + }, + { + "name": "y", + "type": "double" + }, + { + "name": "zoom", + "type": "double" + } + ], + "type": "MaskCoords" + }, + { + "id": "1251549527", + "predicate": "inputStickeredMediaPhoto", + "params": [ + { + "name": "id", + "type": "InputPhoto" + } + ], + "type": "InputStickeredMedia" + }, + { + "id": "70813275", + "predicate": "inputStickeredMediaDocument", + "params": [ + { + "name": "id", + "type": "InputDocument" + } + ], + "type": "InputStickeredMedia" + }, + { + "id": "-750828557", + "predicate": "inputMediaGame", + "params": [ + { + "name": "id", + "type": "InputGame" + } + ], + "type": "InputMedia" + }, + { + "id": "-38694904", + "predicate": "messageMediaGame", + "params": [ + { + "name": "game", + "type": "Game" + } + ], + "type": "MessageMedia" + }, + { + "id": "1262639204", + "predicate": "inputBotInlineMessageGame", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "reply_markup", + "type": "flags.2?ReplyMarkup" + } + ], + "type": "InputBotInlineMessage" + }, + { + "id": "1336154098", + "predicate": "inputBotInlineResultGame", + "params": [ + { + "name": "id", + "type": "string" + }, + { + "name": "short_name", + "type": "string" + }, + { + "name": "send_message", + "type": "InputBotInlineMessage" + } + ], + "type": "InputBotInlineResult" + }, + { + "id": "-1107729093", + "predicate": "game", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "id", + "type": "long" + }, + { + "name": "access_hash", + "type": "long" + }, + { + "name": "short_name", + "type": "string" + }, + { + "name": "title", + "type": "string" + }, + { + "name": "description", + "type": "string" + }, + { + "name": "photo", + "type": "Photo" + }, + { + "name": "document", + "type": "flags.0?Document" + } + ], + "type": "Game" + }, + { + "id": "53231223", + "predicate": "inputGameID", + "params": [ + { + "name": "id", + "type": "long" + }, + { + "name": "access_hash", + "type": "long" + } + ], + "type": "InputGame" + }, + { + "id": "-1020139510", + "predicate": "inputGameShortName", + "params": [ + { + "name": "bot_id", + "type": "InputUser" + }, + { + "name": "short_name", + "type": "string" + } + ], + "type": "InputGame" + }, + { + "id": "1493171408", + "predicate": "highScore", + "params": [ + { + "name": "pos", + "type": "int" + }, + { + "name": "user_id", + "type": "int" + }, + { + "name": "score", + "type": "int" + } + ], + "type": "HighScore" + }, + { + "id": "-1707344487", + "predicate": "messages.highScores", + "params": [ + { + "name": "scores", + "type": "Vector" + }, + { + "name": "users", + "type": "Vector" + } + ], + "type": "messages.HighScores" + }, + { + "id": "-1663561404", + "predicate": "messages.chatsSlice", + "params": [ + { + "name": "count", + "type": "int" + }, + { + "name": "chats", + "type": "Vector" + } + ], + "type": "messages.Chats" + }, + { + "id": "1081547008", + "predicate": "updateChannelWebPage", + "params": [ + { + "name": "channel_id", + "type": "int" + }, + { + "name": "webpage", + "type": "WebPage" + }, + { + "name": "pts", + "type": "int" + }, + { + "name": "pts_count", + "type": "int" + } + ], + "type": "Update" + }, + { + "id": "1258196845", + "predicate": "updates.differenceTooLong", + "params": [ + { + "name": "pts", + "type": "int" + } + ], + "type": "updates.Difference" + }, + { + "id": "-580219064", + "predicate": "sendMessageGamePlayAction", + "params": [], + "type": "SendMessageAction" + }, + { + "id": "-2054908813", + "predicate": "webPageNotModified", + "params": [], + "type": "WebPage" + }, + { + "id": "-599948721", + "predicate": "textEmpty", + "params": [], + "type": "RichText" + }, + { + "id": "1950782688", + "predicate": "textPlain", + "params": [ + { + "name": "text", + "type": "string" + } + ], + "type": "RichText" + }, + { + "id": "1730456516", + "predicate": "textBold", + "params": [ + { + "name": "text", + "type": "RichText" + } + ], + "type": "RichText" + }, + { + "id": "-653089380", + "predicate": "textItalic", + "params": [ + { + "name": "text", + "type": "RichText" + } + ], + "type": "RichText" + }, + { + "id": "-1054465340", + "predicate": "textUnderline", + "params": [ + { + "name": "text", + "type": "RichText" + } + ], + "type": "RichText" + }, + { + "id": "-1678197867", + "predicate": "textStrike", + "params": [ + { + "name": "text", + "type": "RichText" + } + ], + "type": "RichText" + }, + { + "id": "1816074681", + "predicate": "textFixed", + "params": [ + { + "name": "text", + "type": "RichText" + } + ], + "type": "RichText" + }, + { + "id": "1009288385", + "predicate": "textUrl", + "params": [ + { + "name": "text", + "type": "RichText" + }, + { + "name": "url", + "type": "string" + }, + { + "name": "webpage_id", + "type": "long" + } + ], + "type": "RichText" + }, + { + "id": "-564523562", + "predicate": "textEmail", + "params": [ + { + "name": "text", + "type": "RichText" + }, + { + "name": "email", + "type": "string" + } + ], + "type": "RichText" + }, + { + "id": "2120376535", + "predicate": "textConcat", + "params": [ + { + "name": "texts", + "type": "Vector" + } + ], + "type": "RichText" + }, + { + "id": "1890305021", + "predicate": "pageBlockTitle", + "params": [ + { + "name": "text", + "type": "RichText" + } + ], + "type": "PageBlock" + }, + { + "id": "-1879401953", + "predicate": "pageBlockSubtitle", + "params": [ + { + "name": "text", + "type": "RichText" + } + ], + "type": "PageBlock" + }, + { + "id": "-1162877472", + "predicate": "pageBlockAuthorDate", + "params": [ + { + "name": "author", + "type": "RichText" + }, + { + "name": "published_date", + "type": "int" + } + ], + "type": "PageBlock" + }, + { + "id": "-1076861716", + "predicate": "pageBlockHeader", + "params": [ + { + "name": "text", + "type": "RichText" + } + ], + "type": "PageBlock" + }, + { + "id": "-248793375", + "predicate": "pageBlockSubheader", + "params": [ + { + "name": "text", + "type": "RichText" + } + ], + "type": "PageBlock" + }, + { + "id": "1182402406", + "predicate": "pageBlockParagraph", + "params": [ + { + "name": "text", + "type": "RichText" + } + ], + "type": "PageBlock" + }, + { + "id": "-1066346178", + "predicate": "pageBlockPreformatted", + "params": [ + { + "name": "text", + "type": "RichText" + }, + { + "name": "language", + "type": "string" + } + ], + "type": "PageBlock" + }, + { + "id": "1216809369", + "predicate": "pageBlockFooter", + "params": [ + { + "name": "text", + "type": "RichText" + } + ], + "type": "PageBlock" + }, + { + "id": "-618614392", + "predicate": "pageBlockDivider", + "params": [], + "type": "PageBlock" + }, + { + "id": "978896884", + "predicate": "pageBlockList", + "params": [ + { + "name": "ordered", + "type": "Bool" + }, + { + "name": "items", + "type": "Vector" + } + ], + "type": "PageBlock" + }, + { + "id": "641563686", + "predicate": "pageBlockBlockquote", + "params": [ + { + "name": "text", + "type": "RichText" + }, + { + "name": "caption", + "type": "RichText" + } + ], + "type": "PageBlock" + }, + { + "id": "1329878739", + "predicate": "pageBlockPullquote", + "params": [ + { + "name": "text", + "type": "RichText" + }, + { + "name": "caption", + "type": "RichText" + } + ], + "type": "PageBlock" + }, + { + "id": "-372860542", + "predicate": "pageBlockPhoto", + "params": [ + { + "name": "photo_id", + "type": "long" + }, + { + "name": "caption", + "type": "RichText" + } + ], + "type": "PageBlock" + }, + { + "id": "-640214938", + "predicate": "pageBlockVideo", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "autoplay", + "type": "flags.0?true" + }, + { + "name": "loop", + "type": "flags.1?true" + }, + { + "name": "video_id", + "type": "long" + }, + { + "name": "caption", + "type": "RichText" + } + ], + "type": "PageBlock" + }, + { + "id": "972174080", + "predicate": "pageBlockCover", + "params": [ + { + "name": "cover", + "type": "PageBlock" + } + ], + "type": "PageBlock" + }, + { + "id": "-840826671", + "predicate": "pageBlockEmbed", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "full_width", + "type": "flags.0?true" + }, + { + "name": "allow_scrolling", + "type": "flags.3?true" + }, + { + "name": "url", + "type": "flags.1?string" + }, + { + "name": "html", + "type": "flags.2?string" + }, + { + "name": "poster_photo_id", + "type": "flags.4?long" + }, + { + "name": "w", + "type": "int" + }, + { + "name": "h", + "type": "int" + }, + { + "name": "caption", + "type": "RichText" + } + ], + "type": "PageBlock" + }, + { + "id": "690781161", + "predicate": "pageBlockEmbedPost", + "params": [ + { + "name": "url", + "type": "string" + }, + { + "name": "webpage_id", + "type": "long" + }, + { + "name": "author_photo_id", + "type": "long" + }, + { + "name": "author", + "type": "string" + }, + { + "name": "date", + "type": "int" + }, + { + "name": "blocks", + "type": "Vector" + }, + { + "name": "caption", + "type": "RichText" + } + ], + "type": "PageBlock" + }, + { + "id": "319588707", + "predicate": "pageBlockSlideshow", + "params": [ + { + "name": "items", + "type": "Vector" + }, + { + "name": "caption", + "type": "RichText" + } + ], + "type": "PageBlock" + }, + { + "id": "-1908433218", + "predicate": "pagePart", + "params": [ + { + "name": "blocks", + "type": "Vector" + }, + { + "name": "photos", + "type": "Vector" + }, + { + "name": "documents", + "type": "Vector" + } + ], + "type": "Page" + }, + { + "id": "1433323434", + "predicate": "pageFull", + "params": [ + { + "name": "blocks", + "type": "Vector" + }, + { + "name": "photos", + "type": "Vector" + }, + { + "name": "documents", + "type": "Vector" + } + ], + "type": "Page" + }, + { + "id": "-1425052898", + "predicate": "updatePhoneCall", + "params": [ + { + "name": "phone_call", + "type": "PhoneCall" + } + ], + "type": "Update" + }, + { + "id": "-686710068", + "predicate": "updateDialogPinned", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "pinned", + "type": "flags.0?true" + }, + { + "name": "peer", + "type": "Peer" + } + ], + "type": "Update" + }, + { + "id": "-657787251", + "predicate": "updatePinnedDialogs", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "order", + "type": "flags.0?Vector" + } + ], + "type": "Update" + }, + { + "id": "-88417185", + "predicate": "inputPrivacyKeyPhoneCall", + "params": [], + "type": "InputPrivacyKey" + }, + { + "id": "1030105979", + "predicate": "privacyKeyPhoneCall", + "params": [], + "type": "PrivacyKey" + }, + { + "id": "324435594", + "predicate": "pageBlockUnsupported", + "params": [], + "type": "PageBlock" + }, + { + "id": "-837994576", + "predicate": "pageBlockAnchor", + "params": [ + { + "name": "name", + "type": "string" + } + ], + "type": "PageBlock" + }, + { + "id": "145955919", + "predicate": "pageBlockCollage", + "params": [ + { + "name": "items", + "type": "Vector" + }, + { + "name": "caption", + "type": "RichText" + } + ], + "type": "PageBlock" + }, + { + "id": "506920429", + "predicate": "inputPhoneCall", + "params": [ + { + "name": "id", + "type": "long" + }, + { + "name": "access_hash", + "type": "long" + } + ], + "type": "InputPhoneCall" + }, + { + "id": "1399245077", + "predicate": "phoneCallEmpty", + "params": [ + { + "name": "id", + "type": "long" + } + ], + "type": "PhoneCall" + }, + { + "id": "462375633", + "predicate": "phoneCallWaiting", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "id", + "type": "long" + }, + { + "name": "access_hash", + "type": "long" + }, + { + "name": "date", + "type": "int" + }, + { + "name": "admin_id", + "type": "int" + }, + { + "name": "participant_id", + "type": "int" + }, + { + "name": "protocol", + "type": "PhoneCallProtocol" + }, + { + "name": "receive_date", + "type": "flags.0?int" + } + ], + "type": "PhoneCall" + }, + { + "id": "-2089411356", + "predicate": "phoneCallRequested", + "params": [ + { + "name": "id", + "type": "long" + }, + { + "name": "access_hash", + "type": "long" + }, + { + "name": "date", + "type": "int" + }, + { + "name": "admin_id", + "type": "int" + }, + { + "name": "participant_id", + "type": "int" + }, + { + "name": "g_a_hash", + "type": "bytes" + }, + { + "name": "protocol", + "type": "PhoneCallProtocol" + } + ], + "type": "PhoneCall" + }, + { + "id": "-1660057", + "predicate": "phoneCall", + "params": [ + { + "name": "id", + "type": "long" + }, + { + "name": "access_hash", + "type": "long" + }, + { + "name": "date", + "type": "int" + }, + { + "name": "admin_id", + "type": "int" + }, + { + "name": "participant_id", + "type": "int" + }, + { + "name": "g_a_or_b", + "type": "bytes" + }, + { + "name": "key_fingerprint", + "type": "long" + }, + { + "name": "protocol", + "type": "PhoneCallProtocol" + }, + { + "name": "connection", + "type": "PhoneConnection" + }, + { + "name": "alternative_connections", + "type": "Vector" + }, + { + "name": "start_date", + "type": "int" + } + ], + "type": "PhoneCall" + }, + { + "id": "1355435489", + "predicate": "phoneCallDiscarded", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "need_rating", + "type": "flags.2?true" + }, + { + "name": "need_debug", + "type": "flags.3?true" + }, + { + "name": "id", + "type": "long" + }, + { + "name": "reason", + "type": "flags.0?PhoneCallDiscardReason" + }, + { + "name": "duration", + "type": "flags.1?int" + } + ], + "type": "PhoneCall" + }, + { + "id": "-1655957568", + "predicate": "phoneConnection", + "params": [ + { + "name": "id", + "type": "long" + }, + { + "name": "ip", + "type": "string" + }, + { + "name": "ipv6", + "type": "string" + }, + { + "name": "port", + "type": "int" + }, + { + "name": "peer_tag", + "type": "bytes" + } + ], + "type": "PhoneConnection" + }, + { + "id": "-1564789301", + "predicate": "phoneCallProtocol", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "udp_p2p", + "type": "flags.0?true" + }, + { + "name": "udp_reflector", + "type": "flags.1?true" + }, + { + "name": "min_layer", + "type": "int" + }, + { + "name": "max_layer", + "type": "int" + } + ], + "type": "PhoneCallProtocol" + }, + { + "id": "-326966976", + "predicate": "phone.phoneCall", + "params": [ + { + "name": "phone_call", + "type": "PhoneCall" + }, + { + "name": "users", + "type": "Vector" + } + ], + "type": "phone.PhoneCall" + }, + { + "id": "-2048646399", + "predicate": "phoneCallDiscardReasonMissed", + "params": [], + "type": "PhoneCallDiscardReason" + }, + { + "id": "-527056480", + "predicate": "phoneCallDiscardReasonDisconnect", + "params": [], + "type": "PhoneCallDiscardReason" + }, + { + "id": "1471006352", + "predicate": "phoneCallDiscardReasonHangup", + "params": [], + "type": "PhoneCallDiscardReason" + }, + { + "id": "-84416311", + "predicate": "phoneCallDiscardReasonBusy", + "params": [], + "type": "PhoneCallDiscardReason" + }, + { + "id": "-2134272152", + "predicate": "inputMessagesFilterPhoneCalls", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "missed", + "type": "flags.0?true" + } + ], + "type": "MessagesFilter" + }, + { + "id": "-2132731265", + "predicate": "messageActionPhoneCall", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "call_id", + "type": "long" + }, + { + "name": "reason", + "type": "flags.0?PhoneCallDiscardReason" + }, + { + "name": "duration", + "type": "flags.1?int" + } + ], + "type": "MessageAction" + }, + { + "id": "-1022713000", + "predicate": "invoice", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "test", + "type": "flags.0?true" + }, + { + "name": "name_requested", + "type": "flags.1?true" + }, + { + "name": "phone_requested", + "type": "flags.2?true" + }, + { + "name": "email_requested", + "type": "flags.3?true" + }, + { + "name": "shipping_address_requested", + "type": "flags.4?true" + }, + { + "name": "flexible", + "type": "flags.5?true" + }, + { + "name": "phone_to_provider", + "type": "flags.6?true" + }, + { + "name": "email_to_provider", + "type": "flags.7?true" + }, + { + "name": "currency", + "type": "string" + }, + { + "name": "prices", + "type": "Vector" + } + ], + "type": "Invoice" + }, + { + "id": "-186607933", + "predicate": "inputMediaInvoice", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "title", + "type": "string" + }, + { + "name": "description", + "type": "string" + }, + { + "name": "photo", + "type": "flags.0?InputWebDocument" + }, + { + "name": "invoice", + "type": "Invoice" + }, + { + "name": "payload", + "type": "bytes" + }, + { + "name": "provider", + "type": "string" + }, + { + "name": "provider_data", + "type": "DataJSON" + }, + { + "name": "start_param", + "type": "string" + } + ], + "type": "InputMedia" + }, + { + "id": "-1892568281", + "predicate": "messageActionPaymentSentMe", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "currency", + "type": "string" + }, + { + "name": "total_amount", + "type": "long" + }, + { + "name": "payload", + "type": "bytes" + }, + { + "name": "info", + "type": "flags.0?PaymentRequestedInfo" + }, + { + "name": "shipping_option_id", + "type": "flags.1?string" + }, + { + "name": "charge", + "type": "PaymentCharge" + } + ], + "type": "MessageAction" + }, + { + "id": "-2074799289", + "predicate": "messageMediaInvoice", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "shipping_address_requested", + "type": "flags.1?true" + }, + { + "name": "test", + "type": "flags.3?true" + }, + { + "name": "title", + "type": "string" + }, + { + "name": "description", + "type": "string" + }, + { + "name": "photo", + "type": "flags.0?WebDocument" + }, + { + "name": "receipt_msg_id", + "type": "flags.2?int" + }, + { + "name": "currency", + "type": "string" + }, + { + "name": "total_amount", + "type": "long" + }, + { + "name": "start_param", + "type": "string" + } + ], + "type": "MessageMedia" + }, + { + "id": "-1344716869", + "predicate": "keyboardButtonBuy", + "params": [ + { + "name": "text", + "type": "string" + } + ], + "type": "KeyboardButton" + }, + { + "id": "1080663248", + "predicate": "messageActionPaymentSent", + "params": [ + { + "name": "currency", + "type": "string" + }, + { + "name": "total_amount", + "type": "long" + } + ], + "type": "MessageAction" + }, + { + "id": "1062645411", + "predicate": "payments.paymentForm", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "can_save_credentials", + "type": "flags.2?true" + }, + { + "name": "password_missing", + "type": "flags.3?true" + }, + { + "name": "bot_id", + "type": "int" + }, + { + "name": "invoice", + "type": "Invoice" + }, + { + "name": "provider_id", + "type": "int" + }, + { + "name": "url", + "type": "string" + }, + { + "name": "native_provider", + "type": "flags.4?string" + }, + { + "name": "native_params", + "type": "flags.4?DataJSON" + }, + { + "name": "saved_info", + "type": "flags.0?PaymentRequestedInfo" + }, + { + "name": "saved_credentials", + "type": "flags.1?PaymentSavedCredentials" + }, + { + "name": "users", + "type": "Vector" + } + ], + "type": "payments.PaymentForm" + }, + { + "id": "512535275", + "predicate": "postAddress", + "params": [ + { + "name": "street_line1", + "type": "string" + }, + { + "name": "street_line2", + "type": "string" + }, + { + "name": "city", + "type": "string" + }, + { + "name": "state", + "type": "string" + }, + { + "name": "country_iso2", + "type": "string" + }, + { + "name": "post_code", + "type": "string" + } + ], + "type": "PostAddress" + }, + { + "id": "-1868808300", + "predicate": "paymentRequestedInfo", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "name", + "type": "flags.0?string" + }, + { + "name": "phone", + "type": "flags.1?string" + }, + { + "name": "email", + "type": "flags.2?string" + }, + { + "name": "shipping_address", + "type": "flags.3?PostAddress" + } + ], + "type": "PaymentRequestedInfo" + }, + { + "id": "-2095595325", + "predicate": "updateBotWebhookJSON", + "params": [ + { + "name": "data", + "type": "DataJSON" + } + ], + "type": "Update" + }, + { + "id": "-1684914010", + "predicate": "updateBotWebhookJSONQuery", + "params": [ + { + "name": "query_id", + "type": "long" + }, + { + "name": "data", + "type": "DataJSON" + }, + { + "name": "timeout", + "type": "int" + } + ], + "type": "Update" + }, + { + "id": "-523384512", + "predicate": "updateBotShippingQuery", + "params": [ + { + "name": "query_id", + "type": "long" + }, + { + "name": "user_id", + "type": "int" + }, + { + "name": "payload", + "type": "bytes" + }, + { + "name": "shipping_address", + "type": "PostAddress" + } + ], + "type": "Update" + }, + { + "id": "1563376297", + "predicate": "updateBotPrecheckoutQuery", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "query_id", + "type": "long" + }, + { + "name": "user_id", + "type": "int" + }, + { + "name": "payload", + "type": "bytes" + }, + { + "name": "info", + "type": "flags.0?PaymentRequestedInfo" + }, + { + "name": "shipping_option_id", + "type": "flags.1?string" + }, + { + "name": "currency", + "type": "string" + }, + { + "name": "total_amount", + "type": "long" + } + ], + "type": "Update" + }, + { + "id": "2104790276", + "predicate": "dataJSON", + "params": [ + { + "name": "data", + "type": "string" + } + ], + "type": "DataJSON" + }, + { + "id": "-886477832", + "predicate": "labeledPrice", + "params": [ + { + "name": "label", + "type": "string" + }, + { + "name": "amount", + "type": "long" + } + ], + "type": "LabeledPrice" + }, + { + "id": "-368917890", + "predicate": "paymentCharge", + "params": [ + { + "name": "id", + "type": "string" + }, + { + "name": "provider_charge_id", + "type": "string" + } + ], + "type": "PaymentCharge" + }, + { + "id": "-842892769", + "predicate": "paymentSavedCredentialsCard", + "params": [ + { + "name": "id", + "type": "string" + }, + { + "name": "title", + "type": "string" + } + ], + "type": "PaymentSavedCredentials" + }, + { + "id": "-971322408", + "predicate": "webDocument", + "params": [ + { + "name": "url", + "type": "string" + }, + { + "name": "access_hash", + "type": "long" + }, + { + "name": "size", + "type": "int" + }, + { + "name": "mime_type", + "type": "string" + }, + { + "name": "attributes", + "type": "Vector" + }, + { + "name": "dc_id", + "type": "int" + } + ], + "type": "WebDocument" + }, + { + "id": "-1678949555", + "predicate": "inputWebDocument", + "params": [ + { + "name": "url", + "type": "string" + }, + { + "name": "size", + "type": "int" + }, + { + "name": "mime_type", + "type": "string" + }, + { + "name": "attributes", + "type": "Vector" + } + ], + "type": "InputWebDocument" + }, + { + "id": "-1036396922", + "predicate": "inputWebFileLocation", + "params": [ + { + "name": "url", + "type": "string" + }, + { + "name": "access_hash", + "type": "long" + } + ], + "type": "InputWebFileLocation" + }, + { + "id": "568808380", + "predicate": "upload.webFile", + "params": [ + { + "name": "size", + "type": "int" + }, + { + "name": "mime_type", + "type": "string" + }, + { + "name": "file_type", + "type": "storage.FileType" + }, + { + "name": "mtime", + "type": "int" + }, + { + "name": "bytes", + "type": "bytes" + } + ], + "type": "upload.WebFile" + }, + { + "id": "-784000893", + "predicate": "payments.validatedRequestedInfo", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "id", + "type": "flags.0?string" + }, + { + "name": "shipping_options", + "type": "flags.1?Vector" + } + ], + "type": "payments.ValidatedRequestedInfo" + }, + { + "id": "1314881805", + "predicate": "payments.paymentResult", + "params": [ + { + "name": "updates", + "type": "Updates" + } + ], + "type": "payments.PaymentResult" + }, + { + "id": "1800845601", + "predicate": "payments.paymentVerficationNeeded", + "params": [ + { + "name": "url", + "type": "string" + } + ], + "type": "payments.PaymentResult" + }, + { + "id": "1342771681", + "predicate": "payments.paymentReceipt", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "date", + "type": "int" + }, + { + "name": "bot_id", + "type": "int" + }, + { + "name": "invoice", + "type": "Invoice" + }, + { + "name": "provider_id", + "type": "int" + }, + { + "name": "info", + "type": "flags.0?PaymentRequestedInfo" + }, + { + "name": "shipping", + "type": "flags.1?ShippingOption" + }, + { + "name": "currency", + "type": "string" + }, + { + "name": "total_amount", + "type": "long" + }, + { + "name": "credentials_title", + "type": "string" + }, + { + "name": "users", + "type": "Vector" + } + ], + "type": "payments.PaymentReceipt" + }, + { + "id": "-74456004", + "predicate": "payments.savedInfo", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "has_saved_credentials", + "type": "flags.1?true" + }, + { + "name": "saved_info", + "type": "flags.0?PaymentRequestedInfo" + } + ], + "type": "payments.SavedInfo" + }, + { + "id": "-1056001329", + "predicate": "inputPaymentCredentialsSaved", + "params": [ + { + "name": "id", + "type": "string" + }, + { + "name": "tmp_password", + "type": "bytes" + } + ], + "type": "InputPaymentCredentials" + }, + { + "id": "873977640", + "predicate": "inputPaymentCredentials", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "save", + "type": "flags.0?true" + }, + { + "name": "data", + "type": "DataJSON" + } + ], + "type": "InputPaymentCredentials" + }, + { + "id": "-614138572", + "predicate": "account.tmpPassword", + "params": [ + { + "name": "tmp_password", + "type": "bytes" + }, + { + "name": "valid_until", + "type": "int" + } + ], + "type": "account.TmpPassword" + }, + { + "id": "-1239335713", + "predicate": "shippingOption", + "params": [ + { + "name": "id", + "type": "string" + }, + { + "name": "title", + "type": "string" + }, + { + "name": "prices", + "type": "Vector" + } + ], + "type": "ShippingOption" + }, + { + "id": "1828732223", + "predicate": "phoneCallAccepted", + "params": [ + { + "name": "id", + "type": "long" + }, + { + "name": "access_hash", + "type": "long" + }, + { + "name": "date", + "type": "int" + }, + { + "name": "admin_id", + "type": "int" + }, + { + "name": "participant_id", + "type": "int" + }, + { + "name": "g_b", + "type": "bytes" + }, + { + "name": "protocol", + "type": "PhoneCallProtocol" + } + ], + "type": "PhoneCall" + }, + { + "id": "2054952868", + "predicate": "inputMessagesFilterRoundVoice", + "params": [], + "type": "MessagesFilter" + }, + { + "id": "-1253451181", + "predicate": "inputMessagesFilterRoundVideo", + "params": [], + "type": "MessagesFilter" + }, + { + "id": "-363659686", + "predicate": "upload.fileCdnRedirect", + "params": [ + { + "name": "dc_id", + "type": "int" + }, + { + "name": "file_token", + "type": "bytes" + }, + { + "name": "encryption_key", + "type": "bytes" + }, + { + "name": "encryption_iv", + "type": "bytes" + }, + { + "name": "cdn_file_hashes", + "type": "Vector" + } + ], + "type": "upload.File" + }, + { + "id": "-1997373508", + "predicate": "sendMessageRecordRoundAction", + "params": [], + "type": "SendMessageAction" + }, + { + "id": "608050278", + "predicate": "sendMessageUploadRoundAction", + "params": [ + { + "name": "progress", + "type": "int" + } + ], + "type": "SendMessageAction" + }, + { + "id": "-290921362", + "predicate": "upload.cdnFileReuploadNeeded", + "params": [ + { + "name": "request_token", + "type": "bytes" + } + ], + "type": "upload.CdnFile" + }, + { + "id": "-1449145777", + "predicate": "upload.cdnFile", + "params": [ + { + "name": "bytes", + "type": "bytes" + } + ], + "type": "upload.CdnFile" + }, + { + "id": "-914167110", + "predicate": "cdnPublicKey", + "params": [ + { + "name": "dc_id", + "type": "int" + }, + { + "name": "public_key", + "type": "string" + } + ], + "type": "CdnPublicKey" + }, + { + "id": "1462101002", + "predicate": "cdnConfig", + "params": [ + { + "name": "public_keys", + "type": "Vector" + } + ], + "type": "CdnConfig" + }, + { + "id": "281165899", + "predicate": "updateLangPackTooLong", + "params": [], + "type": "Update" + }, + { + "id": "1442983757", + "predicate": "updateLangPack", + "params": [ + { + "name": "difference", + "type": "LangPackDifference" + } + ], + "type": "Update" + }, + { + "id": "-283684427", + "predicate": "pageBlockChannel", + "params": [ + { + "name": "channel", + "type": "Chat" + } + ], + "type": "PageBlock" + }, + { + "id": "-6249322", + "predicate": "inputStickerSetItem", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "document", + "type": "InputDocument" + }, + { + "name": "emoji", + "type": "string" + }, + { + "name": "mask_coords", + "type": "flags.0?MaskCoords" + } + ], + "type": "InputStickerSetItem" + }, + { + "id": "-892239370", + "predicate": "langPackString", + "params": [ + { + "name": "key", + "type": "string" + }, + { + "name": "value", + "type": "string" + } + ], + "type": "LangPackString" + }, + { + "id": "1816636575", + "predicate": "langPackStringPluralized", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "key", + "type": "string" + }, + { + "name": "zero_value", + "type": "flags.0?string" + }, + { + "name": "one_value", + "type": "flags.1?string" + }, + { + "name": "two_value", + "type": "flags.2?string" + }, + { + "name": "few_value", + "type": "flags.3?string" + }, + { + "name": "many_value", + "type": "flags.4?string" + }, + { + "name": "other_value", + "type": "string" + } + ], + "type": "LangPackString" + }, + { + "id": "695856818", + "predicate": "langPackStringDeleted", + "params": [ + { + "name": "key", + "type": "string" + } + ], + "type": "LangPackString" + }, + { + "id": "-209337866", + "predicate": "langPackDifference", + "params": [ + { + "name": "lang_code", + "type": "string" + }, + { + "name": "from_version", + "type": "int" + }, + { + "name": "version", + "type": "int" + }, + { + "name": "strings", + "type": "Vector" + } + ], + "type": "LangPackDifference" + }, + { + "id": "292985073", + "predicate": "langPackLanguage", + "params": [ + { + "name": "name", + "type": "string" + }, + { + "name": "native_name", + "type": "string" + }, + { + "name": "lang_code", + "type": "string" + } + ], + "type": "LangPackLanguage" + }, + { + "id": "-1473271656", + "predicate": "channelParticipantAdmin", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "can_edit", + "type": "flags.0?true" + }, + { + "name": "user_id", + "type": "int" + }, + { + "name": "inviter_id", + "type": "int" + }, + { + "name": "promoted_by", + "type": "int" + }, + { + "name": "date", + "type": "int" + }, + { + "name": "admin_rights", + "type": "ChannelAdminRights" + } + ], + "type": "ChannelParticipant" + }, + { + "id": "573315206", + "predicate": "channelParticipantBanned", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "left", + "type": "flags.0?true" + }, + { + "name": "user_id", + "type": "int" + }, + { + "name": "kicked_by", + "type": "int" + }, + { + "name": "date", + "type": "int" + }, + { + "name": "banned_rights", + "type": "ChannelBannedRights" + } + ], + "type": "ChannelParticipant" + }, + { + "id": "338142689", + "predicate": "channelParticipantsBanned", + "params": [ + { + "name": "q", + "type": "string" + } + ], + "type": "ChannelParticipantsFilter" + }, + { + "id": "106343499", + "predicate": "channelParticipantsSearch", + "params": [ + { + "name": "q", + "type": "string" + } + ], + "type": "ChannelParticipantsFilter" + }, + { + "id": "511092620", + "predicate": "topPeerCategoryPhoneCalls", + "params": [], + "type": "TopPeerCategory" + }, + { + "id": "834148991", + "predicate": "pageBlockAudio", + "params": [ + { + "name": "audio_id", + "type": "long" + }, + { + "name": "caption", + "type": "RichText" + } + ], + "type": "PageBlock" + }, + { + "id": "1568467877", + "predicate": "channelAdminRights", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "change_info", + "type": "flags.0?true" + }, + { + "name": "post_messages", + "type": "flags.1?true" + }, + { + "name": "edit_messages", + "type": "flags.2?true" + }, + { + "name": "delete_messages", + "type": "flags.3?true" + }, + { + "name": "ban_users", + "type": "flags.4?true" + }, + { + "name": "invite_users", + "type": "flags.5?true" + }, + { + "name": "invite_link", + "type": "flags.6?true" + }, + { + "name": "pin_messages", + "type": "flags.7?true" + }, + { + "name": "add_admins", + "type": "flags.9?true" + } + ], + "type": "ChannelAdminRights" + }, + { + "id": "1489977929", + "predicate": "channelBannedRights", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "view_messages", + "type": "flags.0?true" + }, + { + "name": "send_messages", + "type": "flags.1?true" + }, + { + "name": "send_media", + "type": "flags.2?true" + }, + { + "name": "send_stickers", + "type": "flags.3?true" + }, + { + "name": "send_gifs", + "type": "flags.4?true" + }, + { + "name": "send_games", + "type": "flags.5?true" + }, + { + "name": "send_inline", + "type": "flags.6?true" + }, + { + "name": "embed_links", + "type": "flags.7?true" + }, + { + "name": "until_date", + "type": "int" + } + ], + "type": "ChannelBannedRights" + }, + { + "id": "-421545947", + "predicate": "channelAdminLogEventActionChangeTitle", + "params": [ + { + "name": "prev_value", + "type": "string" + }, + { + "name": "new_value", + "type": "string" + } + ], + "type": "ChannelAdminLogEventAction" + }, + { + "id": "1427671598", + "predicate": "channelAdminLogEventActionChangeAbout", + "params": [ + { + "name": "prev_value", + "type": "string" + }, + { + "name": "new_value", + "type": "string" + } + ], + "type": "ChannelAdminLogEventAction" + }, + { + "id": "1783299128", + "predicate": "channelAdminLogEventActionChangeUsername", + "params": [ + { + "name": "prev_value", + "type": "string" + }, + { + "name": "new_value", + "type": "string" + } + ], + "type": "ChannelAdminLogEventAction" + }, + { + "id": "-1204857405", + "predicate": "channelAdminLogEventActionChangePhoto", + "params": [ + { + "name": "prev_photo", + "type": "ChatPhoto" + }, + { + "name": "new_photo", + "type": "ChatPhoto" + } + ], + "type": "ChannelAdminLogEventAction" + }, + { + "id": "460916654", + "predicate": "channelAdminLogEventActionToggleInvites", + "params": [ + { + "name": "new_value", + "type": "Bool" + } + ], + "type": "ChannelAdminLogEventAction" + }, + { + "id": "648939889", + "predicate": "channelAdminLogEventActionToggleSignatures", + "params": [ + { + "name": "new_value", + "type": "Bool" + } + ], + "type": "ChannelAdminLogEventAction" + }, + { + "id": "-370660328", + "predicate": "channelAdminLogEventActionUpdatePinned", + "params": [ + { + "name": "message", + "type": "Message" + } + ], + "type": "ChannelAdminLogEventAction" + }, + { + "id": "1889215493", + "predicate": "channelAdminLogEventActionEditMessage", + "params": [ + { + "name": "prev_message", + "type": "Message" + }, + { + "name": "new_message", + "type": "Message" + } + ], + "type": "ChannelAdminLogEventAction" + }, + { + "id": "1121994683", + "predicate": "channelAdminLogEventActionDeleteMessage", + "params": [ + { + "name": "message", + "type": "Message" + } + ], + "type": "ChannelAdminLogEventAction" + }, + { + "id": "405815507", + "predicate": "channelAdminLogEventActionParticipantJoin", + "params": [], + "type": "ChannelAdminLogEventAction" + }, + { + "id": "-124291086", + "predicate": "channelAdminLogEventActionParticipantLeave", + "params": [], + "type": "ChannelAdminLogEventAction" + }, + { + "id": "-484690728", + "predicate": "channelAdminLogEventActionParticipantInvite", + "params": [ + { + "name": "participant", + "type": "ChannelParticipant" + } + ], + "type": "ChannelAdminLogEventAction" + }, + { + "id": "-422036098", + "predicate": "channelAdminLogEventActionParticipantToggleBan", + "params": [ + { + "name": "prev_participant", + "type": "ChannelParticipant" + }, + { + "name": "new_participant", + "type": "ChannelParticipant" + } + ], + "type": "ChannelAdminLogEventAction" + }, + { + "id": "-714643696", + "predicate": "channelAdminLogEventActionParticipantToggleAdmin", + "params": [ + { + "name": "prev_participant", + "type": "ChannelParticipant" + }, + { + "name": "new_participant", + "type": "ChannelParticipant" + } + ], + "type": "ChannelAdminLogEventAction" + }, + { + "id": "995769920", + "predicate": "channelAdminLogEvent", + "params": [ + { + "name": "id", + "type": "long" + }, + { + "name": "date", + "type": "int" + }, + { + "name": "user_id", + "type": "int" + }, + { + "name": "action", + "type": "ChannelAdminLogEventAction" + } + ], + "type": "ChannelAdminLogEvent" + }, + { + "id": "-309659827", + "predicate": "channels.adminLogResults", + "params": [ + { + "name": "events", + "type": "Vector" + }, + { + "name": "chats", + "type": "Vector" + }, + { + "name": "users", + "type": "Vector" + } + ], + "type": "channels.AdminLogResults" + }, + { + "id": "-368018716", + "predicate": "channelAdminLogEventsFilter", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "join", + "type": "flags.0?true" + }, + { + "name": "leave", + "type": "flags.1?true" + }, + { + "name": "invite", + "type": "flags.2?true" + }, + { + "name": "ban", + "type": "flags.3?true" + }, + { + "name": "unban", + "type": "flags.4?true" + }, + { + "name": "kick", + "type": "flags.5?true" + }, + { + "name": "unkick", + "type": "flags.6?true" + }, + { + "name": "promote", + "type": "flags.7?true" + }, + { + "name": "demote", + "type": "flags.8?true" + }, + { + "name": "info", + "type": "flags.9?true" + }, + { + "name": "settings", + "type": "flags.10?true" + }, + { + "name": "pinned", + "type": "flags.11?true" + }, + { + "name": "edit", + "type": "flags.12?true" + }, + { + "name": "delete", + "type": "flags.13?true" + } + ], + "type": "ChannelAdminLogEventsFilter" + }, + { + "id": "1200788123", + "predicate": "messageActionScreenshotTaken", + "params": [], + "type": "MessageAction" + }, + { + "id": "1558266229", + "predicate": "popularContact", + "params": [ + { + "name": "client_id", + "type": "long" + }, + { + "name": "importers", + "type": "int" + } + ], + "type": "PopularContact" + }, + { + "id": "2012136335", + "predicate": "cdnFileHash", + "params": [ + { + "name": "offset", + "type": "int" + }, + { + "name": "limit", + "type": "int" + }, + { + "name": "hash", + "type": "bytes" + } + ], + "type": "CdnFileHash" + }, + { + "id": "-1040652646", + "predicate": "inputMessagesFilterMyMentions", + "params": [], + "type": "MessagesFilter" + }, + { + "id": "1887741886", + "predicate": "updateContactsReset", + "params": [], + "type": "Update" + }, + { + "id": "-1312568665", + "predicate": "channelAdminLogEventActionChangeStickerSet", + "params": [ + { + "name": "prev_stickerset", + "type": "InputStickerSet" + }, + { + "name": "new_stickerset", + "type": "InputStickerSet" + } + ], + "type": "ChannelAdminLogEventAction" + }, + { + "id": "-451831443", + "predicate": "updateFavedStickers", + "params": [], + "type": "Update" + }, + { + "id": "-209768682", + "predicate": "messages.favedStickers", + "params": [ + { + "name": "hash", + "type": "int" + }, + { + "name": "packs", + "type": "Vector" + }, + { + "name": "stickers", + "type": "Vector" + } + ], + "type": "messages.FavedStickers" + }, + { + "id": "-1634752813", + "predicate": "messages.favedStickersNotModified", + "params": [], + "type": "messages.FavedStickers" + }, + { + "id": "-1987495099", + "predicate": "updateChannelReadMessagesContents", + "params": [ + { + "name": "channel_id", + "type": "int" + }, + { + "name": "messages", + "type": "Vector" + } + ], + "type": "Update" + }, + { + "id": "2065305999", + "predicate": "inputMediaGeoLive", + "params": [ + { + "name": "geo_point", + "type": "InputGeoPoint" + }, + { + "name": "period", + "type": "int" + } + ], + "type": "InputMedia" + }, + { + "id": "2084316681", + "predicate": "messageMediaGeoLive", + "params": [ + { + "name": "geo", + "type": "GeoPoint" + }, + { + "name": "period", + "type": "int" + } + ], + "type": "MessageMedia" + }, + { + "id": "-85549226", + "predicate": "messageActionCustomAction", + "params": [ + { + "name": "message", + "type": "string" + } + ], + "type": "MessageAction" + }, + { + "id": "-530392189", + "predicate": "inputMessagesFilterContacts", + "params": [], + "type": "MessagesFilter" + }, + { + "id": "-419271411", + "predicate": "inputMessagesFilterGeo", + "params": [], + "type": "MessagesFilter" + }, + { + "id": "1893427255", + "predicate": "updateChannelAvailableMessages", + "params": [ + { + "name": "channel_id", + "type": "int" + }, + { + "name": "available_min_id", + "type": "int" + } + ], + "type": "Update" + }, + { + "id": "-266911767", + "predicate": "channels.channelParticipantsNotModified", + "params": [], + "type": "channels.ChannelParticipants" + }, + { + "id": "1599903217", + "predicate": "channelAdminLogEventActionTogglePreHistoryHidden", + "params": [ + { + "name": "new_value", + "type": "Bool" + } + ], + "type": "ChannelAdminLogEventAction" + }, + { + "id": "235081943", + "predicate": "help.recentMeUrls", + "params": [ + { + "name": "urls", + "type": "Vector" + }, + { + "name": "chats", + "type": "Vector" + }, + { + "name": "users", + "type": "Vector" + } + ], + "type": "help.RecentMeUrls" + }, + { + "id": "-1917045962", + "predicate": "recentMeUrlUser", + "params": [ + { + "name": "url", + "type": "string" + }, + { + "name": "user_id", + "type": "int" + } + ], + "type": "RecentMeUrl" + }, + { + "id": "-1608834311", + "predicate": "recentMeUrlChat", + "params": [ + { + "name": "url", + "type": "string" + }, + { + "name": "chat_id", + "type": "int" + } + ], + "type": "RecentMeUrl" + }, + { + "id": "-1140172836", + "predicate": "recentMeUrlStickerSet", + "params": [ + { + "name": "url", + "type": "string" + }, + { + "name": "set", + "type": "StickerSetCovered" + } + ], + "type": "RecentMeUrl" + }, + { + "id": "-347535331", + "predicate": "recentMeUrlChatInvite", + "params": [ + { + "name": "url", + "type": "string" + }, + { + "name": "chat_invite", + "type": "ChatInvite" + } + ], + "type": "RecentMeUrl" + }, + { + "id": "1189204285", + "predicate": "recentMeUrlUnknown", + "params": [ + { + "name": "url", + "type": "string" + } + ], + "type": "RecentMeUrl" + }, + { + "id": "1588230153", + "predicate": "inputSingleMedia", + "params": [ + { + "name": "media", + "type": "InputMedia" + }, + { + "name": "random_id", + "type": "long" + } + ], + "type": "InputSingleMedia" + }, + { + "id": "1951620897", + "predicate": "messages.messagesNotModified", + "params": [ + { + "name": "count", + "type": "int" + } + ], + "type": "messages.Messages" + }, + { + "id": "178373535", + "predicate": "inputPaymentCredentialsApplePay", + "params": [ + { + "name": "payment_data", + "type": "DataJSON" + } + ], + "type": "InputPaymentCredentials" + }, + { + "id": "-905587442", + "predicate": "inputPaymentCredentialsAndroidPay", + "params": [ + { + "name": "payment_token", + "type": "DataJSON" + }, + { + "name": "google_transaction_id", + "type": "string" + } + ], + "type": "InputPaymentCredentials" + } + ], + "methods": [ + { + "id": "-878758099", + "method": "invokeAfterMsg", + "params": [ + { + "name": "msg_id", + "type": "long" + }, + { + "name": "query", + "type": "!X" + } + ], + "type": "X" + }, + { + "id": "1036301552", + "method": "invokeAfterMsgs", + "params": [ + { + "name": "msg_ids", + "type": "Vector" + }, + { + "name": "query", + "type": "!X" + } + ], + "type": "X" + }, + { + "id": "1877286395", + "method": "auth.checkPhone", + "params": [ + { + "name": "phone_number", + "type": "string" + } + ], + "type": "auth.CheckedPhone" + }, + { + "id": "-2035355412", + "method": "auth.sendCode", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "allow_flashcall", + "type": "flags.0?true" + }, + { + "name": "phone_number", + "type": "string" + }, + { + "name": "current_number", + "type": "flags.0?Bool" + }, + { + "name": "api_id", + "type": "int" + }, + { + "name": "api_hash", + "type": "string" + } + ], + "type": "auth.SentCode" + }, + { + "id": "453408308", + "method": "auth.signUp", + "params": [ + { + "name": "phone_number", + "type": "string" + }, + { + "name": "phone_code_hash", + "type": "string" + }, + { + "name": "phone_code", + "type": "string" + }, + { + "name": "first_name", + "type": "string" + }, + { + "name": "last_name", + "type": "string" + } + ], + "type": "auth.Authorization" + }, + { + "id": "-1126886015", + "method": "auth.signIn", + "params": [ + { + "name": "phone_number", + "type": "string" + }, + { + "name": "phone_code_hash", + "type": "string" + }, + { + "name": "phone_code", + "type": "string" + } + ], + "type": "auth.Authorization" + }, + { + "id": "1461180992", + "method": "auth.logOut", + "params": [], + "type": "Bool" + }, + { + "id": "-1616179942", + "method": "auth.resetAuthorizations", + "params": [], + "type": "Bool" + }, + { + "id": "1998331287", + "method": "auth.sendInvites", + "params": [ + { + "name": "phone_numbers", + "type": "Vector" + }, + { + "name": "message", + "type": "string" + } + ], + "type": "Bool" + }, + { + "id": "-440401971", + "method": "auth.exportAuthorization", + "params": [ + { + "name": "dc_id", + "type": "int" + } + ], + "type": "auth.ExportedAuthorization" + }, + { + "id": "-470837741", + "method": "auth.importAuthorization", + "params": [ + { + "name": "id", + "type": "int" + }, + { + "name": "bytes", + "type": "bytes" + } + ], + "type": "auth.Authorization" + }, + { + "id": "-145197871", + "method": "account.registerDevice", + "params": [ + { + "name": "token_type", + "type": "int" + }, + { + "name": "token", + "type": "string" + }, + { + "name": "other_uids", + "type": "Vector" + } + ], + "type": "Bool" + }, + { + "id": "813089983", + "method": "account.unregisterDevice", + "params": [ + { + "name": "token_type", + "type": "int" + }, + { + "name": "token", + "type": "string" + }, + { + "name": "other_uids", + "type": "Vector" + } + ], + "type": "Bool" + }, + { + "id": "-2067899501", + "method": "account.updateNotifySettings", + "params": [ + { + "name": "peer", + "type": "InputNotifyPeer" + }, + { + "name": "settings", + "type": "InputPeerNotifySettings" + } + ], + "type": "Bool" + }, + { + "id": "313765169", + "method": "account.getNotifySettings", + "params": [ + { + "name": "peer", + "type": "InputNotifyPeer" + } + ], + "type": "PeerNotifySettings" + }, + { + "id": "-612493497", + "method": "account.resetNotifySettings", + "params": [], + "type": "Bool" + }, + { + "id": "2018596725", + "method": "account.updateProfile", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "first_name", + "type": "flags.0?string" + }, + { + "name": "last_name", + "type": "flags.1?string" + }, + { + "name": "about", + "type": "flags.2?string" + } + ], + "type": "User" + }, + { + "id": "1713919532", + "method": "account.updateStatus", + "params": [ + { + "name": "offline", + "type": "Bool" + } + ], + "type": "Bool" + }, + { + "id": "-1068696894", + "method": "account.getWallPapers", + "params": [], + "type": "Vector" + }, + { + "id": "227648840", + "method": "users.getUsers", + "params": [ + { + "name": "id", + "type": "Vector" + } + ], + "type": "Vector" + }, + { + "id": "-902781519", + "method": "users.getFullUser", + "params": [ + { + "name": "id", + "type": "InputUser" + } + ], + "type": "UserFull" + }, + { + "id": "-995929106", + "method": "contacts.getStatuses", + "params": [], + "type": "Vector" + }, + { + "id": "-1071414113", + "method": "contacts.getContacts", + "params": [ + { + "name": "hash", + "type": "int" + } + ], + "type": "contacts.Contacts" + }, + { + "id": "746589157", + "method": "contacts.importContacts", + "params": [ + { + "name": "contacts", + "type": "Vector" + } + ], + "type": "contacts.ImportedContacts" + }, + { + "id": "301470424", + "method": "contacts.search", + "params": [ + { + "name": "q", + "type": "string" + }, + { + "name": "limit", + "type": "int" + } + ], + "type": "contacts.Found" + }, + { + "id": "-1902823612", + "method": "contacts.deleteContact", + "params": [ + { + "name": "id", + "type": "InputUser" + } + ], + "type": "contacts.Link" + }, + { + "id": "1504393374", + "method": "contacts.deleteContacts", + "params": [ + { + "name": "id", + "type": "Vector" + } + ], + "type": "Bool" + }, + { + "id": "858475004", + "method": "contacts.block", + "params": [ + { + "name": "id", + "type": "InputUser" + } + ], + "type": "Bool" + }, + { + "id": "-448724803", + "method": "contacts.unblock", + "params": [ + { + "name": "id", + "type": "InputUser" + } + ], + "type": "Bool" + }, + { + "id": "-176409329", + "method": "contacts.getBlocked", + "params": [ + { + "name": "offset", + "type": "int" + }, + { + "name": "limit", + "type": "int" + } + ], + "type": "contacts.Blocked" + }, + { + "id": "1109588596", + "method": "messages.getMessages", + "params": [ + { + "name": "id", + "type": "Vector" + } + ], + "type": "messages.Messages" + }, + { + "id": "421243333", + "method": "messages.getDialogs", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "exclude_pinned", + "type": "flags.0?true" + }, + { + "name": "offset_date", + "type": "int" + }, + { + "name": "offset_id", + "type": "int" + }, + { + "name": "offset_peer", + "type": "InputPeer" + }, + { + "name": "limit", + "type": "int" + } + ], + "type": "messages.Dialogs" + }, + { + "id": "-591691168", + "method": "messages.getHistory", + "params": [ + { + "name": "peer", + "type": "InputPeer" + }, + { + "name": "offset_id", + "type": "int" + }, + { + "name": "offset_date", + "type": "int" + }, + { + "name": "add_offset", + "type": "int" + }, + { + "name": "limit", + "type": "int" + }, + { + "name": "max_id", + "type": "int" + }, + { + "name": "min_id", + "type": "int" + }, + { + "name": "hash", + "type": "int" + } + ], + "type": "messages.Messages" + }, + { + "id": "60726944", + "method": "messages.search", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "peer", + "type": "InputPeer" + }, + { + "name": "q", + "type": "string" + }, + { + "name": "from_id", + "type": "flags.0?InputUser" + }, + { + "name": "filter", + "type": "MessagesFilter" + }, + { + "name": "min_date", + "type": "int" + }, + { + "name": "max_date", + "type": "int" + }, + { + "name": "offset_id", + "type": "int" + }, + { + "name": "add_offset", + "type": "int" + }, + { + "name": "limit", + "type": "int" + }, + { + "name": "max_id", + "type": "int" + }, + { + "name": "min_id", + "type": "int" + } + ], + "type": "messages.Messages" + }, + { + "id": "238054714", + "method": "messages.readHistory", + "params": [ + { + "name": "peer", + "type": "InputPeer" + }, + { + "name": "max_id", + "type": "int" + } + ], + "type": "messages.AffectedMessages" + }, + { + "id": "469850889", + "method": "messages.deleteHistory", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "just_clear", + "type": "flags.0?true" + }, + { + "name": "peer", + "type": "InputPeer" + }, + { + "name": "max_id", + "type": "int" + } + ], + "type": "messages.AffectedHistory" + }, + { + "id": "-443640366", + "method": "messages.deleteMessages", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "revoke", + "type": "flags.0?true" + }, + { + "name": "id", + "type": "Vector" + } + ], + "type": "messages.AffectedMessages" + }, + { + "id": "94983360", + "method": "messages.receivedMessages", + "params": [ + { + "name": "max_id", + "type": "int" + } + ], + "type": "Vector" + }, + { + "id": "-1551737264", + "method": "messages.setTyping", + "params": [ + { + "name": "peer", + "type": "InputPeer" + }, + { + "name": "action", + "type": "SendMessageAction" + } + ], + "type": "Bool" + }, + { + "id": "-91733382", + "method": "messages.sendMessage", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "no_webpage", + "type": "flags.1?true" + }, + { + "name": "silent", + "type": "flags.5?true" + }, + { + "name": "background", + "type": "flags.6?true" + }, + { + "name": "clear_draft", + "type": "flags.7?true" + }, + { + "name": "peer", + "type": "InputPeer" + }, + { + "name": "reply_to_msg_id", + "type": "flags.0?int" + }, + { + "name": "message", + "type": "string" + }, + { + "name": "random_id", + "type": "long" + }, + { + "name": "reply_markup", + "type": "flags.2?ReplyMarkup" + }, + { + "name": "entities", + "type": "flags.3?Vector" + } + ], + "type": "Updates" + }, + { + "id": "-923703407", + "method": "messages.sendMedia", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "silent", + "type": "flags.5?true" + }, + { + "name": "background", + "type": "flags.6?true" + }, + { + "name": "clear_draft", + "type": "flags.7?true" + }, + { + "name": "peer", + "type": "InputPeer" + }, + { + "name": "reply_to_msg_id", + "type": "flags.0?int" + }, + { + "name": "media", + "type": "InputMedia" + }, + { + "name": "random_id", + "type": "long" + }, + { + "name": "reply_markup", + "type": "flags.2?ReplyMarkup" + } + ], + "type": "Updates" + }, + { + "id": "1888354709", + "method": "messages.forwardMessages", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "silent", + "type": "flags.5?true" + }, + { + "name": "background", + "type": "flags.6?true" + }, + { + "name": "with_my_score", + "type": "flags.8?true" + }, + { + "name": "from_peer", + "type": "InputPeer" + }, + { + "name": "id", + "type": "Vector" + }, + { + "name": "random_id", + "type": "Vector" + }, + { + "name": "to_peer", + "type": "InputPeer" + }, + { + "name": "grouped", + "type": "flags.9?true" + } + ], + "type": "Updates" + }, + { + "id": "1013621127", + "method": "messages.getChats", + "params": [ + { + "name": "id", + "type": "Vector" + } + ], + "type": "messages.Chats" + }, + { + "id": "998448230", + "method": "messages.getFullChat", + "params": [ + { + "name": "chat_id", + "type": "int" + } + ], + "type": "messages.ChatFull" + }, + { + "id": "-599447467", + "method": "messages.editChatTitle", + "params": [ + { + "name": "chat_id", + "type": "int" + }, + { + "name": "title", + "type": "string" + } + ], + "type": "Updates" + }, + { + "id": "-900957736", + "method": "messages.editChatPhoto", + "params": [ + { + "name": "chat_id", + "type": "int" + }, + { + "name": "photo", + "type": "InputChatPhoto" + } + ], + "type": "Updates" + }, + { + "id": "-106911223", + "method": "messages.addChatUser", + "params": [ + { + "name": "chat_id", + "type": "int" + }, + { + "name": "user_id", + "type": "InputUser" + }, + { + "name": "fwd_limit", + "type": "int" + } + ], + "type": "Updates" + }, + { + "id": "-530505962", + "method": "messages.deleteChatUser", + "params": [ + { + "name": "chat_id", + "type": "int" + }, + { + "name": "user_id", + "type": "InputUser" + } + ], + "type": "Updates" + }, + { + "id": "164303470", + "method": "messages.createChat", + "params": [ + { + "name": "users", + "type": "Vector" + }, + { + "name": "title", + "type": "string" + } + ], + "type": "Updates" + }, + { + "id": "-304838614", + "method": "updates.getState", + "params": [], + "type": "updates.State" + }, + { + "id": "630429265", + "method": "updates.getDifference", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "pts", + "type": "int" + }, + { + "name": "pts_total_limit", + "type": "flags.0?int" + }, + { + "name": "date", + "type": "int" + }, + { + "name": "qts", + "type": "int" + } + ], + "type": "updates.Difference" + }, + { + "id": "-256159406", + "method": "photos.updateProfilePhoto", + "params": [ + { + "name": "id", + "type": "InputPhoto" + } + ], + "type": "UserProfilePhoto" + }, + { + "id": "1328726168", + "method": "photos.uploadProfilePhoto", + "params": [ + { + "name": "file", + "type": "InputFile" + } + ], + "type": "photos.Photo" + }, + { + "id": "-1291540959", + "method": "upload.saveFilePart", + "params": [ + { + "name": "file_id", + "type": "long" + }, + { + "name": "file_part", + "type": "int" + }, + { + "name": "bytes", + "type": "bytes" + } + ], + "type": "Bool" + }, + { + "id": "-475607115", + "method": "upload.getFile", + "params": [ + { + "name": "location", + "type": "InputFileLocation" + }, + { + "name": "offset", + "type": "int" + }, + { + "name": "limit", + "type": "int" + } + ], + "type": "upload.File" + }, + { + "id": "-990308245", + "method": "help.getConfig", + "params": [], + "type": "Config" + }, + { + "id": "531836966", + "method": "help.getNearestDc", + "params": [], + "type": "NearestDc" + }, + { + "id": "-1372724842", + "method": "help.getAppUpdate", + "params": [], + "type": "help.AppUpdate" + }, + { + "id": "1862465352", + "method": "help.saveAppLog", + "params": [ + { + "name": "events", + "type": "Vector" + } + ], + "type": "Bool" + }, + { + "id": "1295590211", + "method": "help.getInviteText", + "params": [], + "type": "help.InviteText" + }, + { + "id": "-2016444625", + "method": "photos.deletePhotos", + "params": [ + { + "name": "id", + "type": "Vector" + } + ], + "type": "Vector" + }, + { + "id": "-1848823128", + "method": "photos.getUserPhotos", + "params": [ + { + "name": "user_id", + "type": "InputUser" + }, + { + "name": "offset", + "type": "int" + }, + { + "name": "max_id", + "type": "long" + }, + { + "name": "limit", + "type": "int" + } + ], + "type": "photos.Photos" + }, + { + "id": "865483769", + "method": "messages.forwardMessage", + "params": [ + { + "name": "peer", + "type": "InputPeer" + }, + { + "name": "id", + "type": "int" + }, + { + "name": "random_id", + "type": "long" + } + ], + "type": "Updates" + }, + { + "id": "651135312", + "method": "messages.getDhConfig", + "params": [ + { + "name": "version", + "type": "int" + }, + { + "name": "random_length", + "type": "int" + } + ], + "type": "messages.DhConfig" + }, + { + "id": "-162681021", + "method": "messages.requestEncryption", + "params": [ + { + "name": "user_id", + "type": "InputUser" + }, + { + "name": "random_id", + "type": "int" + }, + { + "name": "g_a", + "type": "bytes" + } + ], + "type": "EncryptedChat" + }, + { + "id": "1035731989", + "method": "messages.acceptEncryption", + "params": [ + { + "name": "peer", + "type": "InputEncryptedChat" + }, + { + "name": "g_b", + "type": "bytes" + }, + { + "name": "key_fingerprint", + "type": "long" + } + ], + "type": "EncryptedChat" + }, + { + "id": "-304536635", + "method": "messages.discardEncryption", + "params": [ + { + "name": "chat_id", + "type": "int" + } + ], + "type": "Bool" + }, + { + "id": "2031374829", + "method": "messages.setEncryptedTyping", + "params": [ + { + "name": "peer", + "type": "InputEncryptedChat" + }, + { + "name": "typing", + "type": "Bool" + } + ], + "type": "Bool" + }, + { + "id": "2135648522", + "method": "messages.readEncryptedHistory", + "params": [ + { + "name": "peer", + "type": "InputEncryptedChat" + }, + { + "name": "max_date", + "type": "int" + } + ], + "type": "Bool" + }, + { + "id": "-1451792525", + "method": "messages.sendEncrypted", + "params": [ + { + "name": "peer", + "type": "InputEncryptedChat" + }, + { + "name": "random_id", + "type": "long" + }, + { + "name": "data", + "type": "bytes" + } + ], + "type": "messages.SentEncryptedMessage" + }, + { + "id": "-1701831834", + "method": "messages.sendEncryptedFile", + "params": [ + { + "name": "peer", + "type": "InputEncryptedChat" + }, + { + "name": "random_id", + "type": "long" + }, + { + "name": "data", + "type": "bytes" + }, + { + "name": "file", + "type": "InputEncryptedFile" + } + ], + "type": "messages.SentEncryptedMessage" + }, + { + "id": "852769188", + "method": "messages.sendEncryptedService", + "params": [ + { + "name": "peer", + "type": "InputEncryptedChat" + }, + { + "name": "random_id", + "type": "long" + }, + { + "name": "data", + "type": "bytes" + } + ], + "type": "messages.SentEncryptedMessage" + }, + { + "id": "1436924774", + "method": "messages.receivedQueue", + "params": [ + { + "name": "max_qts", + "type": "int" + } + ], + "type": "Vector" + }, + { + "id": "-562337987", + "method": "upload.saveBigFilePart", + "params": [ + { + "name": "file_id", + "type": "long" + }, + { + "name": "file_part", + "type": "int" + }, + { + "name": "file_total_parts", + "type": "int" + }, + { + "name": "bytes", + "type": "bytes" + } + ], + "type": "Bool" + }, + { + "id": "-951575130", + "method": "initConnection", + "params": [ + { + "name": "api_id", + "type": "int" + }, + { + "name": "device_model", + "type": "string" + }, + { + "name": "system_version", + "type": "string" + }, + { + "name": "app_version", + "type": "string" + }, + { + "name": "system_lang_code", + "type": "string" + }, + { + "name": "lang_pack", + "type": "string" + }, + { + "name": "lang_code", + "type": "string" + }, + { + "name": "query", + "type": "!X" + } + ], + "type": "X" + }, + { + "id": "-1663104819", + "method": "help.getSupport", + "params": [], + "type": "help.Support" + }, + { + "id": "-841733627", + "method": "auth.bindTempAuthKey", + "params": [ + { + "name": "perm_auth_key_id", + "type": "long" + }, + { + "name": "nonce", + "type": "long" + }, + { + "name": "expires_at", + "type": "int" + }, + { + "name": "encrypted_message", + "type": "bytes" + } + ], + "type": "Bool" + }, + { + "id": "-2065352905", + "method": "contacts.exportCard", + "params": [], + "type": "Vector" + }, + { + "id": "1340184318", + "method": "contacts.importCard", + "params": [ + { + "name": "export_card", + "type": "Vector" + } + ], + "type": "User" + }, + { + "id": "916930423", + "method": "messages.readMessageContents", + "params": [ + { + "name": "id", + "type": "Vector" + } + ], + "type": "messages.AffectedMessages" + }, + { + "id": "655677548", + "method": "account.checkUsername", + "params": [ + { + "name": "username", + "type": "string" + } + ], + "type": "Bool" + }, + { + "id": "1040964988", + "method": "account.updateUsername", + "params": [ + { + "name": "username", + "type": "string" + } + ], + "type": "User" + }, + { + "id": "-623130288", + "method": "account.getPrivacy", + "params": [ + { + "name": "key", + "type": "InputPrivacyKey" + } + ], + "type": "account.PrivacyRules" + }, + { + "id": "-906486552", + "method": "account.setPrivacy", + "params": [ + { + "name": "key", + "type": "InputPrivacyKey" + }, + { + "name": "rules", + "type": "Vector" + } + ], + "type": "account.PrivacyRules" + }, + { + "id": "1099779595", + "method": "account.deleteAccount", + "params": [ + { + "name": "reason", + "type": "string" + } + ], + "type": "Bool" + }, + { + "id": "150761757", + "method": "account.getAccountTTL", + "params": [], + "type": "AccountDaysTTL" + }, + { + "id": "608323678", + "method": "account.setAccountTTL", + "params": [ + { + "name": "ttl", + "type": "AccountDaysTTL" + } + ], + "type": "Bool" + }, + { + "id": "-627372787", + "method": "invokeWithLayer", + "params": [ + { + "name": "layer", + "type": "int" + }, + { + "name": "query", + "type": "!X" + } + ], + "type": "X" + }, + { + "id": "-113456221", + "method": "contacts.resolveUsername", + "params": [ + { + "name": "username", + "type": "string" + } + ], + "type": "contacts.ResolvedPeer" + }, + { + "id": "149257707", + "method": "account.sendChangePhoneCode", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "allow_flashcall", + "type": "flags.0?true" + }, + { + "name": "phone_number", + "type": "string" + }, + { + "name": "current_number", + "type": "flags.0?Bool" + } + ], + "type": "auth.SentCode" + }, + { + "id": "1891839707", + "method": "account.changePhone", + "params": [ + { + "name": "phone_number", + "type": "string" + }, + { + "name": "phone_code_hash", + "type": "string" + }, + { + "name": "phone_code", + "type": "string" + } + ], + "type": "User" + }, + { + "id": "479598769", + "method": "messages.getAllStickers", + "params": [ + { + "name": "hash", + "type": "int" + } + ], + "type": "messages.AllStickers" + }, + { + "id": "954152242", + "method": "account.updateDeviceLocked", + "params": [ + { + "name": "period", + "type": "int" + } + ], + "type": "Bool" + }, + { + "id": "1418342645", + "method": "account.getPassword", + "params": [], + "type": "account.Password" + }, + { + "id": "174260510", + "method": "auth.checkPassword", + "params": [ + { + "name": "password_hash", + "type": "bytes" + } + ], + "type": "auth.Authorization" + }, + { + "id": "623001124", + "method": "messages.getWebPagePreview", + "params": [ + { + "name": "message", + "type": "string" + } + ], + "type": "MessageMedia" + }, + { + "id": "-484392616", + "method": "account.getAuthorizations", + "params": [], + "type": "account.Authorizations" + }, + { + "id": "-545786948", + "method": "account.resetAuthorization", + "params": [ + { + "name": "hash", + "type": "long" + } + ], + "type": "Bool" + }, + { + "id": "-1131605573", + "method": "account.getPasswordSettings", + "params": [ + { + "name": "current_password_hash", + "type": "bytes" + } + ], + "type": "account.PasswordSettings" + }, + { + "id": "-92517498", + "method": "account.updatePasswordSettings", + "params": [ + { + "name": "current_password_hash", + "type": "bytes" + }, + { + "name": "new_settings", + "type": "account.PasswordInputSettings" + } + ], + "type": "Bool" + }, + { + "id": "-661144474", + "method": "auth.requestPasswordRecovery", + "params": [], + "type": "auth.PasswordRecovery" + }, + { + "id": "1319464594", + "method": "auth.recoverPassword", + "params": [ + { + "name": "code", + "type": "string" + } + ], + "type": "auth.Authorization" + }, + { + "id": "-1080796745", + "method": "invokeWithoutUpdates", + "params": [ + { + "name": "query", + "type": "!X" + } + ], + "type": "X" + }, + { + "id": "2106086025", + "method": "messages.exportChatInvite", + "params": [ + { + "name": "chat_id", + "type": "int" + } + ], + "type": "ExportedChatInvite" + }, + { + "id": "1051570619", + "method": "messages.checkChatInvite", + "params": [ + { + "name": "hash", + "type": "string" + } + ], + "type": "ChatInvite" + }, + { + "id": "1817183516", + "method": "messages.importChatInvite", + "params": [ + { + "name": "hash", + "type": "string" + } + ], + "type": "Updates" + }, + { + "id": "639215886", + "method": "messages.getStickerSet", + "params": [ + { + "name": "stickerset", + "type": "InputStickerSet" + } + ], + "type": "messages.StickerSet" + }, + { + "id": "-946871200", + "method": "messages.installStickerSet", + "params": [ + { + "name": "stickerset", + "type": "InputStickerSet" + }, + { + "name": "archived", + "type": "Bool" + } + ], + "type": "messages.StickerSetInstallResult" + }, + { + "id": "-110209570", + "method": "messages.uninstallStickerSet", + "params": [ + { + "name": "stickerset", + "type": "InputStickerSet" + } + ], + "type": "Bool" + }, + { + "id": "1738800940", + "method": "auth.importBotAuthorization", + "params": [ + { + "name": "flags", + "type": "int" + }, + { + "name": "api_id", + "type": "int" + }, + { + "name": "api_hash", + "type": "string" + }, + { + "name": "bot_auth_token", + "type": "string" + } + ], + "type": "auth.Authorization" + }, + { + "id": "-421563528", + "method": "messages.startBot", + "params": [ + { + "name": "bot", + "type": "InputUser" + }, + { + "name": "peer", + "type": "InputPeer" + }, + { + "name": "random_id", + "type": "long" + }, + { + "name": "start_param", + "type": "string" + } + ], + "type": "Updates" + }, + { + "id": "-1877938321", + "method": "help.getAppChangelog", + "params": [ + { + "name": "prev_app_version", + "type": "string" + } + ], + "type": "Updates" + }, + { + "id": "-820669733", + "method": "messages.reportSpam", + "params": [ + { + "name": "peer", + "type": "InputPeer" + } + ], + "type": "Bool" + }, + { + "id": "-993483427", + "method": "messages.getMessagesViews", + "params": [ + { + "name": "peer", + "type": "InputPeer" + }, + { + "name": "id", + "type": "Vector" + }, + { + "name": "increment", + "type": "Bool" + } + ], + "type": "Vector" + }, + { + "id": "51854712", + "method": "updates.getChannelDifference", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "force", + "type": "flags.0?true" + }, + { + "name": "channel", + "type": "InputChannel" + }, + { + "name": "filter", + "type": "ChannelMessagesFilter" + }, + { + "name": "pts", + "type": "int" + }, + { + "name": "limit", + "type": "int" + } + ], + "type": "updates.ChannelDifference" + }, + { + "id": "-871347913", + "method": "channels.readHistory", + "params": [ + { + "name": "channel", + "type": "InputChannel" + }, + { + "name": "max_id", + "type": "int" + } + ], + "type": "Bool" + }, + { + "id": "-2067661490", + "method": "channels.deleteMessages", + "params": [ + { + "name": "channel", + "type": "InputChannel" + }, + { + "name": "id", + "type": "Vector" + } + ], + "type": "messages.AffectedMessages" + }, + { + "id": "-787622117", + "method": "channels.deleteUserHistory", + "params": [ + { + "name": "channel", + "type": "InputChannel" + }, + { + "name": "user_id", + "type": "InputUser" + } + ], + "type": "messages.AffectedHistory" + }, + { + "id": "-32999408", + "method": "channels.reportSpam", + "params": [ + { + "name": "channel", + "type": "InputChannel" + }, + { + "name": "user_id", + "type": "InputUser" + }, + { + "name": "id", + "type": "Vector" + } + ], + "type": "Bool" + }, + { + "id": "-1814580409", + "method": "channels.getMessages", + "params": [ + { + "name": "channel", + "type": "InputChannel" + }, + { + "name": "id", + "type": "Vector" + } + ], + "type": "messages.Messages" + }, + { + "id": "306054633", + "method": "channels.getParticipants", + "params": [ + { + "name": "channel", + "type": "InputChannel" + }, + { + "name": "filter", + "type": "ChannelParticipantsFilter" + }, + { + "name": "offset", + "type": "int" + }, + { + "name": "limit", + "type": "int" + }, + { + "name": "hash", + "type": "int" + } + ], + "type": "channels.ChannelParticipants" + }, + { + "id": "1416484774", + "method": "channels.getParticipant", + "params": [ + { + "name": "channel", + "type": "InputChannel" + }, + { + "name": "user_id", + "type": "InputUser" + } + ], + "type": "channels.ChannelParticipant" + }, + { + "id": "176122811", + "method": "channels.getChannels", + "params": [ + { + "name": "id", + "type": "Vector" + } + ], + "type": "messages.Chats" + }, + { + "id": "141781513", + "method": "channels.getFullChannel", + "params": [ + { + "name": "channel", + "type": "InputChannel" + } + ], + "type": "messages.ChatFull" + }, + { + "id": "-192332417", + "method": "channels.createChannel", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "broadcast", + "type": "flags.0?true" + }, + { + "name": "megagroup", + "type": "flags.1?true" + }, + { + "name": "title", + "type": "string" + }, + { + "name": "about", + "type": "string" + } + ], + "type": "Updates" + }, + { + "id": "333610782", + "method": "channels.editAbout", + "params": [ + { + "name": "channel", + "type": "InputChannel" + }, + { + "name": "about", + "type": "string" + } + ], + "type": "Bool" + }, + { + "id": "548962836", + "method": "channels.editAdmin", + "params": [ + { + "name": "channel", + "type": "InputChannel" + }, + { + "name": "user_id", + "type": "InputUser" + }, + { + "name": "admin_rights", + "type": "ChannelAdminRights" + } + ], + "type": "Updates" + }, + { + "id": "1450044624", + "method": "channels.editTitle", + "params": [ + { + "name": "channel", + "type": "InputChannel" + }, + { + "name": "title", + "type": "string" + } + ], + "type": "Updates" + }, + { + "id": "-248621111", + "method": "channels.editPhoto", + "params": [ + { + "name": "channel", + "type": "InputChannel" + }, + { + "name": "photo", + "type": "InputChatPhoto" + } + ], + "type": "Updates" + }, + { + "id": "283557164", + "method": "channels.checkUsername", + "params": [ + { + "name": "channel", + "type": "InputChannel" + }, + { + "name": "username", + "type": "string" + } + ], + "type": "Bool" + }, + { + "id": "890549214", + "method": "channels.updateUsername", + "params": [ + { + "name": "channel", + "type": "InputChannel" + }, + { + "name": "username", + "type": "string" + } + ], + "type": "Bool" + }, + { + "id": "615851205", + "method": "channels.joinChannel", + "params": [ + { + "name": "channel", + "type": "InputChannel" + } + ], + "type": "Updates" + }, + { + "id": "-130635115", + "method": "channels.leaveChannel", + "params": [ + { + "name": "channel", + "type": "InputChannel" + } + ], + "type": "Updates" + }, + { + "id": "429865580", + "method": "channels.inviteToChannel", + "params": [ + { + "name": "channel", + "type": "InputChannel" + }, + { + "name": "users", + "type": "Vector" + } + ], + "type": "Updates" + }, + { + "id": "-950663035", + "method": "channels.exportInvite", + "params": [ + { + "name": "channel", + "type": "InputChannel" + } + ], + "type": "ExportedChatInvite" + }, + { + "id": "-1072619549", + "method": "channels.deleteChannel", + "params": [ + { + "name": "channel", + "type": "InputChannel" + } + ], + "type": "Updates" + }, + { + "id": "-326379039", + "method": "messages.toggleChatAdmins", + "params": [ + { + "name": "chat_id", + "type": "int" + }, + { + "name": "enabled", + "type": "Bool" + } + ], + "type": "Updates" + }, + { + "id": "-1444503762", + "method": "messages.editChatAdmin", + "params": [ + { + "name": "chat_id", + "type": "int" + }, + { + "name": "user_id", + "type": "InputUser" + }, + { + "name": "is_admin", + "type": "Bool" + } + ], + "type": "Bool" + }, + { + "id": "363051235", + "method": "messages.migrateChat", + "params": [ + { + "name": "chat_id", + "type": "int" + } + ], + "type": "Updates" + }, + { + "id": "-1640190800", + "method": "messages.searchGlobal", + "params": [ + { + "name": "q", + "type": "string" + }, + { + "name": "offset_date", + "type": "int" + }, + { + "name": "offset_peer", + "type": "InputPeer" + }, + { + "name": "offset_id", + "type": "int" + }, + { + "name": "limit", + "type": "int" + } + ], + "type": "messages.Messages" + }, + { + "id": "-1374118561", + "method": "account.reportPeer", + "params": [ + { + "name": "peer", + "type": "InputPeer" + }, + { + "name": "reason", + "type": "ReportReason" + } + ], + "type": "Bool" + }, + { + "id": "2016638777", + "method": "messages.reorderStickerSets", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "masks", + "type": "flags.0?true" + }, + { + "name": "order", + "type": "Vector" + } + ], + "type": "Bool" + }, + { + "id": "889286899", + "method": "help.getTermsOfService", + "params": [], + "type": "help.TermsOfService" + }, + { + "id": "864953444", + "method": "messages.getDocumentByHash", + "params": [ + { + "name": "sha256", + "type": "bytes" + }, + { + "name": "size", + "type": "int" + }, + { + "name": "mime_type", + "type": "string" + } + ], + "type": "Document" + }, + { + "id": "-1080395925", + "method": "messages.searchGifs", + "params": [ + { + "name": "q", + "type": "string" + }, + { + "name": "offset", + "type": "int" + } + ], + "type": "messages.FoundGifs" + }, + { + "id": "-2084618926", + "method": "messages.getSavedGifs", + "params": [ + { + "name": "hash", + "type": "int" + } + ], + "type": "messages.SavedGifs" + }, + { + "id": "846868683", + "method": "messages.saveGif", + "params": [ + { + "name": "id", + "type": "InputDocument" + }, + { + "name": "unsave", + "type": "Bool" + } + ], + "type": "Bool" + }, + { + "id": "1364105629", + "method": "messages.getInlineBotResults", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "bot", + "type": "InputUser" + }, + { + "name": "peer", + "type": "InputPeer" + }, + { + "name": "geo_point", + "type": "flags.0?InputGeoPoint" + }, + { + "name": "query", + "type": "string" + }, + { + "name": "offset", + "type": "string" + } + ], + "type": "messages.BotResults" + }, + { + "id": "-346119674", + "method": "messages.setInlineBotResults", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "gallery", + "type": "flags.0?true" + }, + { + "name": "private", + "type": "flags.1?true" + }, + { + "name": "query_id", + "type": "long" + }, + { + "name": "results", + "type": "Vector" + }, + { + "name": "cache_time", + "type": "int" + }, + { + "name": "next_offset", + "type": "flags.2?string" + }, + { + "name": "switch_pm", + "type": "flags.3?InlineBotSwitchPM" + } + ], + "type": "Bool" + }, + { + "id": "-1318189314", + "method": "messages.sendInlineBotResult", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "silent", + "type": "flags.5?true" + }, + { + "name": "background", + "type": "flags.6?true" + }, + { + "name": "clear_draft", + "type": "flags.7?true" + }, + { + "name": "peer", + "type": "InputPeer" + }, + { + "name": "reply_to_msg_id", + "type": "flags.0?int" + }, + { + "name": "random_id", + "type": "long" + }, + { + "name": "query_id", + "type": "long" + }, + { + "name": "id", + "type": "string" + } + ], + "type": "Updates" + }, + { + "id": "1231065863", + "method": "channels.toggleInvites", + "params": [ + { + "name": "channel", + "type": "InputChannel" + }, + { + "name": "enabled", + "type": "Bool" + } + ], + "type": "Updates" + }, + { + "id": "-826838685", + "method": "channels.exportMessageLink", + "params": [ + { + "name": "channel", + "type": "InputChannel" + }, + { + "name": "id", + "type": "int" + }, + { + "name": "grouped", + "type": "Bool" + } + ], + "type": "ExportedMessageLink" + }, + { + "id": "527021574", + "method": "channels.toggleSignatures", + "params": [ + { + "name": "channel", + "type": "InputChannel" + }, + { + "name": "enabled", + "type": "Bool" + } + ], + "type": "Updates" + }, + { + "id": "-1460572005", + "method": "messages.hideReportSpam", + "params": [ + { + "name": "peer", + "type": "InputPeer" + } + ], + "type": "Bool" + }, + { + "id": "913498268", + "method": "messages.getPeerSettings", + "params": [ + { + "name": "peer", + "type": "InputPeer" + } + ], + "type": "PeerSettings" + }, + { + "id": "-1490162350", + "method": "channels.updatePinnedMessage", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "silent", + "type": "flags.0?true" + }, + { + "name": "channel", + "type": "InputChannel" + }, + { + "name": "id", + "type": "int" + } + ], + "type": "Updates" + }, + { + "id": "1056025023", + "method": "auth.resendCode", + "params": [ + { + "name": "phone_number", + "type": "string" + }, + { + "name": "phone_code_hash", + "type": "string" + } + ], + "type": "auth.SentCode" + }, + { + "id": "520357240", + "method": "auth.cancelCode", + "params": [ + { + "name": "phone_number", + "type": "string" + }, + { + "name": "phone_code_hash", + "type": "string" + } + ], + "type": "Bool" + }, + { + "id": "-39416522", + "method": "messages.getMessageEditData", + "params": [ + { + "name": "peer", + "type": "InputPeer" + }, + { + "name": "id", + "type": "int" + } + ], + "type": "messages.MessageEditData" + }, + { + "id": "97630429", + "method": "messages.editMessage", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "no_webpage", + "type": "flags.1?true" + }, + { + "name": "stop_geo_live", + "type": "flags.12?true" + }, + { + "name": "peer", + "type": "InputPeer" + }, + { + "name": "id", + "type": "int" + }, + { + "name": "message", + "type": "flags.11?string" + }, + { + "name": "reply_markup", + "type": "flags.2?ReplyMarkup" + }, + { + "name": "entities", + "type": "flags.3?Vector" + }, + { + "name": "geo_point", + "type": "flags.13?InputGeoPoint" + } + ], + "type": "Updates" + }, + { + "id": "-1327463869", + "method": "messages.editInlineBotMessage", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "no_webpage", + "type": "flags.1?true" + }, + { + "name": "stop_geo_live", + "type": "flags.12?true" + }, + { + "name": "id", + "type": "InputBotInlineMessageID" + }, + { + "name": "message", + "type": "flags.11?string" + }, + { + "name": "reply_markup", + "type": "flags.2?ReplyMarkup" + }, + { + "name": "entities", + "type": "flags.3?Vector" + }, + { + "name": "geo_point", + "type": "flags.13?InputGeoPoint" + } + ], + "type": "Bool" + }, + { + "id": "-2130010132", + "method": "messages.getBotCallbackAnswer", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "game", + "type": "flags.1?true" + }, + { + "name": "peer", + "type": "InputPeer" + }, + { + "name": "msg_id", + "type": "int" + }, + { + "name": "data", + "type": "flags.0?bytes" + } + ], + "type": "messages.BotCallbackAnswer" + }, + { + "id": "-712043766", + "method": "messages.setBotCallbackAnswer", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "alert", + "type": "flags.1?true" + }, + { + "name": "query_id", + "type": "long" + }, + { + "name": "message", + "type": "flags.0?string" + }, + { + "name": "url", + "type": "flags.2?string" + }, + { + "name": "cache_time", + "type": "int" + } + ], + "type": "Bool" + }, + { + "id": "-728224331", + "method": "contacts.getTopPeers", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "correspondents", + "type": "flags.0?true" + }, + { + "name": "bots_pm", + "type": "flags.1?true" + }, + { + "name": "bots_inline", + "type": "flags.2?true" + }, + { + "name": "phone_calls", + "type": "flags.3?true" + }, + { + "name": "groups", + "type": "flags.10?true" + }, + { + "name": "channels", + "type": "flags.15?true" + }, + { + "name": "offset", + "type": "int" + }, + { + "name": "limit", + "type": "int" + }, + { + "name": "hash", + "type": "int" + } + ], + "type": "contacts.TopPeers" + }, + { + "id": "451113900", + "method": "contacts.resetTopPeerRating", + "params": [ + { + "name": "category", + "type": "TopPeerCategory" + }, + { + "name": "peer", + "type": "InputPeer" + } + ], + "type": "Bool" + }, + { + "id": "764901049", + "method": "messages.getPeerDialogs", + "params": [ + { + "name": "peers", + "type": "Vector" + } + ], + "type": "messages.PeerDialogs" + }, + { + "id": "-1137057461", + "method": "messages.saveDraft", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "no_webpage", + "type": "flags.1?true" + }, + { + "name": "reply_to_msg_id", + "type": "flags.0?int" + }, + { + "name": "peer", + "type": "InputPeer" + }, + { + "name": "message", + "type": "string" + }, + { + "name": "entities", + "type": "flags.3?Vector" + } + ], + "type": "Bool" + }, + { + "id": "1782549861", + "method": "messages.getAllDrafts", + "params": [], + "type": "Updates" + }, + { + "id": "353818557", + "method": "account.sendConfirmPhoneCode", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "allow_flashcall", + "type": "flags.0?true" + }, + { + "name": "hash", + "type": "string" + }, + { + "name": "current_number", + "type": "flags.0?Bool" + } + ], + "type": "auth.SentCode" + }, + { + "id": "1596029123", + "method": "account.confirmPhone", + "params": [ + { + "name": "phone_code_hash", + "type": "string" + }, + { + "name": "phone_code", + "type": "string" + } + ], + "type": "Bool" + }, + { + "id": "766298703", + "method": "messages.getFeaturedStickers", + "params": [ + { + "name": "hash", + "type": "int" + } + ], + "type": "messages.FeaturedStickers" + }, + { + "id": "1527873830", + "method": "messages.readFeaturedStickers", + "params": [ + { + "name": "id", + "type": "Vector" + } + ], + "type": "Bool" + }, + { + "id": "1587647177", + "method": "messages.getRecentStickers", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "attached", + "type": "flags.0?true" + }, + { + "name": "hash", + "type": "int" + } + ], + "type": "messages.RecentStickers" + }, + { + "id": "958863608", + "method": "messages.saveRecentSticker", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "attached", + "type": "flags.0?true" + }, + { + "name": "id", + "type": "InputDocument" + }, + { + "name": "unsave", + "type": "Bool" + } + ], + "type": "Bool" + }, + { + "id": "-1986437075", + "method": "messages.clearRecentStickers", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "attached", + "type": "flags.0?true" + } + ], + "type": "Bool" + }, + { + "id": "1475442322", + "method": "messages.getArchivedStickers", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "masks", + "type": "flags.0?true" + }, + { + "name": "offset_id", + "type": "long" + }, + { + "name": "limit", + "type": "int" + } + ], + "type": "messages.ArchivedStickers" + }, + { + "id": "-1920105769", + "method": "channels.getAdminedPublicChannels", + "params": [], + "type": "messages.Chats" + }, + { + "id": "-1907842680", + "method": "auth.dropTempAuthKeys", + "params": [ + { + "name": "except_auth_keys", + "type": "Vector" + } + ], + "type": "Bool" + }, + { + "id": "-1896289088", + "method": "messages.setGameScore", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "edit_message", + "type": "flags.0?true" + }, + { + "name": "force", + "type": "flags.1?true" + }, + { + "name": "peer", + "type": "InputPeer" + }, + { + "name": "id", + "type": "int" + }, + { + "name": "user_id", + "type": "InputUser" + }, + { + "name": "score", + "type": "int" + } + ], + "type": "Updates" + }, + { + "id": "363700068", + "method": "messages.setInlineGameScore", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "edit_message", + "type": "flags.0?true" + }, + { + "name": "force", + "type": "flags.1?true" + }, + { + "name": "id", + "type": "InputBotInlineMessageID" + }, + { + "name": "user_id", + "type": "InputUser" + }, + { + "name": "score", + "type": "int" + } + ], + "type": "Bool" + }, + { + "id": "1706608543", + "method": "messages.getMaskStickers", + "params": [ + { + "name": "hash", + "type": "int" + } + ], + "type": "messages.AllStickers" + }, + { + "id": "-866424884", + "method": "messages.getAttachedStickers", + "params": [ + { + "name": "media", + "type": "InputStickeredMedia" + } + ], + "type": "Vector" + }, + { + "id": "-400399203", + "method": "messages.getGameHighScores", + "params": [ + { + "name": "peer", + "type": "InputPeer" + }, + { + "name": "id", + "type": "int" + }, + { + "name": "user_id", + "type": "InputUser" + } + ], + "type": "messages.HighScores" + }, + { + "id": "258170395", + "method": "messages.getInlineGameHighScores", + "params": [ + { + "name": "id", + "type": "InputBotInlineMessageID" + }, + { + "name": "user_id", + "type": "InputUser" + } + ], + "type": "messages.HighScores" + }, + { + "id": "218777796", + "method": "messages.getCommonChats", + "params": [ + { + "name": "user_id", + "type": "InputUser" + }, + { + "name": "max_id", + "type": "int" + }, + { + "name": "limit", + "type": "int" + } + ], + "type": "messages.Chats" + }, + { + "id": "-341307408", + "method": "messages.getAllChats", + "params": [ + { + "name": "except_ids", + "type": "Vector" + } + ], + "type": "messages.Chats" + }, + { + "id": "-333262899", + "method": "help.setBotUpdatesStatus", + "params": [ + { + "name": "pending_updates_count", + "type": "int" + }, + { + "name": "message", + "type": "string" + } + ], + "type": "Bool" + }, + { + "id": "852135825", + "method": "messages.getWebPage", + "params": [ + { + "name": "url", + "type": "string" + }, + { + "name": "hash", + "type": "int" + } + ], + "type": "WebPage" + }, + { + "id": "847887978", + "method": "messages.toggleDialogPin", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "pinned", + "type": "flags.0?true" + }, + { + "name": "peer", + "type": "InputPeer" + } + ], + "type": "Bool" + }, + { + "id": "-1784678844", + "method": "messages.reorderPinnedDialogs", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "force", + "type": "flags.0?true" + }, + { + "name": "order", + "type": "Vector" + } + ], + "type": "Bool" + }, + { + "id": "-497756594", + "method": "messages.getPinnedDialogs", + "params": [], + "type": "messages.PeerDialogs" + }, + { + "id": "1536537556", + "method": "phone.requestCall", + "params": [ + { + "name": "user_id", + "type": "InputUser" + }, + { + "name": "random_id", + "type": "int" + }, + { + "name": "g_a_hash", + "type": "bytes" + }, + { + "name": "protocol", + "type": "PhoneCallProtocol" + } + ], + "type": "phone.PhoneCall" + }, + { + "id": "1003664544", + "method": "phone.acceptCall", + "params": [ + { + "name": "peer", + "type": "InputPhoneCall" + }, + { + "name": "g_b", + "type": "bytes" + }, + { + "name": "protocol", + "type": "PhoneCallProtocol" + } + ], + "type": "phone.PhoneCall" + }, + { + "id": "2027164582", + "method": "phone.discardCall", + "params": [ + { + "name": "peer", + "type": "InputPhoneCall" + }, + { + "name": "duration", + "type": "int" + }, + { + "name": "reason", + "type": "PhoneCallDiscardReason" + }, + { + "name": "connection_id", + "type": "long" + } + ], + "type": "Updates" + }, + { + "id": "399855457", + "method": "phone.receivedCall", + "params": [ + { + "name": "peer", + "type": "InputPhoneCall" + } + ], + "type": "Bool" + }, + { + "id": "1259113487", + "method": "messages.reportEncryptedSpam", + "params": [ + { + "name": "peer", + "type": "InputEncryptedChat" + } + ], + "type": "Bool" + }, + { + "id": "-1712285883", + "method": "payments.getPaymentForm", + "params": [ + { + "name": "msg_id", + "type": "int" + } + ], + "type": "payments.PaymentForm" + }, + { + "id": "730364339", + "method": "payments.sendPaymentForm", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "msg_id", + "type": "int" + }, + { + "name": "requested_info_id", + "type": "flags.0?string" + }, + { + "name": "shipping_option_id", + "type": "flags.1?string" + }, + { + "name": "credentials", + "type": "InputPaymentCredentials" + } + ], + "type": "payments.PaymentResult" + }, + { + "id": "1250046590", + "method": "account.getTmpPassword", + "params": [ + { + "name": "password_hash", + "type": "bytes" + }, + { + "name": "period", + "type": "int" + } + ], + "type": "account.TmpPassword" + }, + { + "id": "-436833542", + "method": "messages.setBotShippingResults", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "query_id", + "type": "long" + }, + { + "name": "error", + "type": "flags.0?string" + }, + { + "name": "shipping_options", + "type": "flags.1?Vector" + } + ], + "type": "Bool" + }, + { + "id": "163765653", + "method": "messages.setBotPrecheckoutResults", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "success", + "type": "flags.1?true" + }, + { + "name": "query_id", + "type": "long" + }, + { + "name": "error", + "type": "flags.0?string" + } + ], + "type": "Bool" + }, + { + "id": "619086221", + "method": "upload.getWebFile", + "params": [ + { + "name": "location", + "type": "InputWebFileLocation" + }, + { + "name": "offset", + "type": "int" + }, + { + "name": "limit", + "type": "int" + } + ], + "type": "upload.WebFile" + }, + { + "id": "-1440257555", + "method": "bots.sendCustomRequest", + "params": [ + { + "name": "custom_method", + "type": "string" + }, + { + "name": "params", + "type": "DataJSON" + } + ], + "type": "DataJSON" + }, + { + "id": "-434028723", + "method": "bots.answerWebhookJSONQuery", + "params": [ + { + "name": "query_id", + "type": "long" + }, + { + "name": "data", + "type": "DataJSON" + } + ], + "type": "Bool" + }, + { + "id": "-1601001088", + "method": "payments.getPaymentReceipt", + "params": [ + { + "name": "msg_id", + "type": "int" + } + ], + "type": "payments.PaymentReceipt" + }, + { + "id": "1997180532", + "method": "payments.validateRequestedInfo", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "save", + "type": "flags.0?true" + }, + { + "name": "msg_id", + "type": "int" + }, + { + "name": "info", + "type": "PaymentRequestedInfo" + } + ], + "type": "payments.ValidatedRequestedInfo" + }, + { + "id": "578650699", + "method": "payments.getSavedInfo", + "params": [], + "type": "payments.SavedInfo" + }, + { + "id": "-667062079", + "method": "payments.clearSavedInfo", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "credentials", + "type": "flags.0?true" + }, + { + "name": "info", + "type": "flags.1?true" + } + ], + "type": "Bool" + }, + { + "id": "1430593449", + "method": "phone.getCallConfig", + "params": [], + "type": "DataJSON" + }, + { + "id": "788404002", + "method": "phone.confirmCall", + "params": [ + { + "name": "peer", + "type": "InputPhoneCall" + }, + { + "name": "g_a", + "type": "bytes" + }, + { + "name": "key_fingerprint", + "type": "long" + }, + { + "name": "protocol", + "type": "PhoneCallProtocol" + } + ], + "type": "phone.PhoneCall" + }, + { + "id": "475228724", + "method": "phone.setCallRating", + "params": [ + { + "name": "peer", + "type": "InputPhoneCall" + }, + { + "name": "rating", + "type": "int" + }, + { + "name": "comment", + "type": "string" + } + ], + "type": "Updates" + }, + { + "id": "662363518", + "method": "phone.saveCallDebug", + "params": [ + { + "name": "peer", + "type": "InputPhoneCall" + }, + { + "name": "debug", + "type": "DataJSON" + } + ], + "type": "Bool" + }, + { + "id": "536919235", + "method": "upload.getCdnFile", + "params": [ + { + "name": "file_token", + "type": "bytes" + }, + { + "name": "offset", + "type": "int" + }, + { + "name": "limit", + "type": "int" + } + ], + "type": "upload.CdnFile" + }, + { + "id": "452533257", + "method": "upload.reuploadCdnFile", + "params": [ + { + "name": "file_token", + "type": "bytes" + }, + { + "name": "request_token", + "type": "bytes" + } + ], + "type": "Vector" + }, + { + "id": "1375900482", + "method": "help.getCdnConfig", + "params": [], + "type": "CdnConfig" + }, + { + "id": "1369162417", + "method": "messages.uploadMedia", + "params": [ + { + "name": "peer", + "type": "InputPeer" + }, + { + "name": "media", + "type": "InputMedia" + } + ], + "type": "MessageMedia" + }, + { + "id": "-1680314774", + "method": "stickers.createStickerSet", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "masks", + "type": "flags.0?true" + }, + { + "name": "user_id", + "type": "InputUser" + }, + { + "name": "title", + "type": "string" + }, + { + "name": "short_name", + "type": "string" + }, + { + "name": "stickers", + "type": "Vector" + } + ], + "type": "messages.StickerSet" + }, + { + "id": "-1699363442", + "method": "langpack.getLangPack", + "params": [ + { + "name": "lang_code", + "type": "string" + } + ], + "type": "LangPackDifference" + }, + { + "id": "773776152", + "method": "langpack.getStrings", + "params": [ + { + "name": "lang_code", + "type": "string" + }, + { + "name": "keys", + "type": "Vector" + } + ], + "type": "Vector" + }, + { + "id": "187583869", + "method": "langpack.getDifference", + "params": [ + { + "name": "from_version", + "type": "int" + } + ], + "type": "LangPackDifference" + }, + { + "id": "-2146445955", + "method": "langpack.getLanguages", + "params": [], + "type": "Vector" + }, + { + "id": "-1076292147", + "method": "channels.editBanned", + "params": [ + { + "name": "channel", + "type": "InputChannel" + }, + { + "name": "user_id", + "type": "InputUser" + }, + { + "name": "banned_rights", + "type": "ChannelBannedRights" + } + ], + "type": "Updates" + }, + { + "id": "870184064", + "method": "channels.getAdminLog", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "channel", + "type": "InputChannel" + }, + { + "name": "q", + "type": "string" + }, + { + "name": "events_filter", + "type": "flags.0?ChannelAdminLogEventsFilter" + }, + { + "name": "admins", + "type": "flags.1?Vector" + }, + { + "name": "max_id", + "type": "long" + }, + { + "name": "min_id", + "type": "long" + }, + { + "name": "limit", + "type": "int" + } + ], + "type": "channels.AdminLogResults" + }, + { + "id": "-143257775", + "method": "stickers.removeStickerFromSet", + "params": [ + { + "name": "sticker", + "type": "InputDocument" + } + ], + "type": "messages.StickerSet" + }, + { + "id": "-4795190", + "method": "stickers.changeStickerPosition", + "params": [ + { + "name": "sticker", + "type": "InputDocument" + }, + { + "name": "position", + "type": "int" + } + ], + "type": "messages.StickerSet" + }, + { + "id": "-2041315650", + "method": "stickers.addStickerToSet", + "params": [ + { + "name": "stickerset", + "type": "InputStickerSet" + }, + { + "name": "sticker", + "type": "InputStickerSetItem" + } + ], + "type": "messages.StickerSet" + }, + { + "id": "-914493408", + "method": "messages.sendScreenshotNotification", + "params": [ + { + "name": "peer", + "type": "InputPeer" + }, + { + "name": "reply_to_msg_id", + "type": "int" + }, + { + "name": "random_id", + "type": "long" + } + ], + "type": "Updates" + }, + { + "id": "-149567365", + "method": "upload.getCdnFileHashes", + "params": [ + { + "name": "file_token", + "type": "bytes" + }, + { + "name": "offset", + "type": "int" + } + ], + "type": "Vector" + }, + { + "id": "1180140658", + "method": "messages.getUnreadMentions", + "params": [ + { + "name": "peer", + "type": "InputPeer" + }, + { + "name": "offset_id", + "type": "int" + }, + { + "name": "add_offset", + "type": "int" + }, + { + "name": "limit", + "type": "int" + }, + { + "name": "max_id", + "type": "int" + }, + { + "name": "min_id", + "type": "int" + } + ], + "type": "messages.Messages" + }, + { + "id": "-1174420133", + "method": "messages.faveSticker", + "params": [ + { + "name": "id", + "type": "InputDocument" + }, + { + "name": "unfave", + "type": "Bool" + } + ], + "type": "Bool" + }, + { + "id": "-359881479", + "method": "channels.setStickers", + "params": [ + { + "name": "channel", + "type": "InputChannel" + }, + { + "name": "stickerset", + "type": "InputStickerSet" + } + ], + "type": "Bool" + }, + { + "id": "-2020263951", + "method": "contacts.resetSaved", + "params": [], + "type": "Bool" + }, + { + "id": "567151374", + "method": "messages.getFavedStickers", + "params": [ + { + "name": "hash", + "type": "int" + } + ], + "type": "messages.FavedStickers" + }, + { + "id": "-357180360", + "method": "channels.readMessageContents", + "params": [ + { + "name": "channel", + "type": "InputChannel" + }, + { + "name": "id", + "type": "Vector" + } + ], + "type": "Bool" + }, + { + "id": "613691874", + "method": "messages.getRecentLocations", + "params": [ + { + "name": "peer", + "type": "InputPeer" + }, + { + "name": "limit", + "type": "int" + } + ], + "type": "messages.Messages" + }, + { + "id": "251759059", + "method": "messages.readMentions", + "params": [ + { + "name": "peer", + "type": "InputPeer" + } + ], + "type": "messages.AffectedHistory" + }, + { + "id": "1036054804", + "method": "help.getRecentMeUrls", + "params": [ + { + "name": "referer", + "type": "string" + } + ], + "type": "help.RecentMeUrls" + }, + { + "id": "-1355375294", + "method": "channels.deleteHistory", + "params": [ + { + "name": "channel", + "type": "InputChannel" + }, + { + "name": "max_id", + "type": "int" + } + ], + "type": "Bool" + }, + { + "id": "-356796084", + "method": "channels.togglePreHistoryHidden", + "params": [ + { + "name": "channel", + "type": "InputChannel" + }, + { + "name": "enabled", + "type": "Bool" + } + ], + "type": "Updates" + }, + { + "id": "546656559", + "method": "messages.sendMultiMedia", + "params": [ + { + "name": "flags", + "type": "#" + }, + { + "name": "silent", + "type": "flags.5?true" + }, + { + "name": "background", + "type": "flags.6?true" + }, + { + "name": "clear_draft", + "type": "flags.7?true" + }, + { + "name": "peer", + "type": "InputPeer" + }, + { + "name": "reply_to_msg_id", + "type": "flags.0?int" + }, + { + "name": "multi_media", + "type": "Vector" + } + ], + "type": "Updates" + }, + { + "id": "1347929239", + "method": "messages.uploadEncryptedFile", + "params": [ + { + "name": "peer", + "type": "InputEncryptedChat" + }, + { + "name": "file", + "type": "InputEncryptedFile" + } + ], + "type": "EncryptedFile" + } + ] +} \ No newline at end of file From 8b392f515988d5b2a9feaec90a06b21059c591da Mon Sep 17 00:00:00 2001 From: Paulo Rogerio Panhoto Date: Thu, 1 Mar 2018 15:01:38 -0300 Subject: [PATCH 27/30] Rethrows BadMessageExceptions when parsing container messages. --- TLSharp.Core/Network/MtProtoSender.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/TLSharp.Core/Network/MtProtoSender.cs b/TLSharp.Core/Network/MtProtoSender.cs index 0b749438..2c96dcb9 100644 --- a/TLSharp.Core/Network/MtProtoSender.cs +++ b/TLSharp.Core/Network/MtProtoSender.cs @@ -573,6 +573,10 @@ private bool HandleContainer(ulong messageId, int sequence, BinaryReader message messageReader.BaseStream.Position = beginPosition + innerLength; } } + catch (BadMessageException e) + { + throw e; + } catch (Exception e) { logger.Debug($"failed to process message in contailer: {e}"); From 4c112086aac26275f0bf8be4a07494d5ec7bc4f9 Mon Sep 17 00:00:00 2001 From: Paulo Rogerio Panhoto Date: Thu, 1 Mar 2018 19:50:29 -0300 Subject: [PATCH 28/30] Adds another callback recurrent timed tasks. --- TLSharp.Core/TelegramClient.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/TLSharp.Core/TelegramClient.cs b/TLSharp.Core/TelegramClient.cs index e3f44920..91fd283b 100644 --- a/TLSharp.Core/TelegramClient.cs +++ b/TLSharp.Core/TelegramClient.cs @@ -37,7 +37,8 @@ public class TelegramClient : IDisposable public delegate void ClientEvent(TelegramClient source); public event UpdatesEvent Updates; - public event ClientEvent IdleLoop; + public event ClientEvent ScheduledTasks; + public event ClientEvent IdleTasks; public Session Session { get { return _session; } } @@ -148,12 +149,13 @@ public async Task MainLoopAsync(int timeslicems) await SendPingAsync(); lastPing = now; } - if (IdleLoop != null) + if (ScheduledTasks != null) { logger.Trace("Running idle tasks"); - IdleLoop.Invoke(this); - IdleLoop = null; + ScheduledTasks.Invoke(this); + ScheduledTasks = null; } + IdleTasks?.Invoke(this); } } } From 8180ee94f0ab468e63a9c610e8e4ec3ec7afe01c Mon Sep 17 00:00:00 2001 From: Paulo Rogerio Panhoto Date: Thu, 8 Mar 2018 16:38:30 -0300 Subject: [PATCH 29/30] sets the _looping flag to true right from the constructor so if Close() is called before the loop starts, the client will never loop for events. --- TLSharp.Core/TelegramClient.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/TLSharp.Core/TelegramClient.cs b/TLSharp.Core/TelegramClient.cs index 91fd283b..215e9b4c 100644 --- a/TLSharp.Core/TelegramClient.cs +++ b/TLSharp.Core/TelegramClient.cs @@ -31,7 +31,7 @@ public class TelegramClient : IDisposable private Session _session; private List dcOptions; private TcpClientConnectionHandler _handler; - private bool _looping; + private bool _looping = true; public delegate void UpdatesEvent (TelegramClient source, TLAbsUpdates updates); public delegate void ClientEvent(TelegramClient source); @@ -131,7 +131,6 @@ public async Task MainLoopAsync(int timeslicems) logger.Trace("Entered loop"); var lastPing = DateTime.UtcNow; await SendPingAsync(); - _looping = true; while (_looping) { try From 6836e563addc57bd3e0273333a3059306f928b7c Mon Sep 17 00:00:00 2001 From: Paulo Rogerio Panhoto Date: Mon, 12 Mar 2018 17:59:42 -0300 Subject: [PATCH 30/30] GetUserDialogsAsync() has new parameter offset so that when a dialogsSlice is received, the continuation can be asked for. --- TLSharp.Core/TelegramClient.cs | 816 ++++++++++++++++----------------- 1 file changed, 408 insertions(+), 408 deletions(-) diff --git a/TLSharp.Core/TelegramClient.cs b/TLSharp.Core/TelegramClient.cs index 215e9b4c..c2ee5c80 100644 --- a/TLSharp.Core/TelegramClient.cs +++ b/TLSharp.Core/TelegramClient.cs @@ -1,102 +1,102 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using TeleSharp.TL; -using TeleSharp.TL.Account; -using TeleSharp.TL.Auth; -using TeleSharp.TL.Contacts; -using TeleSharp.TL.Help; -using TeleSharp.TL.Messages; -using TeleSharp.TL.Upload; -using TLSharp.Core.Auth; -using TLSharp.Core.MTProto.Crypto; -using TLSharp.Core.Network; -using TLSharp.Core.Utils; -using TLAuthorization = TeleSharp.TL.Auth.TLAuthorization; - -namespace TLSharp.Core -{ - public class TelegramClient : IDisposable - { - internal static NLog.Logger logger = NLog.LogManager.GetLogger("TelegramClient"); - private MtProtoSender _sender; - private AuthKey _key; - private TcpTransport _transport; - private string _apiHash = ""; - private int _apiId = 0; - private Session _session; - private List dcOptions; - private TcpClientConnectionHandler _handler; - private bool _looping = true; - - public delegate void UpdatesEvent (TelegramClient source, TLAbsUpdates updates); - public delegate void ClientEvent(TelegramClient source); - - public event UpdatesEvent Updates; - public event ClientEvent ScheduledTasks; - public event ClientEvent IdleTasks; - - public Session Session { get { return _session; } } - - public volatile bool AllowEvents = false; - - public TelegramClient(int apiId, string apiHash, - Session session = null, string sessionUserId = "session", TcpClientConnectionHandler handler = null) - { - if (apiId == default(int)) - throw new MissingApiConfigurationException("API_ID"); - if (string.IsNullOrEmpty(apiHash)) - throw new MissingApiConfigurationException("API_HASH"); - - TLContext.Init(); - _apiHash = apiHash; - _apiId = apiId; - _handler = handler; - - _session = Session.GetSession(session?.Store ?? new FileSessionStore(), session?.SessionUserId ?? sessionUserId, session); - _transport = new TcpTransport(_session.ServerAddress, _session.Port, _handler); - } - - public async Task ConnectAsync(bool reconnect = false) - { - if (_session.AuthKey == null || reconnect) - { - var result = await Authenticator.DoAuthentication(_transport); - _session.AuthKey = result.AuthKey; - _session.TimeOffset = result.TimeOffset; - } - - _sender = new MtProtoSender(_transport, _session); - _sender.UpdatesEvent += _sender_UpdatesEvent; - - //set-up layer - var config = new TLRequestGetConfig(); - var request = new TLRequestInitConnection() - { - ApiId = _apiId, - AppVersion = "1.0.0", - DeviceModel = "PC", - LangCode = "en", - Query = config, - SystemVersion = "Win 10.0" - }; - var invokewithLayer = new TLRequestInvokeWithLayer() { Layer = 66, Query = request }; - await _sender.Send(invokewithLayer); - await _sender.Receive(invokewithLayer); - - dcOptions = ((TLConfig)invokewithLayer.Response).DcOptions.ToList(); - - return true; - } - - private async Task ReconnectToDcAsync(int dcId) - { - if (dcOptions == null || !dcOptions.Any()) - throw new InvalidOperationException($"Can't reconnect. Establish initial connection first."); +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Cryptography; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using TeleSharp.TL; +using TeleSharp.TL.Account; +using TeleSharp.TL.Auth; +using TeleSharp.TL.Contacts; +using TeleSharp.TL.Help; +using TeleSharp.TL.Messages; +using TeleSharp.TL.Upload; +using TLSharp.Core.Auth; +using TLSharp.Core.MTProto.Crypto; +using TLSharp.Core.Network; +using TLSharp.Core.Utils; +using TLAuthorization = TeleSharp.TL.Auth.TLAuthorization; + +namespace TLSharp.Core +{ + public class TelegramClient : IDisposable + { + internal static NLog.Logger logger = NLog.LogManager.GetLogger("TelegramClient"); + private MtProtoSender _sender; + private AuthKey _key; + private TcpTransport _transport; + private string _apiHash = ""; + private int _apiId = 0; + private Session _session; + private List dcOptions; + private TcpClientConnectionHandler _handler; + private bool _looping = true; + + public delegate void UpdatesEvent (TelegramClient source, TLAbsUpdates updates); + public delegate void ClientEvent(TelegramClient source); + + public event UpdatesEvent Updates; + public event ClientEvent ScheduledTasks; + public event ClientEvent IdleTasks; + + public Session Session { get { return _session; } } + + public volatile bool AllowEvents = false; + + public TelegramClient(int apiId, string apiHash, + Session session = null, string sessionUserId = "session", TcpClientConnectionHandler handler = null) + { + if (apiId == default(int)) + throw new MissingApiConfigurationException("API_ID"); + if (string.IsNullOrEmpty(apiHash)) + throw new MissingApiConfigurationException("API_HASH"); + + TLContext.Init(); + _apiHash = apiHash; + _apiId = apiId; + _handler = handler; + + _session = Session.GetSession(session?.Store ?? new FileSessionStore(), session?.SessionUserId ?? sessionUserId, session); + _transport = new TcpTransport(_session.ServerAddress, _session.Port, _handler); + } + + public async Task ConnectAsync(bool reconnect = false) + { + if (_session.AuthKey == null || reconnect) + { + var result = await Authenticator.DoAuthentication(_transport); + _session.AuthKey = result.AuthKey; + _session.TimeOffset = result.TimeOffset; + } + + _sender = new MtProtoSender(_transport, _session); + _sender.UpdatesEvent += _sender_UpdatesEvent; + + //set-up layer + var config = new TLRequestGetConfig(); + var request = new TLRequestInitConnection() + { + ApiId = _apiId, + AppVersion = "1.0.0", + DeviceModel = "PC", + LangCode = "en", + Query = config, + SystemVersion = "Win 10.0" + }; + var invokewithLayer = new TLRequestInvokeWithLayer() { Layer = 66, Query = request }; + await _sender.Send(invokewithLayer); + await _sender.Receive(invokewithLayer); + + dcOptions = ((TLConfig)invokewithLayer.Response).DcOptions.ToList(); + + return true; + } + + private async Task ReconnectToDcAsync(int dcId) + { + if (dcOptions == null || !dcOptions.Any()) + throw new InvalidOperationException($"Can't reconnect. Establish initial connection first."); TLExportedAuthorization exported = null; if (_session.TLUser != null) @@ -104,13 +104,13 @@ private async Task ReconnectToDcAsync(int dcId) TLRequestExportAuthorization exportAuthorization = new TLRequestExportAuthorization() { DcId = dcId }; exported = await SendRequestAsync(exportAuthorization); } - - var dc = dcOptions.First(d => d.Id == dcId); - - _transport = new TcpTransport(dc.IpAddress, dc.Port, _handler); - _session.ServerAddress = dc.IpAddress; - _session.Port = dc.Port; - + + var dc = dcOptions.First(d => d.Id == dcId); + + _transport = new TcpTransport(dc.IpAddress, dc.Port, _handler); + _session.ServerAddress = dc.IpAddress; + _session.Port = dc.Port; + await ConnectAsync(true); if (_session.TLUser != null) @@ -118,264 +118,264 @@ private async Task ReconnectToDcAsync(int dcId) TLRequestImportAuthorization importAuthorization = new TLRequestImportAuthorization() { Id = exported.Id, Bytes = exported.Bytes }; var imported = await SendRequestAsync(importAuthorization); OnUserAuthenticated(((TLUser)imported.User)); - } - } - - public void Close() - { - _looping = false; - } - - public async Task MainLoopAsync(int timeslicems) + } + } + + public void Close() { - logger.Trace("Entered loop"); - var lastPing = DateTime.UtcNow; - await SendPingAsync(); - while (_looping) - { - try + _looping = false; + } + + public async Task MainLoopAsync(int timeslicems) + { + logger.Trace("Entered loop"); + var lastPing = DateTime.UtcNow; + await SendPingAsync(); + while (_looping) + { + try + { + await WaitEventAsync(timeslicems); + } catch (OperationCanceledException) { - await WaitEventAsync(timeslicems); - } catch (OperationCanceledException) - { - logger.Trace("Timeout"); - } - finally - { - var now = DateTime.UtcNow; - if ((now - lastPing).TotalSeconds >= 30) - { - await SendPingAsync(); - lastPing = now; - } + logger.Trace("Timeout"); + } + finally + { + var now = DateTime.UtcNow; + if ((now - lastPing).TotalSeconds >= 30) + { + await SendPingAsync(); + lastPing = now; + } if (ScheduledTasks != null) { logger.Trace("Running idle tasks"); ScheduledTasks.Invoke(this); ScheduledTasks = null; - } - IdleTasks?.Invoke(this); - } - } - } - - private void _sender_UpdatesEvent (TLAbsUpdates updates) - { - if (AllowEvents && Updates != null) - Updates(this, updates); - } - + } + IdleTasks?.Invoke(this); + } + } + } + + private void _sender_UpdatesEvent (TLAbsUpdates updates) + { + if (AllowEvents && Updates != null) + Updates(this, updates); + } + private async Task RequestWithDcMigration(TLMethod request) { - var completed = false; - while(!completed) - { - try - { - await _sender.Send(request); - await _sender.Receive(request); - completed = true; - } - catch(DataCenterMigrationException e) - { - await ReconnectToDcAsync(e.DC); - // prepare the request for another try - request.ConfirmReceived = false; - } + var completed = false; + while(!completed) + { + try + { + await _sender.Send(request); + await _sender.Receive(request); + completed = true; + } + catch(DataCenterMigrationException e) + { + await ReconnectToDcAsync(e.DC); + // prepare the request for another try + request.ConfirmReceived = false; + } } - } - - public async Task WaitEventAsync(int timeoutms) - { - await _sender.Receive (timeoutms); - } - - public bool IsUserAuthorized() - { - return _session.TLUser != null; - } - - public async Task IsPhoneRegisteredAsync(string phoneNumber) - { - if (String.IsNullOrWhiteSpace(phoneNumber)) - throw new ArgumentNullException(nameof(phoneNumber)); - - if (_sender == null) - throw new InvalidOperationException("Not connected!"); - - var authCheckPhoneRequest = new TLRequestCheckPhone() { PhoneNumber = phoneNumber }; - - await RequestWithDcMigration(authCheckPhoneRequest); - - return authCheckPhoneRequest.Response.PhoneRegistered; - } - - public async Task SendCodeRequestAsync(string phoneNumber) - { - if (String.IsNullOrWhiteSpace(phoneNumber)) - throw new ArgumentNullException(nameof(phoneNumber)); - - var request = new TLRequestSendCode() { PhoneNumber = phoneNumber, ApiId = _apiId, ApiHash = _apiHash }; - - await RequestWithDcMigration(request); - - return request.Response.PhoneCodeHash; - } - - public async Task MakeAuthAsync(string phoneNumber, string phoneCodeHash, string code) - { - if (String.IsNullOrWhiteSpace(phoneNumber)) - throw new ArgumentNullException(nameof(phoneNumber)); - - if (String.IsNullOrWhiteSpace(phoneCodeHash)) - throw new ArgumentNullException(nameof(phoneCodeHash)); - - if (String.IsNullOrWhiteSpace(code)) - throw new ArgumentNullException(nameof(code)); - + } + + public async Task WaitEventAsync(int timeoutms) + { + await _sender.Receive (timeoutms); + } + + public bool IsUserAuthorized() + { + return _session.TLUser != null; + } + + public async Task IsPhoneRegisteredAsync(string phoneNumber) + { + if (String.IsNullOrWhiteSpace(phoneNumber)) + throw new ArgumentNullException(nameof(phoneNumber)); + + if (_sender == null) + throw new InvalidOperationException("Not connected!"); + + var authCheckPhoneRequest = new TLRequestCheckPhone() { PhoneNumber = phoneNumber }; + + await RequestWithDcMigration(authCheckPhoneRequest); + + return authCheckPhoneRequest.Response.PhoneRegistered; + } + + public async Task SendCodeRequestAsync(string phoneNumber) + { + if (String.IsNullOrWhiteSpace(phoneNumber)) + throw new ArgumentNullException(nameof(phoneNumber)); + + var request = new TLRequestSendCode() { PhoneNumber = phoneNumber, ApiId = _apiId, ApiHash = _apiHash }; + + await RequestWithDcMigration(request); + + return request.Response.PhoneCodeHash; + } + + public async Task MakeAuthAsync(string phoneNumber, string phoneCodeHash, string code) + { + if (String.IsNullOrWhiteSpace(phoneNumber)) + throw new ArgumentNullException(nameof(phoneNumber)); + + if (String.IsNullOrWhiteSpace(phoneCodeHash)) + throw new ArgumentNullException(nameof(phoneCodeHash)); + + if (String.IsNullOrWhiteSpace(code)) + throw new ArgumentNullException(nameof(code)); + var request = new TLRequestSignIn() { PhoneNumber = phoneNumber, PhoneCodeHash = phoneCodeHash, PhoneCode = code }; - await RequestWithDcMigration(request); - - OnUserAuthenticated(((TLUser)request.Response.User)); - - return ((TLUser)request.Response.User); - } - - public async Task GetPasswordSetting() - { - var request = new TLRequestGetPassword(); - - await RequestWithDcMigration(request); - - return ((TLPassword)request.Response); - } - - public async Task MakeAuthWithPasswordAsync(TLPassword password, string password_str) - { - - byte[] password_Bytes = Encoding.UTF8.GetBytes(password_str); - IEnumerable rv = password.CurrentSalt.Concat(password_Bytes).Concat(password.CurrentSalt); - - SHA256Managed hashstring = new SHA256Managed(); - var password_hash = hashstring.ComputeHash(rv.ToArray()); - - var request = new TLRequestCheckPassword() { PasswordHash = password_hash }; - - await RequestWithDcMigration(request); - - OnUserAuthenticated(((TLUser)request.Response.User)); - - return ((TLUser)request.Response.User); - } - - public async Task SignUpAsync(string phoneNumber, string phoneCodeHash, string code, string firstName, string lastName) - { - var request = new TLRequestSignUp() { PhoneNumber = phoneNumber, PhoneCode = code, PhoneCodeHash = phoneCodeHash, FirstName = firstName, LastName = lastName }; - - await RequestWithDcMigration(request); - - OnUserAuthenticated(((TLUser)request.Response.User)); - - return ((TLUser)request.Response.User); - } - public async Task SendRequestAsync(TLMethod methodToExecute) - { - logger.Info("Sending Request: {0} {1:x8}", methodToExecute, methodToExecute.Constructor); - await RequestWithDcMigration(methodToExecute); - - var result = methodToExecute.GetType().GetProperty("Response").GetValue(methodToExecute); - - return (T)result; - } - - public async Task GetContactsAsync() - { - if (!IsUserAuthorized()) - throw new InvalidOperationException("Authorize user first!"); - - var req = new TLRequestGetContacts() { Hash = "" }; - - return await SendRequestAsync(req); - } - - public async Task SendMessageAsync(TLAbsInputPeer peer, string message) - { - if (!IsUserAuthorized()) - throw new InvalidOperationException("Authorize user first!"); - - return await SendRequestAsync( - new TLRequestSendMessage() - { - Peer = peer, - Message = message, - RandomId = Helpers.GenerateRandomLong() - }); - } - - public async Task SendTypingAsync(TLAbsInputPeer peer) - { - var req = new TLRequestSetTyping() - { - Action = new TLSendMessageTypingAction(), - Peer = peer - }; - return await SendRequestAsync(req); - } - - public async Task GetUserDialogsAsync() - { - var peer = new TLInputPeerSelf(); - return await SendRequestAsync( - new TLRequestGetDialogs() { OffsetDate = 0, OffsetPeer = peer, Limit = 100 }); - } - - public async Task SendUploadedPhoto(TLAbsInputPeer peer, TLAbsInputFile file, string caption) - { - return await SendRequestAsync(new TLRequestSendMedia() - { - RandomId = Helpers.GenerateRandomLong(), - Background = false, - ClearDraft = false, - Media = new TLInputMediaUploadedPhoto() { File = file, Caption = caption }, - Peer = peer - }); - } - - public async Task SendUploadedDocument( - TLAbsInputPeer peer, TLAbsInputFile file, string caption, string mimeType, TLVector attributes) - { - return await SendRequestAsync(new TLRequestSendMedia() - { - RandomId = Helpers.GenerateRandomLong(), - Background = false, - ClearDraft = false, - Media = new TLInputMediaUploadedDocument() - { - File = file, - Caption = caption, - MimeType = mimeType, - Attributes = attributes - }, - Peer = peer - }); - } - - public async Task GetFile(TLAbsInputFileLocation location, int filePartSize, int offset = 0) - { - TLFile result = null; - result = await SendRequestAsync(new TLRequestGetFile() - { - Location = location, - Limit = filePartSize, - Offset = offset - }); - return result; - } - - public async Task SendPingAsync() - { - await _sender.SendPingAsync(); + await RequestWithDcMigration(request); + + OnUserAuthenticated(((TLUser)request.Response.User)); + + return ((TLUser)request.Response.User); + } + + public async Task GetPasswordSetting() + { + var request = new TLRequestGetPassword(); + + await RequestWithDcMigration(request); + + return ((TLPassword)request.Response); + } + + public async Task MakeAuthWithPasswordAsync(TLPassword password, string password_str) + { + + byte[] password_Bytes = Encoding.UTF8.GetBytes(password_str); + IEnumerable rv = password.CurrentSalt.Concat(password_Bytes).Concat(password.CurrentSalt); + + SHA256Managed hashstring = new SHA256Managed(); + var password_hash = hashstring.ComputeHash(rv.ToArray()); + + var request = new TLRequestCheckPassword() { PasswordHash = password_hash }; + + await RequestWithDcMigration(request); + + OnUserAuthenticated(((TLUser)request.Response.User)); + + return ((TLUser)request.Response.User); + } + + public async Task SignUpAsync(string phoneNumber, string phoneCodeHash, string code, string firstName, string lastName) + { + var request = new TLRequestSignUp() { PhoneNumber = phoneNumber, PhoneCode = code, PhoneCodeHash = phoneCodeHash, FirstName = firstName, LastName = lastName }; + + await RequestWithDcMigration(request); + + OnUserAuthenticated(((TLUser)request.Response.User)); + + return ((TLUser)request.Response.User); + } + public async Task SendRequestAsync(TLMethod methodToExecute) + { + logger.Info("Sending Request: {0} {1:x8}", methodToExecute, methodToExecute.Constructor); + await RequestWithDcMigration(methodToExecute); + + var result = methodToExecute.GetType().GetProperty("Response").GetValue(methodToExecute); + + return (T)result; + } + + public async Task GetContactsAsync() + { + if (!IsUserAuthorized()) + throw new InvalidOperationException("Authorize user first!"); + + var req = new TLRequestGetContacts() { Hash = "" }; + + return await SendRequestAsync(req); + } + + public async Task SendMessageAsync(TLAbsInputPeer peer, string message) + { + if (!IsUserAuthorized()) + throw new InvalidOperationException("Authorize user first!"); + + return await SendRequestAsync( + new TLRequestSendMessage() + { + Peer = peer, + Message = message, + RandomId = Helpers.GenerateRandomLong() + }); + } + + public async Task SendTypingAsync(TLAbsInputPeer peer) + { + var req = new TLRequestSetTyping() + { + Action = new TLSendMessageTypingAction(), + Peer = peer + }; + return await SendRequestAsync(req); + } + + public async Task GetUserDialogsAsync(int offset = 0) + { + var peer = new TLInputPeerSelf(); + return await SendRequestAsync( + new TLRequestGetDialogs() { OffsetDate = offset, OffsetPeer = peer, Limit = 100 }); + } + + public async Task SendUploadedPhoto(TLAbsInputPeer peer, TLAbsInputFile file, string caption) + { + return await SendRequestAsync(new TLRequestSendMedia() + { + RandomId = Helpers.GenerateRandomLong(), + Background = false, + ClearDraft = false, + Media = new TLInputMediaUploadedPhoto() { File = file, Caption = caption }, + Peer = peer + }); + } + + public async Task SendUploadedDocument( + TLAbsInputPeer peer, TLAbsInputFile file, string caption, string mimeType, TLVector attributes) + { + return await SendRequestAsync(new TLRequestSendMedia() + { + RandomId = Helpers.GenerateRandomLong(), + Background = false, + ClearDraft = false, + Media = new TLInputMediaUploadedDocument() + { + File = file, + Caption = caption, + MimeType = mimeType, + Attributes = attributes + }, + Peer = peer + }); + } + + public async Task GetFile(TLAbsInputFileLocation location, int filePartSize, int offset = 0) + { + TLFile result = null; + result = await SendRequestAsync(new TLRequestGetFile() + { + Location = location, + Limit = filePartSize, + Offset = offset + }); + return result; + } + + public async Task SendPingAsync() + { + await _sender.SendPingAsync(); } public async Task GetHistoryAsync(TLAbsInputPeer peer, int offset, int max_id, int limit) @@ -391,31 +391,31 @@ public async Task GetHistoryAsync(TLAbsInputPeer peer, int offset Limit = limit }; return await SendRequestAsync(req); - } - - /// - /// Serch user or chat. API: contacts.search#11f812d8 q:string limit:int = contacts.Found; - /// - /// User or chat name - /// Max result count - /// - public async Task SearchUserAsync(string q, int limit = 10) - { - var r = new TeleSharp.TL.Contacts.TLRequestSearch - { - Q = q, - Limit = limit - }; - - return await SendRequestAsync(r); - } - - private void OnUserAuthenticated(TLUser TLUser) - { - _session.TLUser = TLUser; - _session.SessionExpires = int.MaxValue; - - _session.Save(); + } + + /// + /// Serch user or chat. API: contacts.search#11f812d8 q:string limit:int = contacts.Found; + /// + /// User or chat name + /// Max result count + /// + public async Task SearchUserAsync(string q, int limit = 10) + { + var r = new TeleSharp.TL.Contacts.TLRequestSearch + { + Q = q, + Limit = limit + }; + + return await SendRequestAsync(r); + } + + private void OnUserAuthenticated(TLUser TLUser) + { + _session.TLUser = TLUser; + _session.SessionExpires = int.MaxValue; + + _session.Save(); } public bool IsConnected @@ -426,34 +426,34 @@ public bool IsConnected return false; return _transport.IsConnected; } - } - - public void Dispose() - { - if (_transport != null) - { - _transport.Dispose(); - _transport = null; - } - } - } - - public class MissingApiConfigurationException : Exception - { - public const string InfoUrl = "https://github.com/sochix/TLSharp#quick-configuration"; - - internal MissingApiConfigurationException(string invalidParamName) : - base($"Your {invalidParamName} setting is missing. Adjust the configuration first, see {InfoUrl}") - { - } - } - - public class InvalidPhoneCodeException : Exception - { - internal InvalidPhoneCodeException(string msg) : base(msg) { } - } - public class CloudPasswordNeededException : Exception - { - internal CloudPasswordNeededException(string msg) : base(msg) { } - } -} + } + + public void Dispose() + { + if (_transport != null) + { + _transport.Dispose(); + _transport = null; + } + } + } + + public class MissingApiConfigurationException : Exception + { + public const string InfoUrl = "https://github.com/sochix/TLSharp#quick-configuration"; + + internal MissingApiConfigurationException(string invalidParamName) : + base($"Your {invalidParamName} setting is missing. Adjust the configuration first, see {InfoUrl}") + { + } + } + + public class InvalidPhoneCodeException : Exception + { + internal InvalidPhoneCodeException(string msg) : base(msg) { } + } + public class CloudPasswordNeededException : Exception + { + internal CloudPasswordNeededException(string msg) : base(msg) { } + } +}