diff --git a/Examples/Program_ListenUpdates.cs b/Examples/Program_ListenUpdates.cs index e463eef..b94165e 100644 --- a/Examples/Program_ListenUpdates.cs +++ b/Examples/Program_ListenUpdates.cs @@ -51,7 +51,7 @@ namespace WTelegramClientTest case UpdateChatParticipants { participants: ChatParticipants cp }: Console.WriteLine($"{cp.participants.Length} participants in {Chat(cp.chat_id)}"); break; case UpdateUserStatus uus: Console.WriteLine($"{User(uus.user_id)} is now {uus.status.GetType().Name[10..]}"); break; case UpdateUserName uun: Console.WriteLine($"{User(uun.user_id)} has changed profile name: {uun.first_name} {uun.last_name}"); break; - case UpdateUserPhoto uup: Console.WriteLine($"{User(uup.user_id)} has changed profile photo"); break; + case UpdateUser uu: Console.WriteLine($"{User(uu.user_id)} has changed infos/photo"); break; default: Console.WriteLine(update.GetType().Name); break; // there are much more update types than the above example cases } } diff --git a/README.md b/README.md index caa4f31..1c342a3 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![API Layer](https://img.shields.io/badge/API_Layer-150-blueviolet)](https://corefork.telegram.org/methods) +[![API Layer](https://img.shields.io/badge/API_Layer-151-blueviolet)](https://corefork.telegram.org/methods) [![NuGet version](https://img.shields.io/nuget/v/WTelegramClient?color=00508F)](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) [![Donate](https://img.shields.io/badge/Help_this_project:-Donate-ff4444)](http://t.me/WTelegramBot?start=donate) diff --git a/src/TL.Schema.cs b/src/TL.Schema.cs index f747ec7..92f176b 100644 --- a/src/TL.Schema.cs +++ b/src/TL.Schema.cs @@ -199,6 +199,7 @@ namespace TL has_stickers = 0x1, /// Field has a value has_ttl_seconds = 0x2, + spoiler = 0x4, } } /// Forwarded photo See @@ -216,6 +217,7 @@ namespace TL { /// Field has a value has_ttl_seconds = 0x1, + spoiler = 0x2, } } /// Map. See @@ -269,6 +271,7 @@ namespace TL nosound_video = 0x8, /// Force the media file to be uploaded as document force_file = 0x10, + spoiler = 0x20, } } /// Forwarded document See @@ -290,6 +293,7 @@ namespace TL has_ttl_seconds = 0x1, /// Field has a value has_query = 0x2, + spoiler = 0x4, } } /// Can be used to send a venue geolocation. See @@ -324,6 +328,7 @@ namespace TL { /// Field has a value has_ttl_seconds = 0x1, + spoiler = 0x2, } } /// Document that will be downloaded by the telegram servers See @@ -341,6 +346,7 @@ namespace TL { /// Field has a value has_ttl_seconds = 0x1, + spoiler = 0x2, } } /// A game See @@ -819,6 +825,7 @@ namespace TL has_video = 0x1, /// Field has a value has_stripped_thumb = 0x2, + personal = 0x4, } } @@ -1345,6 +1352,7 @@ namespace TL /// Can we delete this channel? can_delete_channel = 0x1, antispam = 0x2, + participants_hidden = 0x4, } /// ID of the channel @@ -1708,6 +1716,7 @@ namespace TL has_photo = 0x1, /// Field has a value has_ttl_seconds = 0x4, + spoiler = 0x8, } } /// Attached map. See @@ -1754,6 +1763,7 @@ namespace TL has_ttl_seconds = 0x4, /// Whether this is a normal sticker, if not set this is a premium sticker and a premium sticker animation must be played. nopremium = 0x8, + spoiler = 0x10, } } /// Preview of webpage See @@ -2194,6 +2204,15 @@ namespace TL has_hidden = 0x8, } } + /// See + [TLDef(0x57DE635E)] + public class MessageActionSuggestProfilePhoto : MessageAction + { + public PhotoBase photo; + } + /// See + [TLDef(0xE7E75F97)] + public class MessageActionAttachMenuBotAllowed : MessageAction { } /// Chat info. See Derived classes: , public abstract class DialogBase : IObject @@ -2738,7 +2757,7 @@ namespace TL } /// Extended user info See - [TLDef(0xC4B1FC3F)] + [TLDef(0xF8D32AED)] public class UserFull : IObject { /// Flags, see TL conditional fields @@ -2749,8 +2768,10 @@ namespace TL [IfFlag(1)] public string about; /// Peer settings public PeerSettings settings; + [IfFlag(21)] public PhotoBase personal_photo; /// Profile photo [IfFlag(2)] public PhotoBase profile_photo; + [IfFlag(22)] public PhotoBase fallback_photo; /// Notification settings public PeerNotifySettings notify_settings; /// For bots, info about the bot (bot commands, etc) @@ -2812,6 +2833,10 @@ namespace TL has_premium_gifts = 0x80000, /// Whether this user doesn't allow sending voice messages in a private chat with them voice_messages_forbidden = 0x100000, + /// Field has a value + has_personal_photo = 0x200000, + /// Field has a value + has_fallback_photo = 0x400000, } } @@ -3167,11 +3192,9 @@ namespace TL public int pts_count; } /// The user is preparing a message; typing, recording, uploading, etc. This update is valid for 6 seconds. If no further updates of this kind are received after 6 seconds, it should be considered that the user stopped doing whatever they were doing See - [TLDef(0xC01E857F)] - public class UpdateUserTyping : Update + [TLDef(0xC01E857F, inheritBefore = true)] + public class UpdateUserTyping : UpdateUser { - /// User id - public long user_id; /// Action type public SendMessageAction action; } @@ -3192,39 +3215,22 @@ namespace TL public ChatParticipantsBase participants; } /// Contact status update. See - [TLDef(0xE5BDF8DE)] - public class UpdateUserStatus : Update + [TLDef(0xE5BDF8DE, inheritBefore = true)] + public class UpdateUserStatus : UpdateUser { - /// User identifier - public long user_id; /// New status public UserStatus status; } /// Changes the user's first name, last name and username. See - [TLDef(0xA7848924)] - public class UpdateUserName : Update + [TLDef(0xA7848924, inheritBefore = true)] + public class UpdateUserName : UpdateUser { - /// User identifier - public long user_id; /// New first name. Corresponds to the new value of real_first_name field of the . public string first_name; /// New last name. Corresponds to the new value of real_last_name field of the . public string last_name; public Username[] usernames; } - /// Change of contact's profile photo. See - [TLDef(0xF227868C)] - public class UpdateUserPhoto : Update - { - /// User identifier - public long user_id; - /// Date of photo update. - public DateTime date; - /// New profile photo - public UserProfilePhoto photo; - /// (), if one of the previously used photos is set a profile photo. - public bool previous; - } /// New encrypted message. See [TLDef(0x12BCBD9A)] public class UpdateNewEncryptedMessage : Update @@ -3334,11 +3340,9 @@ namespace TL public PrivacyRule[] rules; } /// A user's phone number was changed See - [TLDef(0x05492A13)] - public class UpdateUserPhone : Update + [TLDef(0x05492A13, inheritBefore = true)] + public class UpdateUserPhone : UpdateUser { - /// User ID - public long user_id; /// New phone number public string phone; } @@ -4341,11 +4345,9 @@ namespace TL [TLDef(0xFB4C496C)] public class UpdateReadFeaturedEmojiStickers : Update { } /// The emoji status of a certain user has changed See - [TLDef(0x28373599)] - public class UpdateUserEmojiStatus : Update + [TLDef(0x28373599, inheritBefore = true)] + public class UpdateUserEmojiStatus : UpdateUser { - /// User ID - public long user_id; /// New emoji status public EmojiStatus emoji_status; } @@ -4406,6 +4408,12 @@ namespace TL has_order = 0x1, } } + /// See + [TLDef(0x20529438)] + public class UpdateUser : Update + { + public long user_id; + } /// Updates state. See [TLDef(0xA56C2A3E)] @@ -5791,6 +5799,7 @@ namespace TL { /// Whether this custom emoji can be sent by non-Premium users free = 0x1, + text_color = 0x2, } } @@ -6629,6 +6638,7 @@ namespace TL selective = 0x4, /// Field has a value has_placeholder = 0x8, + persistent = 0x10, } } /// Bot or inline keyboard See @@ -8187,6 +8197,14 @@ namespace TL /// Stickerset public override StickerSet Set => set; } + /// See + [TLDef(0x77B15D1C)] + public class StickerSetNoCovered : StickerSetCoveredBase + { + public StickerSet set; + + public override StickerSet Set => set; + } /// Position on a photo where a mask should be placed when attaching stickers to media » See [TLDef(0xAED6DBB2)] @@ -13450,6 +13468,7 @@ namespace TL inactive = 0x1, /// True, if the bot supports the "settings_button_pressed" event » has_settings = 0x2, + request_write_access = 0x4, } } diff --git a/src/TL.SchemaFuncs.cs b/src/TL.SchemaFuncs.cs index 9fab31b..83fa378 100644 --- a/src/TL.SchemaFuncs.cs +++ b/src/TL.SchemaFuncs.cs @@ -3255,9 +3255,10 @@ namespace TL /// Enable or disable web bot attachment menu » See /// Bot ID /// Toggle - public static Task Messages_ToggleBotInAttachMenu(this Client client, InputUserBase bot, bool enabled) + public static Task Messages_ToggleBotInAttachMenu(this Client client, InputUserBase bot, bool enabled, bool write_allowed = false) => client.Invoke(new Messages_ToggleBotInAttachMenu { + flags = (Messages_ToggleBotInAttachMenu.Flags)(write_allowed ? 0x1 : 0), bot = bot, enabled = enabled, }); @@ -3495,9 +3496,10 @@ namespace TL /// Installs a previously uploaded photo as a profile photo. See Possible codes: 400 (details) /// Input photo - public static Task Photos_UpdateProfilePhoto(this Client client, InputPhoto id) + public static Task Photos_UpdateProfilePhoto(this Client client, InputPhoto id, bool fallback = false) => client.Invoke(new Photos_UpdateProfilePhoto { + flags = (Photos_UpdateProfilePhoto.Flags)(fallback ? 0x1 : 0), id = id, }); @@ -3505,10 +3507,10 @@ namespace TL /// File saved in parts by means of Upload_SaveFilePart method /// Animated profile picture video /// Floating point UNIX timestamp in seconds, indicating the frame of the video that should be used as static preview. - public static Task Photos_UploadProfilePhoto(this Client client, InputFileBase file = null, InputFileBase video = null, double? video_start_ts = null) + public static Task Photos_UploadProfilePhoto(this Client client, InputFileBase file = null, InputFileBase video = null, double? video_start_ts = null, bool fallback = false) => client.Invoke(new Photos_UploadProfilePhoto { - flags = (Photos_UploadProfilePhoto.Flags)((file != null ? 0x1 : 0) | (video != null ? 0x2 : 0) | (video_start_ts != null ? 0x4 : 0)), + flags = (Photos_UploadProfilePhoto.Flags)((file != null ? 0x1 : 0) | (video != null ? 0x2 : 0) | (video_start_ts != null ? 0x4 : 0) | (fallback ? 0x8 : 0)), file = file, video = video, video_start_ts = video_start_ts.GetValueOrDefault(), @@ -3536,6 +3538,17 @@ namespace TL limit = limit, }); + /// See + public static Task Photos_UploadContactProfilePhoto(this Client client, InputUserBase user_id, InputFileBase file = null, InputFileBase video = null, double? video_start_ts = null, bool suggest = false, bool save = false) + => client.Invoke(new Photos_UploadContactProfilePhoto + { + flags = (Photos_UploadContactProfilePhoto.Flags)((file != null ? 0x1 : 0) | (video != null ? 0x2 : 0) | (video_start_ts != null ? 0x4 : 0) | (suggest ? 0x8 : 0) | (save ? 0x10 : 0)), + user_id = user_id, + file = file, + video = video, + video_start_ts = video_start_ts.GetValueOrDefault(), + }); + /// Saves a part of file for further sending to one of the methods. See [bots: ✓] Possible codes: 400 (details) /// Random file identifier created by the client /// Numerical order of a part @@ -4360,6 +4373,14 @@ namespace TL msg_id = msg_id, }); + /// See + public static Task Channels_ToggleParticipantsHidden(this Client client, InputChannelBase channel, bool enabled) + => client.Invoke(new Channels_ToggleParticipantsHidden + { + channel = channel, + enabled = enabled, + }); + /// Sends a custom request; for bots only See [bots: ✓] Possible codes: 400,403 (details) /// The method name /// JSON-serialized method parameters @@ -7790,11 +7811,17 @@ namespace TL.Methods public InputUserBase bot; } - [TLDef(0x1AEE33AF)] + [TLDef(0x69F59D69)] public class Messages_ToggleBotInAttachMenu : IMethod { + public Flags flags; public InputUserBase bot; public bool enabled; + + [Flags] public enum Flags : uint + { + write_allowed = 0x1, + } } [TLDef(0x178B480B)] @@ -7983,10 +8010,16 @@ namespace TL.Methods } } - [TLDef(0x72D4742C)] + [TLDef(0x1C3D5956)] public class Photos_UpdateProfilePhoto : IMethod { + public Flags flags; public InputPhoto id; + + [Flags] public enum Flags : uint + { + fallback = 0x1, + } } [TLDef(0x89F30F69)] @@ -8002,6 +8035,7 @@ namespace TL.Methods has_file = 0x1, has_video = 0x2, has_video_start_ts = 0x4, + fallback = 0x8, } } @@ -8020,6 +8054,25 @@ namespace TL.Methods public int limit; } + [TLDef(0xB91A83BF)] + public class Photos_UploadContactProfilePhoto : IMethod + { + public Flags flags; + public InputUserBase user_id; + [IfFlag(0)] public InputFileBase file; + [IfFlag(1)] public InputFileBase video; + [IfFlag(2)] public double video_start_ts; + + [Flags] public enum Flags : uint + { + has_file = 0x1, + has_video = 0x2, + has_video_start_ts = 0x4, + suggest = 0x8, + save = 0x10, + } + } + [TLDef(0xB304A621)] public class Upload_SaveFilePart : IMethod { @@ -8657,6 +8710,13 @@ namespace TL.Methods public int msg_id; } + [TLDef(0x6A6E7854)] + public class Channels_ToggleParticipantsHidden : IMethod + { + public InputChannelBase channel; + public bool enabled; + } + [TLDef(0xAA2769ED)] public class Bots_SendCustomRequest : IMethod { diff --git a/src/TL.Table.cs b/src/TL.Table.cs index f1f9db4..cc4740e 100644 --- a/src/TL.Table.cs +++ b/src/TL.Table.cs @@ -6,7 +6,7 @@ namespace TL { public static class Layer { - public const int Version = 150; // fetched 07/12/2022 12:23:35 + public const int Version = 151; // fetched 29/12/2022 21:30:31 internal const int SecretChats = 144; internal const int MTProto2 = 73; internal const uint VectorCtor = 0x1CB5C415; @@ -65,7 +65,7 @@ namespace TL [0x37982646] = typeof(IpPortSecret), [0x4679B65F] = typeof(AccessPointRule), [0x5A592A6C] = typeof(Help_ConfigSimple), - // from TL.Schema: + // from TL.SchemaExtensions: [0x3FEDD339] = typeof(True), [0xC4B9F9BB] = typeof(Error), [0x56730BCC] = null,//Null @@ -193,6 +193,8 @@ namespace TL [0xABA0F5C6] = typeof(MessageActionGiftPremium), [0x0D999256] = typeof(MessageActionTopicCreate), [0xC0944820] = typeof(MessageActionTopicEdit), + [0x57DE635E] = typeof(MessageActionSuggestProfilePhoto), + [0xE7E75F97] = typeof(MessageActionAttachMenuBotAllowed), [0xD58A08C6] = typeof(Dialog), [0x71BD134C] = typeof(DialogFolder), [0x2331B22D] = typeof(PhotoEmpty), @@ -219,7 +221,7 @@ namespace TL [0xA518110D] = typeof(PeerSettings), [0xA437C3ED] = typeof(WallPaper), [0xE0804116] = typeof(WallPaperNoFile), - [0xC4B1FC3F] = typeof(UserFull), + [0xF8D32AED] = typeof(UserFull), [0x145ADE0B] = typeof(Contact), [0xC13E3C50] = typeof(ImportedContact), [0x16D9703B] = typeof(ContactStatus), @@ -264,7 +266,6 @@ namespace TL [0x07761198] = typeof(UpdateChatParticipants), [0xE5BDF8DE] = typeof(UpdateUserStatus), [0xA7848924] = typeof(UpdateUserName), - [0xF227868C] = typeof(UpdateUserPhoto), [0x12BCBD9A] = typeof(UpdateNewEncryptedMessage), [0x1710F156] = typeof(UpdateEncryptedChatTyping), [0xB4A2E88D] = typeof(UpdateEncryption), @@ -365,6 +366,7 @@ namespace TL [0x5A73A98C] = typeof(UpdateMessageExtendedMedia), [0x192EFBE3] = typeof(UpdateChannelPinnedTopic), [0xFE198602] = typeof(UpdateChannelPinnedTopics), + [0x20529438] = typeof(UpdateUser), [0xA56C2A3E] = typeof(Updates_State), [0x5D75A138] = typeof(Updates_DifferenceEmpty), [0x00F49CA0] = typeof(Updates_Difference), @@ -622,6 +624,7 @@ namespace TL [0x6410A5D2] = typeof(StickerSetCovered), [0x3407E51B] = typeof(StickerSetMultiCovered), [0x40D13C0E] = typeof(StickerSetFullCovered), + [0x77B15D1C] = typeof(StickerSetNoCovered), [0xAED6DBB2] = typeof(MaskCoords), [0x4A992157] = typeof(InputStickeredMediaPhoto), [0x0438865B] = typeof(InputStickeredMediaDocument), diff --git a/src/WTelegramClient.csproj b/src/WTelegramClient.csproj index 5718f70..ce3ce87 100644 --- a/src/WTelegramClient.csproj +++ b/src/WTelegramClient.csproj @@ -13,7 +13,7 @@ WTelegramClient 0.0.0 Wizou - Telegram Client API (MTProto) library written 100% in C# and .NET Standard | Latest API layer: 150 Release Notes: $(ReleaseNotes.Replace("|", "%0D%0A").Replace(" - ","%0D%0A- ").Replace(" ", "%0D%0A%0D%0A")) + Telegram Client API (MTProto) library written 100% in C# and .NET Standard | Latest API layer: 151 Release Notes: $(ReleaseNotes.Replace("|", "%0D%0A").Replace(" - ","%0D%0A- ").Replace(" ", "%0D%0A%0D%0A")) Copyright © Olivier Marcoux 2021-2022 MIT https://github.com/wiz0u/WTelegramClient