From c9ccaf2d17b85ca5a28344d0f2854c35fbb4e431 Mon Sep 17 00:00:00 2001 From: Wizou Date: Sat, 23 Oct 2021 01:37:50 +0200 Subject: [PATCH] More helpers (reordered), notably UserOrChat --- EXAMPLES.md | 4 +- Examples/Program_ListenUpdates.cs | 2 +- src/Generator.cs | 28 ++- src/Helpers.TL.cs | 350 ++++++++++++++++++++---------- src/TL.Schema.cs | 57 ++++- 5 files changed, 318 insertions(+), 123 deletions(-) diff --git a/EXAMPLES.md b/EXAMPLES.md index 6a0ce0e..4694d10 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -76,14 +76,14 @@ if (dialogsBase is Messages_Dialogs dialogs) while (dialogs.dialogs.Length != 0) { foreach (var dialog in dialogs.dialogs) - switch (dialogs.GetUserOrChat(dialog)) + switch (dialogs.UserOrChat(dialog)) { case UserBase user when user.IsActive: Console.WriteLine("User " + user); break; case ChatBase chat when chat.IsActive: Console.WriteLine(chat); break; } var lastDialog = dialogs.dialogs[^1]; var lastMsg = dialogs.messages.LastOrDefault(m => m.Peer.ID == lastDialog.Peer.ID && m.ID == lastDialog.TopMessage); - var offsetPeer = dialogs.GetUserOrChat(lastDialog).ToInputPeer(); + var offsetPeer = dialogs.UserOrChat(lastDialog).ToInputPeer(); dialogs = (Messages_Dialogs)await client.Messages_GetDialogs(lastMsg?.Date ?? default, lastDialog.TopMessage, offsetPeer, 500, 0); } ``` diff --git a/Examples/Program_ListenUpdates.cs b/Examples/Program_ListenUpdates.cs index 4e5de83..eb158c1 100644 --- a/Examples/Program_ListenUpdates.cs +++ b/Examples/Program_ListenUpdates.cs @@ -28,7 +28,7 @@ namespace WTelegramClientTest foreach (var (id, chat) in dialogs.chats) chats[id] = chat; var lastDialog = dialogs.dialogs[^1]; var lastMsg = dialogs.messages.LastOrDefault(m => m.Peer.ID == lastDialog.Peer.ID && m.ID == lastDialog.TopMessage); - var offsetPeer = dialogs.GetUserOrChat(lastDialog).ToInputPeer(); + var offsetPeer = dialogs.UserOrChat(lastDialog).ToInputPeer(); dialogs = (Messages_Dialogs)await client.Messages_GetDialogs(lastMsg?.Date ?? default, lastDialog.TopMessage, offsetPeer, 500, 0); } Console.ReadKey(); diff --git a/src/Generator.cs b/src/Generator.cs index 0d3f3b2..252d9d0 100644 --- a/src/Generator.cs +++ b/src/Generator.cs @@ -180,6 +180,7 @@ namespace WTelegram typeInfo.Structs.Insert(0, typeInfo.MainClass); typeInfo.ReturnName = typeInfo.MainClass.predicate; } + typeInfo.AbstractUserOrChat = AbstractUserOrChatTypes.Contains(typeInfo.ReturnName); } } var layers = schema.constructors.Select(c => c.layer).Distinct().ToList(); @@ -320,14 +321,14 @@ namespace WTelegram } sw.Write(" : "); sw.Write(parentClass); - if (parms.Length == 0) + if (parms.Length == 0 && !typeInfo.AbstractUserOrChat) { sw.WriteLine(" { }"); commonFields = typeInfo.CommonFields; continue; } var hasFlagEnum = parms.Any(p => p.type.StartsWith("flags.")); - bool multiline = hasFlagEnum || parms.Length > 1; + bool multiline = hasFlagEnum || parms.Length > 1 || typeInfo.AbstractUserOrChat; if (multiline) { sw.WriteLine(); @@ -380,6 +381,20 @@ namespace WTelegram } if (multiline) sw.WriteLine(); } + var hasUsersChats = parms.Contains(ParamUsers) && parms.Contains(ParamChats); + if (hasUsersChats || (typeInfo.AbstractUserOrChat && (ctor == typeInfo.MainClass || parentClass == typeInfo.ReturnName))) + { + var modifier = !typeInfo.AbstractUserOrChat ? null : ctorId == 0 ? "abstract " : "override "; + sw.Write($"{tabIndent}\tpublic {modifier}IPeerInfo UserOrChat"); + if (!hasUsersChats || ctor.@params.Length != 3 || !parms.Contains(ParamPeer)) + sw.Write("(Peer peer)"); + if (modifier == "abstract ") + sw.WriteLine(";"); + else if (hasUsersChats) + sw.WriteLine(" => peer.UserOrChat(users, chats);"); + else + sw.WriteLine(" => null;"); + } if (multiline) sw.WriteLine(tabIndent + "}"); @@ -388,6 +403,12 @@ namespace WTelegram commonFields = typeInfo.CommonFields; } } + static readonly Param ParamPeer = new() { name = "peer", type = "Peer" }; + static readonly Param ParamUsers = new() { name = "users", type = "Vector" }; + static readonly Param ParamChats = new() { name = "chats", type = "Vector" }; + static readonly HashSet AbstractUserOrChatTypes = new() { + "Messages_MessagesBase", "Updates_DifferenceBase", "Updates_ChannelDifferenceBase" + }; private static bool IsDerivedName(string derived, string basename) { @@ -715,6 +736,7 @@ namespace WTelegram public List Structs = new(); internal int CommonFields; // n fields are common among all those classes internal bool AsEnum; + internal bool AbstractUserOrChat; } #pragma warning disable IDE1006 // Naming Styles @@ -739,6 +761,8 @@ namespace WTelegram { public string name { get; set; } public string type { get; set; } + public override bool Equals(object obj) => obj is Param other && other.name == name && other.type == type; + public override int GetHashCode() => HashCode.Combine(name, type); } public class Method diff --git a/src/Helpers.TL.cs b/src/Helpers.TL.cs index d88ca10..863e00b 100644 --- a/src/Helpers.TL.cs +++ b/src/Helpers.TL.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; @@ -6,15 +7,82 @@ using System.Web; namespace TL { - partial class InputPeer { public static InputPeerSelf Self => new(); } - partial class InputUser { public static InputUserSelf Self => new(); } - - public interface IPeerInfo { + public interface IPeerInfo + { long ID { get; } bool IsActive { get; } InputPeer ToInputPeer(); } + partial class InputPeer { public static InputPeerSelf Self => new(); } + partial class InputUser { public static InputUserSelf Self => new(); } + + partial class InputFileBase + { + public abstract InputEncryptedFileBase ToInputEncryptedFile(int key_fingerprint); + public abstract InputSecureFileBase ToInputSecureFile(byte[] file_hash, byte[] secret); + } + partial class InputFile + { + public override InputEncryptedFileBase ToInputEncryptedFile(int key_fingerprint) => new InputEncryptedFileUploaded { id = id, parts = parts, md5_checksum = md5_checksum, key_fingerprint = key_fingerprint }; + public override InputSecureFileBase ToInputSecureFile(byte[] file_hash, byte[] secret) => new InputSecureFileUploaded { id = id, parts = parts, md5_checksum = md5_checksum, file_hash = file_hash, secret = secret }; + } + partial class InputFileBig + { + public override InputEncryptedFileBase ToInputEncryptedFile(int key_fingerprint) => new InputEncryptedFileBigUploaded { id = id, parts = parts, key_fingerprint = key_fingerprint }; + public override InputSecureFileBase ToInputSecureFile(byte[] file_hash, byte[] secret) => new InputSecureFileUploaded { id = id, parts = parts, file_hash = file_hash, secret = secret }; + } + + partial class Peer + { + public abstract long ID { get; } + abstract internal IPeerInfo UserOrChat(Dictionary users, Dictionary chats); + } + partial class PeerUser + { + public override string ToString() => "user " + user_id; + public override long ID => user_id; + internal override IPeerInfo UserOrChat(Dictionary users, Dictionary chats) => users[user_id]; + } + partial class PeerChat + { + public override string ToString() => "chat " + chat_id; + public override long ID => chat_id; + internal override IPeerInfo UserOrChat(Dictionary users, Dictionary chats) => chats[chat_id]; + } + partial class PeerChannel + { + public override string ToString() => "channel " + channel_id; + public override long ID => channel_id; + internal override IPeerInfo UserOrChat(Dictionary users, Dictionary chats) => chats[channel_id]; + } + + partial class UserBase : IPeerInfo + { + public abstract long ID { get; } + public abstract bool IsActive { get; } + public abstract InputPeer ToInputPeer(); + protected abstract InputUserBase ToInputUser(); + public static implicit operator InputPeer(UserBase user) => user.ToInputPeer(); + public static implicit operator InputUserBase(UserBase user) => user.ToInputUser(); + } + partial class UserEmpty + { + public override long ID => id; + public override bool IsActive => false; + public override string ToString() => null; + public override InputPeer ToInputPeer() => null; + protected override InputUserBase ToInputUser() => null; + } + partial class User + { + public override long ID => id; + public override bool IsActive => (flags & Flags.deleted) == 0; + public override string ToString() => username != null ? '@' + username : last_name == null ? first_name : $"{first_name} {last_name}"; + public override InputPeer ToInputPeer() => new InputPeerUser { user_id = id, access_hash = access_hash }; + protected override InputUserBase ToInputUser() => new InputUser { user_id = id, access_hash = access_hash }; + } + partial class ChatBase : IPeerInfo { public abstract long ID { get; } @@ -73,79 +141,24 @@ namespace TL public override string ToString() => $"ChannelForbidden {id} \"{title}\""; } - partial class UserBase : IPeerInfo + partial class ChatParticipantBase { - public abstract long ID { get; } - public abstract bool IsActive { get; } - public abstract InputPeer ToInputPeer(); - protected abstract InputUserBase ToInputUser(); - public static implicit operator InputPeer(UserBase user) => user.ToInputPeer(); - public static implicit operator InputUserBase(UserBase user) => user.ToInputUser(); + public abstract long UserId { get; } + public abstract bool IsAdmin { get; } } - partial class UserEmpty + partial class ChatParticipant { - public override long ID => id; - public override bool IsActive => false; - public override string ToString() => null; - public override InputPeer ToInputPeer() => null; - protected override InputUserBase ToInputUser() => null; + public override long UserId => user_id; + public override bool IsAdmin => false; } - partial class User + partial class ChatParticipantCreator { - public override long ID => id; - public override bool IsActive => (flags & Flags.deleted) == 0; - public override string ToString() => username != null ? '@' + username : last_name == null ? first_name : $"{first_name} {last_name}"; - public override InputPeer ToInputPeer() => new InputPeerUser { user_id = id, access_hash = access_hash }; - protected override InputUserBase ToInputUser() => new InputUser { user_id = id, access_hash = access_hash }; + public override long UserId => user_id; + public override bool IsAdmin => true; } - - partial class Peer { public abstract long ID { get; } } - partial class PeerUser { public override long ID => user_id; public override string ToString() => "user " + user_id; } - partial class PeerChat { public override long ID => chat_id; public override string ToString() => "chat " + chat_id; } - partial class PeerChannel { public override long ID => channel_id; public override string ToString() => "channel " + channel_id; } - - partial class Contacts_ResolvedPeer + partial class ChatParticipantAdmin { - public static implicit operator InputPeer(Contacts_ResolvedPeer resolved) => resolved.UserOrChat.ToInputPeer(); - public UserBase User => peer is PeerUser pu ? users[pu.user_id] : null; - public ChatBase Chat => peer is PeerChat or PeerChannel ? chats[peer.ID] : null; - public IPeerInfo UserOrChat => peer switch - { - PeerUser pu => users[pu.user_id], - PeerChat pc => chats[pc.chat_id], - PeerChannel pch => chats[pch.channel_id], - _ => null - }; - } - - partial class DialogBase - { - public abstract Peer Peer { get; } - public abstract int TopMessage { get; } - } - partial class Dialog - { - public override Peer Peer => peer; - public override int TopMessage => top_message; - } - partial class DialogFolder - { - public override Peer Peer => peer; - public override int TopMessage => top_message; - } - - partial class Messages_Dialogs - { - /// Find the matching User/Chat object for a dialog - /// The dialog which peer we want details on - /// a UserBase or ChatBase derived instance - public IPeerInfo GetUserOrChat(DialogBase dialog) => dialog.Peer switch - { - PeerUser pu => users[pu.user_id], - PeerChat pc => chats[pc.chat_id], - PeerChannel pch => chats[pch.channel_id], - _ => null, - }; + public override bool IsAdmin => true; } partial class MessageBase @@ -173,6 +186,22 @@ namespace TL public override DateTime Date => date; } + partial class DialogBase + { + public abstract Peer Peer { get; } + public abstract int TopMessage { get; } + } + partial class Dialog + { + public override Peer Peer => peer; + public override int TopMessage => top_message; + } + partial class DialogFolder + { + public override Peer Peer => peer; + public override int TopMessage => top_message; + } + partial class PhotoBase { public abstract long ID { get; } @@ -261,6 +290,83 @@ namespace TL } } + partial class Contacts_Blocked { public IPeerInfo UserOrChat(PeerBlocked peer) => peer.peer_id.UserOrChat(users, chats); } + + partial class Messages_Dialogs + { + /// Find the matching User/Chat object for a dialog + /// The dialog which peer we want details on + /// a UserBase or ChatBase derived instance + public IPeerInfo UserOrChat(DialogBase dialog) => dialog.Peer.UserOrChat(users, chats); + } + + partial class Messages_MessagesBase + { + public abstract int Count { get; } + public abstract MessageBase[] Messages { get; } + } + partial class Messages_Messages + { + public override int Count => messages.Length; + public override MessageBase[] Messages => messages; + } + partial class Messages_MessagesSlice + { + public override int Count => count; + } + partial class Messages_ChannelMessages + { + public override int Count => count; + public override MessageBase[] Messages => messages; + } + partial class Messages_MessagesNotModified + { + public override int Count => count; + public override MessageBase[] Messages => null; + } + + partial class Updates_DifferenceBase + { + public abstract MessageBase[] NewMessages { get; } + public abstract EncryptedMessageBase[] NewEncryptedMessages { get; } + public abstract Update[] OtherUpdates { get; } + public abstract Updates_State State { get; } + } + partial class Updates_DifferenceEmpty + { + public override MessageBase[] NewMessages => Array.Empty(); + public override EncryptedMessageBase[] NewEncryptedMessages => Array.Empty(); + public override Update[] OtherUpdates => Array.Empty(); + public override Updates_State State => null; + } + partial class Updates_Difference + { + public override MessageBase[] NewMessages => new_messages; + public override EncryptedMessageBase[] NewEncryptedMessages => new_encrypted_messages; + public override Update[] OtherUpdates => other_updates; + public override Updates_State State => state; + } + partial class Updates_DifferenceSlice + { + public override MessageBase[] NewMessages => new_messages; + public override EncryptedMessageBase[] NewEncryptedMessages => new_encrypted_messages; + public override Update[] OtherUpdates => other_updates; + public override Updates_State State => intermediate_state; + } + partial class Updates_DifferenceTooLong + { + public override MessageBase[] NewMessages => null; + public override EncryptedMessageBase[] NewEncryptedMessages => null; + public override Update[] OtherUpdates => null; + public override Updates_State State => null; + } + + partial class EncryptedFile + { + public static implicit operator InputEncryptedFile(EncryptedFile file) => file == null ? null : new InputEncryptedFile { id = file.id, access_hash = file.access_hash }; + public InputEncryptedFileLocation ToFileLocation() => new() { id = id, access_hash = access_hash }; + } + partial class DocumentBase { public abstract long ID { get; } @@ -279,10 +385,68 @@ namespace TL public InputDocumentFileLocation ToFileLocation(PhotoSizeBase thumbSize = null) => new() { id = id, access_hash = access_hash, file_reference = file_reference, thumb_size = thumbSize?.Type }; } - partial class EncryptedFile + partial class SendMessageAction { - public static implicit operator InputEncryptedFile(EncryptedFile file) => file == null ? null : new InputEncryptedFile { id = file.id, access_hash = file.access_hash }; - public InputEncryptedFileLocation ToFileLocation() => new() { id = id, access_hash = access_hash }; + public override string ToString() + { + var type = GetType().Name[11..^6]; + for (int i = 1; i < type.Length; i++) + if (char.IsUpper(type[i])) + return type.ToLowerInvariant().Insert(i, "ing "); + return type.ToLowerInvariant(); + } + } + partial class SpeakingInGroupCallAction { public override string ToString() => "speaking in group call"; } + partial class SendMessageTypingAction { public override string ToString() => "typing"; } + partial class SendMessageCancelAction { public override string ToString() => "stopping"; } + partial class SendMessageGeoLocationAction { public override string ToString() => "selecting a location"; } + partial class SendMessageGamePlayAction { public override string ToString() => "playing a game"; } + partial class SendMessageHistoryImportAction { public override string ToString() => "importing history"; } + + partial class StickerSet + { + public static implicit operator InputStickerSetID(StickerSet stickerSet) => new() { id = stickerSet.id, access_hash = stickerSet.access_hash }; + } + + partial class Contacts_ResolvedPeer + { + public static implicit operator InputPeer(Contacts_ResolvedPeer resolved) => resolved.UserOrChat.ToInputPeer(); + public UserBase User => peer is PeerUser pu ? users[pu.user_id] : null; + public ChatBase Chat => peer is PeerChat or PeerChannel ? chats[peer.ID] : null; + } + + partial class Updates_ChannelDifferenceBase + { + public abstract MessageBase[] NewMessages { get; } + public abstract Update[] OtherUpdates { get; } + public abstract bool Final { get; } + public abstract int Timeout { get; } + } + partial class Updates_ChannelDifferenceEmpty + { + public override MessageBase[] NewMessages => Array.Empty(); + public override Update[] OtherUpdates => Array.Empty(); + public override bool Final => flags.HasFlag(Flags.final); + public override int Timeout => timeout; + } + partial class Updates_ChannelDifference + { + public override MessageBase[] NewMessages => new_messages; + public override Update[] OtherUpdates => other_updates; + public override bool Final => flags.HasFlag(Flags.final); + public override int Timeout => timeout; + } + partial class Updates_ChannelDifferenceTooLong + { + public override MessageBase[] NewMessages => messages; + public override Update[] OtherUpdates => null; + public override bool Final => flags.HasFlag(Flags.final); + public override int Timeout => timeout; + } + + partial class Messages_PeerDialogs + { + public IPeerInfo UserOrChat(DialogBase dialog) => UserOrChat(dialog.Peer); } partial class SecureFile @@ -291,27 +455,6 @@ namespace TL public InputSecureFileLocation ToFileLocation() => new() { id = id, access_hash = access_hash }; } - partial class InputFileBase - { - public abstract InputEncryptedFileBase ToInputEncryptedFile(int key_fingerprint); - public abstract InputSecureFileBase ToInputSecureFile(byte[] file_hash, byte[] secret); - } - partial class InputFile - { - public override InputEncryptedFileBase ToInputEncryptedFile(int key_fingerprint) => new InputEncryptedFileUploaded { id = id, parts = parts, md5_checksum = md5_checksum, key_fingerprint = key_fingerprint }; - public override InputSecureFileBase ToInputSecureFile(byte[] file_hash, byte[] secret) => new InputSecureFileUploaded { id = id, parts = parts, md5_checksum = md5_checksum, file_hash = file_hash, secret = secret }; - } - partial class InputFileBig - { - public override InputEncryptedFileBase ToInputEncryptedFile(int key_fingerprint) => new InputEncryptedFileBigUploaded { id = id, parts = parts, key_fingerprint = key_fingerprint }; - public override InputSecureFileBase ToInputSecureFile(byte[] file_hash, byte[] secret) => new InputSecureFileUploaded { id = id, parts = parts, file_hash = file_hash, secret = secret }; - } - - partial class StickerSet - { - public static implicit operator InputStickerSetID(StickerSet stickerSet) => new() { id = stickerSet.id, access_hash = stickerSet.access_hash }; - } - partial class JsonObjectValue { public override string ToString() => $"{HttpUtility.JavaScriptStringEncode(key, true)}:{value}"; } partial class JsonNull { public override string ToString() => "null"; } partial class JsonBool { public override string ToString() => value ? "true" : "false"; } @@ -337,23 +480,4 @@ namespace TL return sb.Append('}').ToString(); } } - - partial class SendMessageAction - { - public override string ToString() - { - var type = GetType().Name[11..^6]; - for (int i = 1; i < type.Length; i++) - if (char.IsUpper(type[i])) - return type.ToLowerInvariant().Insert(i, "ing "); - return type.ToLowerInvariant(); - } - } - partial class SpeakingInGroupCallAction { public override string ToString() => "speaking in group call"; } - partial class SendMessageTypingAction { public override string ToString() => "typing"; } - partial class SendMessageCancelAction { public override string ToString() => "stopping"; } - partial class SendMessageGeoLocationAction { public override string ToString() => "selecting a location"; } - partial class SendMessageGamePlayAction { public override string ToString() => "playing a game"; } - partial class SendMessageHistoryImportAction{ public override string ToString() => "importing history"; } - } diff --git a/src/TL.Schema.cs b/src/TL.Schema.cs index b397204..35b9a80 100644 --- a/src/TL.Schema.cs +++ b/src/TL.Schema.cs @@ -1278,6 +1278,7 @@ namespace TL public PeerBlocked[] blocked; public Dictionary chats; public Dictionary users; + public IPeerInfo UserOrChat(Peer peer) => peer.UserOrChat(users, chats); } ///See [TLDef(0xE1664194, inheritAfter = true)] @@ -1293,6 +1294,7 @@ namespace TL public MessageBase[] messages; public Dictionary chats; public Dictionary users; + public IPeerInfo UserOrChat(Peer peer) => peer.UserOrChat(users, chats); } ///See [TLDef(0x71E094F3, inheritAfter = true)] @@ -1302,7 +1304,10 @@ namespace TL public partial class Messages_DialogsNotModified : Messages_DialogsBase { public int count; } ///See - public abstract partial class Messages_MessagesBase : ITLObject { } + public abstract partial class Messages_MessagesBase : ITLObject + { + public abstract IPeerInfo UserOrChat(Peer peer); + } ///See [TLDef(0x8C718E87)] public partial class Messages_Messages : Messages_MessagesBase @@ -1310,6 +1315,7 @@ namespace TL public MessageBase[] messages; public Dictionary chats; public Dictionary users; + public override IPeerInfo UserOrChat(Peer peer) => peer.UserOrChat(users, chats); } ///See [TLDef(0x3A54685E, inheritAfter = true)] @@ -1333,10 +1339,15 @@ namespace TL public MessageBase[] messages; public Dictionary chats; public Dictionary users; + public override IPeerInfo UserOrChat(Peer peer) => peer.UserOrChat(users, chats); } ///See [TLDef(0x74535F21)] - public partial class Messages_MessagesNotModified : Messages_MessagesBase { public int count; } + public partial class Messages_MessagesNotModified : Messages_MessagesBase + { + public int count; + public override IPeerInfo UserOrChat(Peer peer) => null; + } ///See [TLDef(0x64FF9FD5)] @@ -1352,6 +1363,7 @@ namespace TL public ChatFullBase full_chat; public Dictionary chats; public Dictionary users; + public IPeerInfo UserOrChat(Peer peer) => peer.UserOrChat(users, chats); } ///See @@ -2088,13 +2100,17 @@ namespace TL } ///See - public abstract partial class Updates_DifferenceBase : ITLObject { } + public abstract partial class Updates_DifferenceBase : ITLObject + { + public abstract IPeerInfo UserOrChat(Peer peer); + } ///See [TLDef(0x5D75A138)] public partial class Updates_DifferenceEmpty : Updates_DifferenceBase { public DateTime date; public int seq; + public override IPeerInfo UserOrChat(Peer peer) => null; } ///See [TLDef(0x00F49CA0)] @@ -2106,6 +2122,7 @@ namespace TL public Dictionary chats; public Dictionary users; public Updates_State state; + public override IPeerInfo UserOrChat(Peer peer) => peer.UserOrChat(users, chats); } ///See [TLDef(0xA8FB1981)] @@ -2117,10 +2134,15 @@ namespace TL public Dictionary chats; public Dictionary users; public Updates_State intermediate_state; + public override IPeerInfo UserOrChat(Peer peer) => peer.UserOrChat(users, chats); } ///See [TLDef(0x4AFE8F6D)] - public partial class Updates_DifferenceTooLong : Updates_DifferenceBase { public int pts; } + public partial class Updates_DifferenceTooLong : Updates_DifferenceBase + { + public int pts; + public override IPeerInfo UserOrChat(Peer peer) => null; + } ///See public abstract partial class UpdatesBase : ITLObject { } @@ -2183,6 +2205,7 @@ namespace TL public DateTime date; public int seq_start; public int seq; + public IPeerInfo UserOrChat(Peer peer) => peer.UserOrChat(users, chats); } ///See [TLDef(0x74AE4240)] @@ -2193,6 +2216,7 @@ namespace TL public Dictionary chats; public DateTime date; public int seq; + public IPeerInfo UserOrChat(Peer peer) => peer.UserOrChat(users, chats); } ///See [TLDef(0x9015E101)] @@ -2612,6 +2636,7 @@ namespace TL public Peer[] results; public Dictionary chats; public Dictionary users; + public IPeerInfo UserOrChat(Peer peer) => peer.UserOrChat(users, chats); } ///See @@ -2717,6 +2742,7 @@ namespace TL public PrivacyRule[] rules; public Dictionary chats; public Dictionary users; + public IPeerInfo UserOrChat(Peer peer) => peer.UserOrChat(users, chats); } ///See @@ -3232,6 +3258,7 @@ namespace TL public Peer peer; public Dictionary chats; public Dictionary users; + public IPeerInfo UserOrChat => peer.UserOrChat(users, chats); } ///See @@ -3243,7 +3270,10 @@ namespace TL } ///See - public abstract partial class Updates_ChannelDifferenceBase : ITLObject { } + public abstract partial class Updates_ChannelDifferenceBase : ITLObject + { + public abstract IPeerInfo UserOrChat(Peer peer); + } ///See [TLDef(0x3E11AFFB)] public partial class Updates_ChannelDifferenceEmpty : Updates_ChannelDifferenceBase @@ -3252,6 +3282,7 @@ namespace TL public Flags flags; public int pts; [IfFlag(1)] public int timeout; + public override IPeerInfo UserOrChat(Peer peer) => null; } ///See [TLDef(0xA4BCC6FE)] @@ -3264,6 +3295,7 @@ namespace TL public MessageBase[] messages; public Dictionary chats; public Dictionary users; + public override IPeerInfo UserOrChat(Peer peer) => peer.UserOrChat(users, chats); } ///See [TLDef(0x2064674E)] @@ -3277,6 +3309,7 @@ namespace TL public Update[] other_updates; public Dictionary chats; public Dictionary users; + public override IPeerInfo UserOrChat(Peer peer) => peer.UserOrChat(users, chats); } ///See @@ -3386,6 +3419,7 @@ namespace TL public ChannelParticipantBase[] participants; public Dictionary chats; public Dictionary users; + public IPeerInfo UserOrChat(Peer peer) => peer.UserOrChat(users, chats); } ///See @@ -3395,6 +3429,7 @@ namespace TL public ChannelParticipantBase participant; public Dictionary chats; public Dictionary users; + public IPeerInfo UserOrChat(Peer peer) => peer.UserOrChat(users, chats); } ///See @@ -3766,6 +3801,7 @@ namespace TL public Dictionary chats; public Dictionary users; public Updates_State state; + public IPeerInfo UserOrChat(Peer peer) => peer.UserOrChat(users, chats); } ///See @@ -3816,6 +3852,7 @@ namespace TL public TopPeerCategoryPeers[] categories; public Dictionary chats; public Dictionary users; + public IPeerInfo UserOrChat(Peer peer) => peer.UserOrChat(users, chats); } ///See [TLDef(0xB52C939D)] @@ -4865,6 +4902,7 @@ namespace TL public ChannelAdminLogEvent[] events; public Dictionary chats; public Dictionary users; + public IPeerInfo UserOrChat(Peer peer) => peer.UserOrChat(users, chats); } ///See @@ -4920,6 +4958,7 @@ namespace TL public RecentMeUrl[] urls; public Dictionary chats; public Dictionary users; + public IPeerInfo UserOrChat(Peer peer) => peer.UserOrChat(users, chats); } ///See @@ -5807,6 +5846,7 @@ namespace TL public int[] dates; public Dictionary chats; public Dictionary users; + public IPeerInfo UserOrChat(Peer peer) => peer.UserOrChat(users, chats); } ///See @@ -6031,6 +6071,7 @@ namespace TL public Dictionary users; [IfFlag(1)] public string psa_type; [IfFlag(2)] public string psa_message; + public IPeerInfo UserOrChat(Peer peer) => peer.UserOrChat(users, chats); } ///See @@ -6155,6 +6196,7 @@ namespace TL public MessageViews[] views; public Dictionary chats; public Dictionary users; + public IPeerInfo UserOrChat(Peer peer) => peer.UserOrChat(users, chats); } ///See @@ -6170,6 +6212,7 @@ namespace TL public int unread_count; public Dictionary chats; public Dictionary users; + public IPeerInfo UserOrChat(Peer peer) => peer.UserOrChat(users, chats); } ///See @@ -6275,6 +6318,7 @@ namespace TL public string participants_next_offset; public Dictionary chats; public Dictionary users; + public IPeerInfo UserOrChat(Peer peer) => peer.UserOrChat(users, chats); } ///See @@ -6287,6 +6331,7 @@ namespace TL public Dictionary chats; public Dictionary users; public int version; + public IPeerInfo UserOrChat(Peer peer) => peer.UserOrChat(users, chats); } ///See @@ -6399,6 +6444,7 @@ namespace TL public Peer[] peers; public Dictionary chats; public Dictionary users; + public IPeerInfo UserOrChat(Peer peer) => peer.UserOrChat(users, chats); } ///See @@ -6502,6 +6548,7 @@ namespace TL public SponsoredMessage[] messages; public Dictionary chats; public Dictionary users; + public IPeerInfo UserOrChat(Peer peer) => peer.UserOrChat(users, chats); } // ---functions---