From 2451068a71444997fb98171e99a9cdd4f7007c7c Mon Sep 17 00:00:00 2001 From: Wizou <11647984+wiz0u@users.noreply.github.com> Date: Wed, 4 Dec 2024 20:10:05 +0100 Subject: [PATCH] API Layer 195: searchStickers, Bot API 8.1 (star referral program) --- .github/dev.yml | 2 +- README.md | 2 +- src/Client.cs | 1 + src/TL.Schema.cs | 145 ++++++++++++++++++++++----- src/TL.SchemaFuncs.cs | 195 ++++++++++++++++++++++++++++++++++--- src/TL.Table.cs | 20 ++-- src/WTelegramClient.csproj | 2 +- 7 files changed, 323 insertions(+), 44 deletions(-) diff --git a/.github/dev.yml b/.github/dev.yml index 37c0a0d..7df51bd 100644 --- a/.github/dev.yml +++ b/.github/dev.yml @@ -1,7 +1,7 @@ pr: none trigger: [ master ] -name: 4.2.4-dev.$(Rev:r) +name: 4.2.5-dev.$(Rev:r) pool: vmImage: ubuntu-latest diff --git a/README.md b/README.md index e58f284..bc6ba13 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![API Layer](https://img.shields.io/badge/API_Layer-194-blueviolet)](https://corefork.telegram.org/methods) +[![API Layer](https://img.shields.io/badge/API_Layer-195-blueviolet)](https://corefork.telegram.org/methods) [![NuGet version](https://img.shields.io/nuget/v/WTelegramClient?color=00508F)](https://www.nuget.org/packages/WTelegramClient/) [![NuGet prerelease](https://img.shields.io/nuget/vpre/WTelegramClient?color=C09030&label=dev+nuget)](https://www.nuget.org/packages/WTelegramClient/absoluteLatest) [![Donate](https://img.shields.io/badge/Help_this_project:-Donate-ff4444)](https://buymeacoffee.com/wizou) diff --git a/src/Client.cs b/src/Client.cs index 08ed96b..fead981 100644 --- a/src/Client.cs +++ b/src/Client.cs @@ -1642,6 +1642,7 @@ namespace WTelegram await ConnectAsync(); } + [EditorBrowsable(EditorBrowsableState.Never)] public async Task InvokeAffected(IMethod query, long peerId) where T : Messages_AffectedMessages { var result = await Invoke(query); diff --git a/src/TL.Schema.cs b/src/TL.Schema.cs index da2a3c6..cb0d452 100644 --- a/src/TL.Schema.cs +++ b/src/TL.Schema.cs @@ -3448,7 +3448,7 @@ namespace TL } /// Extended user info See - [TLDef(0x1F58E369)] + [TLDef(0x979D2376)] public sealed partial class UserFull : IObject { /// Extra bits of information, use flags.HasFlag(...) to test for those @@ -3511,6 +3511,7 @@ namespace TL [IfFlag(38)] public int personal_channel_message; /// Number of gifts the user has chosen to display on their profile [IfFlag(40)] public int stargifts_count; + [IfFlag(43)] public StarRefProgram starref_program; [Flags] public enum Flags : uint { @@ -3595,6 +3596,8 @@ namespace TL /// If set, this user can view ad revenue statistics » for this bot. can_view_revenue = 0x200, bot_can_manage_emoji_status = 0x400, + /// Field has a value + has_starref_program = 0x800, } } @@ -5592,11 +5595,11 @@ namespace TL public BroadcastRevenueBalances balances; } /// The current account's Telegram Stars balance » has changed. See - [TLDef(0x0FB85198)] + [TLDef(0x4E80A379)] public sealed partial class UpdateStarsBalance : Update { /// New balance. - public long balance; + public StarsAmount balance; } /// A callback button sent via a business connection was pressed, and the button data was sent to the bot that created the button. See [TLDef(0x1EA2FDA7)] @@ -5656,18 +5659,6 @@ namespace TL /// Whether paid reaction privacy is enabled or disabled. public bool private_; } - /// See - [TLDef(0x2D13C6EE)] - public sealed partial class UpdateBotSubscriptionExpire : Update - { - public long user_id; - public string payload; - public string invoice_slug; - public DateTime until_date; - public int qts; - - public override (long, int, int) GetMBox() => (-1, qts, 1); - } /// Updates state. See [TLDef(0xA56C2A3E)] @@ -19129,7 +19120,7 @@ namespace TL } /// Represents a Telegram Stars transaction ». See - [TLDef(0x35D4F276)] + [TLDef(0x64DFC926)] public sealed partial class StarsTransaction : IObject { /// Extra bits of information, use flags.HasFlag(...) to test for those @@ -19137,7 +19128,7 @@ namespace TL /// Transaction ID. public string id; /// Amount of Stars (negative for outgoing transactions). - public long stars; + public StarsAmount stars; /// Date of the transaction (unixtime). public DateTime date; /// Source of the incoming transaction, or its recipient for outgoing transactions. @@ -19166,6 +19157,9 @@ namespace TL [IfFlag(14)] public StarGift stargift; /// This transaction is payment for paid bot broadcasts.
Paid broadcasts are only allowed if the allow_paid_floodskip parameter of Messages_SendMessage and other message sending methods is set while trying to broadcast more than 30 messages per second to bot users.
The integer value returned by this flag indicates the number of billed API calls.
[IfFlag(15)] public int floodskip_number; + [IfFlag(16)] public int starref_commission_permille; + [IfFlag(17)] public Peer starref_peer; + [IfFlag(17)] public StarsAmount starref_amount; [Flags] public enum Flags : uint { @@ -19201,17 +19195,21 @@ namespace TL has_stargift = 0x4000, /// Field has a value has_floodskip_number = 0x8000, + /// Field has a value + has_starref_commission_permille = 0x10000, + /// Fields and have a value + has_starref_peer = 0x20000, } } /// Info about the current Telegram Star subscriptions, balance and transaction history ». See - [TLDef(0xBBFA316C)] + [TLDef(0x6C9CE8ED)] public sealed partial class Payments_StarsStatus : IObject, IPeerResolver { /// Extra bits of information, use flags.HasFlag(...) to test for those public Flags flags; /// Current Telegram Star balance. - public long balance; + public StarsAmount balance; /// Info about current Telegram Star subscriptions, only returned when invoking Payments_GetStarsTransactions and Payments_GetStarsSubscriptions. [IfFlag(1)] public StarsSubscription[] subscriptions; /// Offset for pagination of subscriptions: only usable with Payments_GetStarsSubscriptions, returned when invoking Payments_GetStarsTransactions and Payments_GetStarsSubscriptions. @@ -19307,17 +19305,17 @@ namespace TL } /// Describes Telegram Star revenue balances ». See - [TLDef(0x79342946)] + [TLDef(0xFEBE5491)] public sealed partial class StarsRevenueStatus : IObject { /// Extra bits of information, use flags.HasFlag(...) to test for those public Flags flags; /// Amount of not-yet-withdrawn Telegram Stars. - public long current_balance; + public StarsAmount current_balance; /// Amount of withdrawable Telegram Stars. - public long available_balance; + public StarsAmount available_balance; /// Total amount of earned Telegram Stars. - public long overall_revenue; + public StarsAmount overall_revenue; /// Unixtime indicating when will withdrawal be available to the user. If not set, withdrawal can be started now. [IfFlag(1)] public int next_withdrawal_at; @@ -19739,4 +19737,105 @@ namespace TL has_header_dark_color = 0x10, } } + + /// See + [TLDef(0xDD0C66F2)] + public sealed partial class StarRefProgram : IObject + { + public Flags flags; + public long bot_id; + public int commission_permille; + [IfFlag(0)] public int duration_months; + [IfFlag(1)] public DateTime end_date; + [IfFlag(2)] public StarsAmount daily_revenue_per_user; + + [Flags] public enum Flags : uint + { + has_duration_months = 0x1, + has_end_date = 0x2, + has_daily_revenue_per_user = 0x4, + } + } + + /// See + [TLDef(0x19A13F71)] + public sealed partial class ConnectedBotStarRef : IObject + { + public Flags flags; + public string url; + public DateTime date; + public long bot_id; + public int commission_permille; + [IfFlag(0)] public int duration_months; + public long participants; + public long revenue; + + [Flags] public enum Flags : uint + { + has_duration_months = 0x1, + revoked = 0x2, + } + } + + /// See + [TLDef(0x98D5EA1D)] + public sealed partial class Payments_ConnectedStarRefBots : IObject + { + public int count; + public ConnectedBotStarRef[] connected_bots; + public Dictionary users; + } + + /// See + [TLDef(0xB4D5D859)] + public sealed partial class Payments_SuggestedStarRefBots : IObject + { + public Flags flags; + public int count; + public StarRefProgram[] suggested_bots; + public Dictionary users; + [IfFlag(0)] public string next_offset; + + [Flags] public enum Flags : uint + { + has_next_offset = 0x1, + } + } + + /// See + [TLDef(0xBBB6B4A3)] + public sealed partial class StarsAmount : IObject + { + public long amount; + public int nanos; + } + + /// See + public abstract partial class Messages_FoundStickersBase : IObject { } + /// See + [TLDef(0x6010C534)] + public sealed partial class Messages_FoundStickersNotModified : Messages_FoundStickersBase + { + public Flags flags; + [IfFlag(0)] public int next_offset; + + [Flags] public enum Flags : uint + { + has_next_offset = 0x1, + } + } + /// See + [TLDef(0x82C9E290)] + public sealed partial class Messages_FoundStickers : Messages_FoundStickersBase + { + public Flags flags; + [IfFlag(0)] public int next_offset; + public long hash; + public DocumentBase[] stickers; + + [Flags] public enum Flags : uint + { + has_next_offset = 0x1, + } + } } diff --git a/src/TL.SchemaFuncs.cs b/src/TL.SchemaFuncs.cs index d8a7e54..403a62a 100644 --- a/src/TL.SchemaFuncs.cs +++ b/src/TL.SchemaFuncs.cs @@ -1542,10 +1542,12 @@ namespace TL /// Resolve a @username to get peer info See [bots: ✓] Possible codes: 400 (details) /// @username to resolve - public static Task Contacts_ResolveUsername(this Client client, string username) + public static Task Contacts_ResolveUsername(this Client client, string username, string referer = null) => client.Invoke(new Contacts_ResolveUsername { + flags = (Contacts_ResolveUsername.Flags)(referer != null ? 0x1 : 0), username = username, + referer = referer, }); /// Get most used peers See Possible codes: 400 (details) @@ -4364,7 +4366,9 @@ namespace TL random_id = random_id, }); - /// Informs the server that the user has either: See [bots: ✓] + /// Informs the server that the user has interacted with a sponsored message in one of the ways listed here ». See [bots: ✓] + /// The user clicked on the media + /// The user expanded the video to full screen, and then clicked on it. /// The channel/bot where the ad is located /// The ad's unique ID. public static Task Messages_ClickSponsoredMessage(this Client client, InputPeer peer, byte[] random_id, bool media = false, bool fullscreen = false) @@ -4414,6 +4418,19 @@ namespace TL id = id, }); + /// See + public static Task Messages_SearchStickers(this Client client, string q, string emoticon, string[] lang_code, int offset = default, int limit = int.MaxValue, long hash = default, bool emojis = false) + => client.Invoke(new Messages_SearchStickers + { + flags = (Messages_SearchStickers.Flags)(emojis ? 0x1 : 0), + q = q, + emoticon = emoticon, + lang_code = lang_code, + offset = offset, + limit = limit, + hash = hash, + }); + /// Returns a current state of updates. See [bots: ✓] public static Task Updates_GetState(this Client client) => client.Invoke(new Updates_GetState @@ -5764,6 +5781,22 @@ namespace TL url = url, }); + /// See + public static Task Bots_GetAdminedBots(this Client client) + => client.Invoke(new Bots_GetAdminedBots + { + }); + + /// See + public static Task Bots_UpdateStarRefProgram(this Client client, InputUserBase bot, int commission_permille, int? duration_months = null) + => client.Invoke(new Bots_UpdateStarRefProgram + { + flags = (Bots_UpdateStarRefProgram.Flags)(duration_months != null ? 0x1 : 0), + bot = bot, + commission_permille = commission_permille, + duration_months = duration_months ?? default, + }); + /// Get a payment form See Possible codes: 400 (details) /// Invoice /// A JSON object with the following keys, containing color theme information (integers, RGB24) to pass to the payment provider, to apply in eventual verification pages:
bg_color - Background color
text_color - Text color
hint_color - Hint text color
link_color - Link color
button_color - Button color
button_text_color - Button text color @@ -6108,15 +6141,60 @@ namespace TL }); /// See - public static Task Payments_BotCancelStarsSubscription(this Client client, InputUserBase user_id, string invoice_slug = null, string charge_id = null, bool restore = false) + public static Task Payments_BotCancelStarsSubscription(this Client client, InputUserBase user_id, string charge_id, bool restore = false) => client.Invoke(new Payments_BotCancelStarsSubscription { - flags = (Payments_BotCancelStarsSubscription.Flags)((invoice_slug != null ? 0x2 : 0) | (charge_id != null ? 0x4 : 0) | (restore ? 0x1 : 0)), + flags = (Payments_BotCancelStarsSubscription.Flags)(restore ? 0x1 : 0), user_id = user_id, - invoice_slug = invoice_slug, charge_id = charge_id, }); + /// See + public static Task Payments_GetConnectedStarRefBots(this Client client, InputPeer peer, int limit = int.MaxValue, DateTime? offset_date = null, string offset_link = null) + => client.Invoke(new Payments_GetConnectedStarRefBots + { + flags = (Payments_GetConnectedStarRefBots.Flags)((offset_date != null ? 0x4 : 0) | (offset_link != null ? 0x4 : 0)), + peer = peer, + offset_date = offset_date ?? default, + offset_link = offset_link, + limit = limit, + }); + + /// See + public static Task Payments_GetConnectedStarRefBot(this Client client, InputPeer peer, InputUserBase bot) + => client.Invoke(new Payments_GetConnectedStarRefBot + { + peer = peer, + bot = bot, + }); + + /// See + public static Task Payments_GetSuggestedStarRefBots(this Client client, InputPeer peer, string offset, int limit = int.MaxValue, bool order_by_revenue = false, bool order_by_date = false) + => client.Invoke(new Payments_GetSuggestedStarRefBots + { + flags = (Payments_GetSuggestedStarRefBots.Flags)((order_by_revenue ? 0x1 : 0) | (order_by_date ? 0x2 : 0)), + peer = peer, + offset = offset, + limit = limit, + }); + + /// See + public static Task Payments_ConnectStarRefBot(this Client client, InputPeer peer, InputUserBase bot) + => client.Invoke(new Payments_ConnectStarRefBot + { + peer = peer, + bot = bot, + }); + + /// See + public static Task Payments_EditConnectedStarRefBot(this Client client, InputPeer peer, string link, bool revoked = false) + => client.Invoke(new Payments_EditConnectedStarRefBot + { + flags = (Payments_EditConnectedStarRefBot.Flags)(revoked ? 0x1 : 0), + peer = peer, + link = link, + }); + /// Create a stickerset. See [bots: ✓] Possible codes: 400 (details) /// Whether this is a mask stickerset /// Whether this is a custom emoji stickerset. @@ -8528,10 +8606,17 @@ namespace TL.Methods public int limit; } - [TLDef(0xF93CCBA3)] + [TLDef(0x725AFBBC)] public sealed partial class Contacts_ResolveUsername : IMethod { + public Flags flags; public string username; + [IfFlag(0)] public string referer; + + [Flags] public enum Flags : uint + { + has_referer = 0x1, + } } [TLDef(0x973478B6)] @@ -10983,6 +11068,23 @@ namespace TL.Methods public string id; } + [TLDef(0x29B1C66A)] + public sealed partial class Messages_SearchStickers : IMethod + { + public Flags flags; + public string q; + public string emoticon; + public string[] lang_code; + public int offset; + public int limit; + public long hash; + + [Flags] public enum Flags : uint + { + emojis = 0x1, + } + } + [TLDef(0xEDD4882A)] public sealed partial class Updates_GetState : IMethod { } @@ -12021,6 +12123,23 @@ namespace TL.Methods public string url; } + [TLDef(0xB0711D83)] + public sealed partial class Bots_GetAdminedBots : IMethod { } + + [TLDef(0x778B5AB3)] + public sealed partial class Bots_UpdateStarRefProgram : IMethod + { + public Flags flags; + public InputUserBase bot; + public int commission_permille; + [IfFlag(0)] public int duration_months; + + [Flags] public enum Flags : uint + { + has_duration_months = 0x1, + } + } + [TLDef(0x37148DBB)] public sealed partial class Payments_GetPaymentForm : IMethod { @@ -12316,19 +12435,73 @@ namespace TL.Methods public int msg_id; } - [TLDef(0x57F9ECE6)] + [TLDef(0x6DFA0622)] public sealed partial class Payments_BotCancelStarsSubscription : IMethod { public Flags flags; public InputUserBase user_id; - [IfFlag(1)] public string invoice_slug; - [IfFlag(2)] public string charge_id; + public string charge_id; [Flags] public enum Flags : uint { restore = 0x1, - has_invoice_slug = 0x2, - has_charge_id = 0x4, + } + } + + [TLDef(0x5869A553)] + public sealed partial class Payments_GetConnectedStarRefBots : IMethod + { + public Flags flags; + public InputPeer peer; + [IfFlag(2)] public DateTime offset_date; + [IfFlag(2)] public string offset_link; + public int limit; + + [Flags] public enum Flags : uint + { + has_offset_date = 0x4, + } + } + + [TLDef(0xB7D998F0)] + public sealed partial class Payments_GetConnectedStarRefBot : IMethod + { + public InputPeer peer; + public InputUserBase bot; + } + + [TLDef(0x0D6B48F7)] + public sealed partial class Payments_GetSuggestedStarRefBots : IMethod + { + public Flags flags; + public InputPeer peer; + public string offset; + public int limit; + + [Flags] public enum Flags : uint + { + order_by_revenue = 0x1, + order_by_date = 0x2, + } + } + + [TLDef(0x7ED5348A)] + public sealed partial class Payments_ConnectStarRefBot : IMethod + { + public InputPeer peer; + public InputUserBase bot; + } + + [TLDef(0xE4FCA4A3)] + public sealed partial class Payments_EditConnectedStarRefBot : IMethod + { + public Flags flags; + public InputPeer peer; + public string link; + + [Flags] public enum Flags : uint + { + revoked = 0x1, } } diff --git a/src/TL.Table.cs b/src/TL.Table.cs index 25ddcce..1d9e4b9 100644 --- a/src/TL.Table.cs +++ b/src/TL.Table.cs @@ -6,7 +6,7 @@ namespace TL { public static partial class Layer { - public const int Version = 194; // fetched 18/11/2024 12:59:06 + public const int Version = 195; // fetched 04/12/2024 17:50:39 internal const int SecretChats = 144; internal const int MTProto2 = 73; internal const uint VectorCtor = 0x1CB5C415; @@ -241,7 +241,7 @@ namespace TL [0xACD66C5E] = typeof(PeerSettings), [0xA437C3ED] = typeof(WallPaper), [0xE0804116] = typeof(WallPaperNoFile), - [0x1F58E369] = typeof(UserFull), + [0x979D2376] = typeof(UserFull), [0x145ADE0B] = typeof(Contact), [0xC13E3C50] = typeof(ImportedContact), [0x16D9703B] = typeof(ContactStatus), @@ -414,12 +414,11 @@ namespace TL [0xA02A982E] = typeof(UpdateBotDeleteBusinessMessage), [0x1824E40B] = typeof(UpdateNewStoryReaction), [0xDFD961F5] = typeof(UpdateBroadcastRevenueTransactions), - [0x0FB85198] = typeof(UpdateStarsBalance), + [0x4E80A379] = typeof(UpdateStarsBalance), [0x1EA2FDA7] = typeof(UpdateBusinessBotCallbackQuery), [0xA584B019] = typeof(UpdateStarsRevenueStatus), [0x283BD312] = typeof(UpdateBotPurchasedPaidMedia), [0x51CA7AEC] = typeof(UpdatePaidReactionPrivacy), - [0x2D13C6EE] = typeof(UpdateBotSubscriptionExpire), [0xA56C2A3E] = typeof(Updates_State), [0x5D75A138] = typeof(Updates_DifferenceEmpty), [0x00F49CA0] = typeof(Updates_Difference), @@ -1314,12 +1313,12 @@ namespace TL [0x60682812] = typeof(StarsTransactionPeerAds), [0xF9677AAD] = typeof(StarsTransactionPeerAPI), [0x0BD915C0] = typeof(StarsTopupOption), - [0x35D4F276] = typeof(StarsTransaction), - [0xBBFA316C] = typeof(Payments_StarsStatus), + [0x64DFC926] = typeof(StarsTransaction), + [0x6C9CE8ED] = typeof(Payments_StarsStatus), [0xE87ACBC0] = typeof(FoundStory), [0xE2DE7737] = typeof(Stories_FoundStories), [0xDE4C5D93] = typeof(GeoPointAddress), - [0x79342946] = typeof(StarsRevenueStatus), + [0xFEBE5491] = typeof(StarsRevenueStatus), [0xC92BB73B] = typeof(Payments_StarsRevenueStats), [0x1DAB80B7] = typeof(Payments_StarsRevenueWithdrawalUrl), [0x394E7F21] = typeof(Payments_StarsRevenueAdsAccountUrl), @@ -1345,6 +1344,13 @@ namespace TL [0x8ECF0511] = typeof(Messages_BotPreparedInlineMessage), [0xFF57708D] = typeof(Messages_PreparedInlineMessage), [0xC99B1950] = typeof(BotAppSettings), + [0xDD0C66F2] = typeof(StarRefProgram), + [0x19A13F71] = typeof(ConnectedBotStarRef), + [0x98D5EA1D] = typeof(Payments_ConnectedStarRefBots), + [0xB4D5D859] = typeof(Payments_SuggestedStarRefBots), + [0xBBB6B4A3] = typeof(StarsAmount), + [0x6010C534] = typeof(Messages_FoundStickersNotModified), + [0x82C9E290] = typeof(Messages_FoundStickers), // from TL.Secret: [0x6ABD9782] = typeof(Layer143.DecryptedMessageMediaDocument), [0x020DF5D0] = typeof(Layer101.MessageEntityBlockquote), diff --git a/src/WTelegramClient.csproj b/src/WTelegramClient.csproj index 19eee24..9ddd748 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: 194 + Telegram Client API (MTProto) library written 100% in C# and .NET Standard | Latest API layer: 195 Release Notes: $(ReleaseNotes.Replace("|", "%0D%0A").Replace(" - ","%0D%0A- ").Replace(" ", "%0D%0A%0D%0A"))