From 72fba5540726efa5aa1862e7e6490197bd89a8b1 Mon Sep 17 00:00:00 2001 From: Wizou <11647984+wiz0u@users.noreply.github.com> Date: Thu, 3 Feb 2022 16:55:16 +0100 Subject: [PATCH] Upgrade to layer 138 --- .github/dev.yml | 2 +- README.md | 2 +- src/Client.cs | 22 +++----- src/TL.Schema.cs | 133 ++++++++++++++++++++++++++++++++++++++++------- src/TL.Table.cs | 12 +++-- 5 files changed, 128 insertions(+), 43 deletions(-) diff --git a/.github/dev.yml b/.github/dev.yml index a366488..5dd6d81 100644 --- a/.github/dev.yml +++ b/.github/dev.yml @@ -2,7 +2,7 @@ pr: none trigger: - master -name: 2.0.1-dev.$(Rev:r) +name: 2.0.2-dev.$(Rev:r) pool: vmImage: ubuntu-latest diff --git a/README.md b/README.md index 9f78092..f9afbb7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![NuGet version](https://img.shields.io/nuget/v/WTelegramClient)](https://www.nuget.org/packages/WTelegramClient/) [![Build Status](https://img.shields.io/azure-devops/build/wiz0u/WTelegramClient/7)](https://dev.azure.com/wiz0u/WTelegramClient/_build?definitionId=7) -[![API Layer](https://img.shields.io/badge/API_Layer-137-blueviolet)](https://corefork.telegram.org/methods) +[![API Layer](https://img.shields.io/badge/API_Layer-138-blueviolet)](https://corefork.telegram.org/methods) [![dev nuget](https://img.shields.io/badge/dynamic/json?color=ffc040&label=dev%20nuget&query=%24.versions%5B0%5D&url=https%3A%2F%2Fpkgs.dev.azure.com%2Fwiz0u%2F81bd92b7-0bb9-4701-b426-09090b27e037%2F_packaging%2F46ce0497-7803-4bd4-8c6c-030583e7c371%2Fnuget%2Fv3%2Fflat2%2Fwtelegramclient%2Findex.json)](https://dev.azure.com/wiz0u/WTelegramClient/_packaging?_a=package&feed=WTelegramClient&package=WTelegramClient&protocolType=NuGet) [![Support Chat](https://img.shields.io/badge/Chat_with_us-on_Telegram-0088cc)](https://t.me/WTelegramClient) [![Donate](https://img.shields.io/badge/Help_this_project:-Donate-ff4444)](http://wizou.fr/donate.html) diff --git a/src/Client.cs b/src/Client.cs index e379ac5..18647d4 100644 --- a/src/Client.cs +++ b/src/Client.cs @@ -182,7 +182,7 @@ namespace WTelegram { } _cts?.Cancel(); - _sendSemaphore = new(0); + _sendSemaphore = new(0); // initially taken, first released during DoConnectAsync _reactorTask = null; _networkStream?.Close(); _tcpClient?.Dispose(); @@ -815,26 +815,16 @@ namespace WTelegram } else { - string typeName; var ctorNb = reader.ReadUInt32(); if (ctorNb == Layer.VectorCtor) { reader.BaseStream.Position -= 4; - var array = reader.ReadTLVector(typeof(IObject[])); - if (array.Length > 0) - { - for (type = array.GetValue(0).GetType(); type.BaseType != typeof(object);) type = type.BaseType; - typeName = type.Name + "[]"; - } - else - typeName = "object[]"; - result = array; - } - else - { - result = reader.ReadTLObject(ctorNb); - typeName = result?.GetType().Name; + result = reader.ReadTLVector(typeof(IObject[])); } + else if (ctorNb == (uint)Bool.False) result = false; + else if (ctorNb == (uint)Bool.True) result = true; + else result = reader.ReadTLObject(ctorNb); + var typeName = result?.GetType().Name; if (MsgIdToStamp(msgId) >= _session.SessionStart) Helpers.Log(4, $" → {typeName,-37} for unknown msgId #{(short)msgId.GetHashCode():X4}"); else diff --git a/src/TL.Schema.cs b/src/TL.Schema.cs index e91dab6..fc6b444 100644 --- a/src/TL.Schema.cs +++ b/src/TL.Schema.cs @@ -2065,7 +2065,7 @@ namespace TL public abstract int TopMessage { get; } } /// Chat See - [TLDef(0x2C171F72)] + [TLDef(0xA8EDD0F5)] public class Dialog : DialogBase { /// Flags, see TL conditional fields @@ -2082,6 +2082,7 @@ namespace TL public int unread_count; /// Number of unread mentions public int unread_mentions_count; + public int unread_reactions_count; /// Notification settings public PeerNotifySettings notify_settings; /// PTS @@ -5897,6 +5898,7 @@ namespace TL has_thumbs = 0x10, /// Is this an animated stickerpack animated = 0x20, + gifs = 0x40, } } @@ -12472,42 +12474,33 @@ namespace TL } /// Message reactions See - [TLDef(0x087B6E36)] + [TLDef(0x4F2B9479)] public class MessageReactions : IObject { /// Flags, see TL conditional fields public Flags flags; /// Reactions public ReactionCount[] results; - [IfFlag(1)] public MessageUserReaction[] recent_reactons; + [IfFlag(1)] public MessagePeerReaction[] recent_reactions; [Flags] public enum Flags { /// Similar to min objects, used for message reaction constructors that are the same for all users so they don't have the reactions sent by the current user (you can use messages.getMessagesReactions to get the full reaction info). min = 0x1, - /// Field has a value - has_recent_reactons = 0x2, + /// Field has a value + has_recent_reactions = 0x2, can_see_list = 0x4, } } - /// Message reaction See - [TLDef(0x932844FA)] - public class MessageUserReaction : IObject - { - /// ID of user that reacted this way - public long user_id; - /// Reaction (UTF8 emoji) - public string reaction; - } - /// See - [TLDef(0xA366923C)] - public class Messages_MessageReactionsList : IObject + [TLDef(0x31BD492D)] + public class Messages_MessageReactionsList : IObject, IPeerResolver { public Flags flags; public int count; - public MessageUserReaction[] reactions; + public MessagePeerReaction[] reactions; + public Dictionary chats; public Dictionary users; [IfFlag(0)] public string next_offset; @@ -12516,6 +12509,8 @@ namespace TL /// Field has a value has_next_offset = 0x1, } + /// returns a or for the given Peer + public IPeerInfo UserOrChat(Peer peer) => peer.UserOrChat(users, chats); } /// See @@ -12550,6 +12545,34 @@ namespace TL public AvailableReaction[] reactions; } + /// See + public abstract class Messages_TranslatedText : IObject { } + /// See + [TLDef(0x67CA4737)] + public class Messages_TranslateNoResult : Messages_TranslatedText { } + /// See + [TLDef(0xA214F7D0)] + public class Messages_TranslateResultText : Messages_TranslatedText + { + public string text; + } + + /// Message reaction See + [TLDef(0x51B67EFF)] + public class MessagePeerReaction : IObject + { + public Flags flags; + public Peer peer_id; + /// Reaction (UTF8 emoji) + public string reaction; + + [Flags] public enum Flags + { + big = 0x1, + unread = 0x2, + } + } + // ---functions--- public static class SchemaExtensions @@ -15475,10 +15498,10 @@ namespace TL /// Peer /// Message ID to react to /// Reaction (a UTF8 emoji) - public static Task Messages_SendReaction(this Client client, InputPeer peer, int msg_id, string reaction = null) + public static Task Messages_SendReaction(this Client client, InputPeer peer, int msg_id, bool big = false, string reaction = null) => client.Invoke(new Messages_SendReaction { - flags = (Messages_SendReaction.Flags)(reaction != null ? 0x1 : 0), + flags = (Messages_SendReaction.Flags)((big ? 0x2 : 0) | (reaction != null ? 0x1 : 0)), peer = peer, msg_id = msg_id, reaction = reaction, @@ -15534,6 +15557,37 @@ namespace TL reaction = reaction, }); + /// See + public static Task Messages_TranslateText(this Client client, string to_lang, InputPeer peer = null, int? msg_id = null, string text = null, string from_lang = null) + => client.Invoke(new Messages_TranslateText + { + flags = (Messages_TranslateText.Flags)((peer != null ? 0x1 : 0) | (msg_id != null ? 0x1 : 0) | (text != null ? 0x2 : 0) | (from_lang != null ? 0x4 : 0)), + peer = peer, + msg_id = msg_id.GetValueOrDefault(), + text = text, + from_lang = from_lang, + to_lang = to_lang, + }); + + /// See + public static Task Messages_GetUnreadReactions(this Client client, InputPeer peer, int offset_id, int add_offset, int limit, int max_id, int min_id) + => client.Invoke(new Messages_GetUnreadReactions + { + peer = peer, + offset_id = offset_id, + add_offset = add_offset, + limit = limit, + max_id = max_id, + min_id = min_id, + }); + + /// See + public static Task Messages_ReadReactions(this Client client, InputPeer peer) + => client.Invoke(new Messages_ReadReactions + { + peer = peer, + }); + /// Returns a current state of updates. See [bots: ✓] public static Task Updates_GetState(this Client client) => client.Invoke(new Updates_GetState @@ -19442,6 +19496,7 @@ namespace TL.Methods { /// Field has a value has_reaction = 0x1, + big = 0x2, } } @@ -19490,6 +19545,44 @@ namespace TL.Methods public string reaction; } + [TLDef(0x24CE6DEE)] + public class Messages_TranslateText : IMethod + { + public Flags flags; + [IfFlag(0)] public InputPeer peer; + [IfFlag(0)] public int msg_id; + [IfFlag(1)] public string text; + [IfFlag(2)] public string from_lang; + public string to_lang; + + [Flags] public enum Flags + { + /// Field has a value + has_peer = 0x1, + /// Field has a value + has_text = 0x2, + /// Field has a value + has_from_lang = 0x4, + } + } + + [TLDef(0xE85BAE1A)] + public class Messages_GetUnreadReactions : IMethod + { + public InputPeer peer; + public int offset_id; + public int add_offset; + public int limit; + public int max_id; + public int min_id; + } + + [TLDef(0x82E251D7)] + public class Messages_ReadReactions : IMethod + { + public InputPeer peer; + } + [TLDef(0xEDD4882A)] public class Updates_GetState : IMethod { } diff --git a/src/TL.Table.cs b/src/TL.Table.cs index c3b76d2..0b08d76 100644 --- a/src/TL.Table.cs +++ b/src/TL.Table.cs @@ -7,7 +7,7 @@ namespace TL { public static class Layer { - public const int Version = 137; // fetched 19/01/2022 20:17:41 + public const int Version = 138; // fetched 31/01/2022 22:18:08 internal const uint VectorCtor = 0x1CB5C415; internal const uint NullCtor = 0x56730BCC; internal const uint RpcResultCtor = 0xF35C6D01; @@ -186,7 +186,7 @@ namespace TL [0xB3A07661] = typeof(MessageActionGroupCallScheduled), [0xAA786345] = typeof(MessageActionSetChatTheme), [0xEBBCA3CB] = typeof(MessageActionChatJoinedByRequest), - [0x2C171F72] = typeof(Dialog), + [0xA8EDD0F5] = typeof(Dialog), [0x71BD134C] = typeof(DialogFolder), [0x2331B22D] = typeof(PhotoEmpty), [0xFB197A65] = typeof(Photo), @@ -934,12 +934,14 @@ namespace TL [0x6880B94D] = typeof(Messages_PeerSettings), [0xC3A2835F] = typeof(Auth_LoggedOut), [0x6FB250D1] = typeof(ReactionCount), - [0x087B6E36] = typeof(MessageReactions), - [0x932844FA] = typeof(MessageUserReaction), - [0xA366923C] = typeof(Messages_MessageReactionsList), + [0x4F2B9479] = typeof(MessageReactions), + [0x31BD492D] = typeof(Messages_MessageReactionsList), [0xC077EC01] = typeof(AvailableReaction), [0x9F071957] = null,//Messages_AvailableReactionsNotModified [0x768E3AAD] = typeof(Messages_AvailableReactions), + [0x67CA4737] = typeof(Messages_TranslateNoResult), + [0xA214F7D0] = typeof(Messages_TranslateResultText), + [0x51B67EFF] = typeof(MessagePeerReaction), // from TL.Secret: [0xBB718624] = typeof(Layer66.SendMessageUploadRoundAction), [0xE50511D8] = typeof(Layer45.DecryptedMessageMediaWebPage),