API Layer 163: some minor bot & update stuff

This commit is contained in:
Wizou 2023-09-18 19:21:48 +02:00
parent 38efb05923
commit 8f90e88074
9 changed files with 61 additions and 23 deletions

2
.github/dev.yml vendored
View file

@ -2,7 +2,7 @@
trigger: trigger:
- master - master
name: 3.5.4-dev.$(Rev:r) name: 3.5.5-dev.$(Rev:r)
pool: pool:
vmImage: ubuntu-latest vmImage: ubuntu-latest

2
.github/release.yml vendored
View file

@ -8,7 +8,7 @@ pool:
variables: variables:
buildConfiguration: 'Release' buildConfiguration: 'Release'
releaseNotes: $[replace(variables['releaseNotes'], '"', '''''')] releaseNotes2: $[replace($(releaseNotes), '"', '''''')]
stages: stages:
- stage: publish - stage: publish

View file

@ -200,6 +200,7 @@ You have to handle `client.OnUpdate` events containing an `UpdateNewMessage`.
See the `HandleMessage` method in [Examples/Program_ListenUpdates.cs](https://github.com/wiz0u/WTelegramClient/blob/master/Examples/Program_ListenUpdates.cs?ts=4#L23). See the `HandleMessage` method in [Examples/Program_ListenUpdates.cs](https://github.com/wiz0u/WTelegramClient/blob/master/Examples/Program_ListenUpdates.cs?ts=4#L23).
You can filter specific chats the message are posted in, by looking at the `Message.peer_id` field. You can filter specific chats the message are posted in, by looking at the `Message.peer_id` field.
See also [explanation below](#message-user) to extract user/chat info from messages.
<a name="download"></a> <a name="download"></a>
## Downloading photos, medias, files ## Downloading photos, medias, files
@ -270,6 +271,7 @@ InputPeer peer = chats.chats[1234567890]; // the chat we want
DateTime when = DateTime.UtcNow.AddMinutes(3); DateTime when = DateTime.UtcNow.AddMinutes(3);
await client.SendMessageAsync(peer, "This will be posted in 3 minutes", schedule_date: when); await client.SendMessageAsync(peer, "This will be posted in 3 minutes", schedule_date: when);
``` ```
*Note: Make sure your computer clock is synchronized with Internet time*
<a name="fun"></a> <a name="fun"></a>
## Fun with stickers, GIFs, dice, and animated emojies ## Fun with stickers, GIFs, dice, and animated emojies
@ -471,7 +473,7 @@ dialogs.CollectUsersChats(_users, _chats);
private async Task OnUpdate(UpdatesBase updates) private async Task OnUpdate(UpdatesBase updates)
{ {
updates.CollectUsersChats(_users, _chats); updates.CollectUsersChats(_users, _chats);
... ...
} }

View file

@ -1,4 +1,4 @@
[![API Layer](https://img.shields.io/badge/API_Layer-162-blueviolet)](https://corefork.telegram.org/methods) [![API Layer](https://img.shields.io/badge/API_Layer-163-blueviolet)](https://corefork.telegram.org/methods)
[![NuGet version](https://img.shields.io/nuget/v/WTelegramClient?color=00508F)](https://www.nuget.org/packages/WTelegramClient/) [![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) [![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://www.buymeacoffee.com/wizou) [![Donate](https://img.shields.io/badge/Help_this_project:-Donate-ff4444)](https://www.buymeacoffee.com/wizou)

View file

@ -21,6 +21,7 @@ namespace WTelegram
int RemoteLayer { get; } int RemoteLayer { get; }
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles")]
public sealed class SecretChats : IDisposable public sealed class SecretChats : IDisposable
{ {
public event Action OnChanged; public event Action OnChanged;

View file

@ -2286,13 +2286,13 @@ namespace TL
{ {
/// <summary>Extra bits of information, use <c>flags.HasFlag(...)</c> to test for those</summary> /// <summary>Extra bits of information, use <c>flags.HasFlag(...)</c> to test for those</summary>
public Flags flags; public Flags flags;
/// <summary>Topic title.</summary> /// <summary>New topic title.</summary>
[IfFlag(0)] public string title; [IfFlag(0)] public string title;
/// <summary>ID of the <a href="https://corefork.telegram.org/api/custom-emoji">custom emoji</a> used as topic icon.</summary> /// <summary>ID of the new <a href="https://corefork.telegram.org/api/custom-emoji">custom emoji</a> used as topic icon, or if it was removed.</summary>
[IfFlag(1)] public long icon_emoji_id; [IfFlag(1)] public long icon_emoji_id;
/// <summary>Whether the topic was closed.</summary> /// <summary>Whether the topic was opened or closed.</summary>
[IfFlag(2)] public bool closed; [IfFlag(2)] public bool closed;
/// <summary>Whether the topic was hidden (only valid for the "General" topic, <c>id=1</c>).</summary> /// <summary>Whether the topic was hidden or unhidden (only valid for the "General" topic, <c>id=1</c>).</summary>
[IfFlag(3)] public bool hidden; [IfFlag(3)] public bool hidden;
[Flags] public enum Flags : uint [Flags] public enum Flags : uint
@ -3406,6 +3406,21 @@ namespace TL
/// <summary>Usernames.</summary> /// <summary>Usernames.</summary>
public Username[] usernames; public Username[] usernames;
} }
/// <summary><para>See <a href="https://corefork.telegram.org/constructor/updateNewAuthorization"/></para></summary>
[TLDef(0x8951ABEF)]
public class UpdateNewAuthorization : Update
{
public Flags flags;
public long hash;
[IfFlag(0)] public DateTime date;
[IfFlag(0)] public string device;
[IfFlag(0)] public string location;
[Flags] public enum Flags : uint
{
unconfirmed = 0x1,
}
}
/// <summary>New encrypted message. <para>See <a href="https://corefork.telegram.org/constructor/updateNewEncryptedMessage"/></para></summary> /// <summary>New encrypted message. <para>See <a href="https://corefork.telegram.org/constructor/updateNewEncryptedMessage"/></para></summary>
[TLDef(0x12BCBD9A)] [TLDef(0x12BCBD9A)]
public class UpdateNewEncryptedMessage : Update public class UpdateNewEncryptedMessage : Update
@ -3571,15 +3586,23 @@ namespace TL
public int pts_count; public int pts_count;
} }
/// <summary>Contents of messages in the common <a href="https://corefork.telegram.org/api/updates">message box</a> were read <para>See <a href="https://corefork.telegram.org/constructor/updateReadMessagesContents"/></para></summary> /// <summary>Contents of messages in the common <a href="https://corefork.telegram.org/api/updates">message box</a> were read <para>See <a href="https://corefork.telegram.org/constructor/updateReadMessagesContents"/></para></summary>
[TLDef(0x68C13933)] [TLDef(0xF8227181)]
public class UpdateReadMessagesContents : Update public class UpdateReadMessagesContents : Update
{ {
public Flags flags;
/// <summary>IDs of read messages</summary> /// <summary>IDs of read messages</summary>
public int[] messages; public int[] messages;
/// <summary><a href="https://corefork.telegram.org/api/updates">Event count after generation</a></summary> /// <summary><a href="https://corefork.telegram.org/api/updates">Event count after generation</a></summary>
public int pts; public int pts;
/// <summary><a href="https://corefork.telegram.org/api/updates">Number of events that were generated</a></summary> /// <summary><a href="https://corefork.telegram.org/api/updates">Number of events that were generated</a></summary>
public int pts_count; public int pts_count;
[IfFlag(0)] public DateTime date;
[Flags] public enum Flags : uint
{
/// <summary>Field <see cref="date"/> has a value</summary>
has_date = 0x1,
}
} }
/// <summary>There are new updates in the specified channel, the client must fetch them.<br/>If the difference is too long or if the channel isn't currently in the states, start fetching from the specified pts. <para>See <a href="https://corefork.telegram.org/constructor/updateChannelTooLong"/></para></summary> /// <summary>There are new updates in the specified channel, the client must fetch them.<br/>If the difference is too long or if the channel isn't currently in the states, start fetching from the specified pts. <para>See <a href="https://corefork.telegram.org/constructor/updateChannelTooLong"/></para></summary>
[TLDef(0x108D941F)] [TLDef(0x108D941F)]
@ -6258,6 +6281,7 @@ namespace TL
encrypted_requests_disabled = 0x8, encrypted_requests_disabled = 0x8,
/// <summary>Whether this session will accept phone calls</summary> /// <summary>Whether this session will accept phone calls</summary>
call_requests_disabled = 0x10, call_requests_disabled = 0x10,
unconfirmed = 0x20,
} }
} }
@ -13869,7 +13893,7 @@ namespace TL
} }
/// <summary>Represents a <a href="https://corefork.telegram.org/api/bots/attach">bot web app that can be launched from the attachment menu »</a> <para>See <a href="https://corefork.telegram.org/constructor/attachMenuBot"/></para></summary> /// <summary>Represents a <a href="https://corefork.telegram.org/api/bots/attach">bot web app that can be launched from the attachment menu »</a> <para>See <a href="https://corefork.telegram.org/constructor/attachMenuBot"/></para></summary>
[TLDef(0xC8AA2CD2)] [TLDef(0xD90D8DFE)]
public class AttachMenuBot : IObject public class AttachMenuBot : IObject
{ {
/// <summary>Extra bits of information, use <c>flags.HasFlag(...)</c> to test for those</summary> /// <summary>Extra bits of information, use <c>flags.HasFlag(...)</c> to test for those</summary>
@ -13879,7 +13903,7 @@ namespace TL
/// <summary>Attachment menu item name</summary> /// <summary>Attachment menu item name</summary>
public string short_name; public string short_name;
/// <summary>List of dialog types where this attachment menu entry should be shown</summary> /// <summary>List of dialog types where this attachment menu entry should be shown</summary>
public AttachMenuPeerType[] peer_types; [IfFlag(3)] public AttachMenuPeerType[] peer_types;
/// <summary>List of platform-specific static icons and animations to use for the attachment menu button</summary> /// <summary>List of platform-specific static icons and animations to use for the attachment menu button</summary>
public AttachMenuBotIcon[] icons; public AttachMenuBotIcon[] icons;
@ -13891,6 +13915,9 @@ namespace TL
has_settings = 0x2, has_settings = 0x2,
/// <summary>Whether the bot would like to send messages to the user.</summary> /// <summary>Whether the bot would like to send messages to the user.</summary>
request_write_access = 0x4, request_write_access = 0x4,
show_in_attach_menu = 0x8,
show_in_side_menu = 0x10,
side_menu_disclaimer_needed = 0x20,
} }
} }
@ -14784,6 +14811,7 @@ namespace TL
inactive = 0x1, inactive = 0x1,
/// <summary>The bot is asking permission to send messages to the user: if the user agrees, set the <c>write_allowed</c> flag when invoking <see cref="SchemaExtensions.Messages_RequestAppWebView">Messages_RequestAppWebView</see>.</summary> /// <summary>The bot is asking permission to send messages to the user: if the user agrees, set the <c>write_allowed</c> flag when invoking <see cref="SchemaExtensions.Messages_RequestAppWebView">Messages_RequestAppWebView</see>.</summary>
request_write_access = 0x2, request_write_access = 0x2,
has_settings = 0x4,
} }
} }

View file

@ -1010,10 +1010,10 @@ namespace TL
/// <param name="hash">Session ID from the <see cref="Authorization"/>, fetchable using <see cref="Account_GetAuthorizations">Account_GetAuthorizations</see></param> /// <param name="hash">Session ID from the <see cref="Authorization"/>, fetchable using <see cref="Account_GetAuthorizations">Account_GetAuthorizations</see></param>
/// <param name="encrypted_requests_disabled">Whether to enable or disable receiving encrypted chats: if the flag is not set, the previous setting is not changed</param> /// <param name="encrypted_requests_disabled">Whether to enable or disable receiving encrypted chats: if the flag is not set, the previous setting is not changed</param>
/// <param name="call_requests_disabled">Whether to enable or disable receiving calls: if the flag is not set, the previous setting is not changed</param> /// <param name="call_requests_disabled">Whether to enable or disable receiving calls: if the flag is not set, the previous setting is not changed</param>
public static Task<bool> Account_ChangeAuthorizationSettings(this Client client, long hash, bool? encrypted_requests_disabled = default, bool? call_requests_disabled = default) public static Task<bool> Account_ChangeAuthorizationSettings(this Client client, long hash, bool? encrypted_requests_disabled = default, bool? call_requests_disabled = default, bool confirmed = false)
=> client.Invoke(new Account_ChangeAuthorizationSettings => client.Invoke(new Account_ChangeAuthorizationSettings
{ {
flags = (Account_ChangeAuthorizationSettings.Flags)((encrypted_requests_disabled != default ? 0x1 : 0) | (call_requests_disabled != default ? 0x2 : 0)), flags = (Account_ChangeAuthorizationSettings.Flags)((encrypted_requests_disabled != default ? 0x1 : 0) | (call_requests_disabled != default ? 0x2 : 0) | (confirmed ? 0x8 : 0)),
hash = hash, hash = hash,
encrypted_requests_disabled = encrypted_requests_disabled.GetValueOrDefault(), encrypted_requests_disabled = encrypted_requests_disabled.GetValueOrDefault(),
call_requests_disabled = call_requests_disabled.GetValueOrDefault(), call_requests_disabled = call_requests_disabled.GetValueOrDefault(),
@ -3095,7 +3095,7 @@ namespace TL
/// <param name="link">Invite link</param> /// <param name="link">Invite link</param>
/// <param name="q">Search for a user in the pending <a href="https://corefork.telegram.org/api/invites#join-requests">join requests »</a> list: only available when the <c>requested</c> flag is set, cannot be used together with a specific <c>link</c>.</param> /// <param name="q">Search for a user in the pending <a href="https://corefork.telegram.org/api/invites#join-requests">join requests »</a> list: only available when the <c>requested</c> flag is set, cannot be used together with a specific <c>link</c>.</param>
/// <param name="offset_date"><a href="https://corefork.telegram.org/api/offsets">Offsets for pagination, for more info click here</a></param> /// <param name="offset_date"><a href="https://corefork.telegram.org/api/offsets">Offsets for pagination, for more info click here</a></param>
/// <param name="offset_user">User ID for <a href="https://corefork.telegram.org/api/offsets">pagination</a></param> /// <param name="offset_user">User ID for <a href="https://corefork.telegram.org/api/offsets">pagination</a>: if set, <c>offset_date</c> <strong>must also be set</strong>.</param>
/// <param name="limit">Maximum number of results to return, <a href="https://corefork.telegram.org/api/offsets">see pagination</a></param> /// <param name="limit">Maximum number of results to return, <a href="https://corefork.telegram.org/api/offsets">see pagination</a></param>
public static Task<Messages_ChatInviteImporters> Messages_GetChatInviteImporters(this Client client, InputPeer peer, DateTime offset_date = default, InputUserBase offset_user = null, int limit = int.MaxValue, string link = null, string q = null, bool requested = false) public static Task<Messages_ChatInviteImporters> Messages_GetChatInviteImporters(this Client client, InputPeer peer, DateTime offset_date = default, InputUserBase offset_user = null, int limit = int.MaxValue, string link = null, string q = null, bool requested = false)
=> client.Invoke(new Messages_GetChatInviteImporters => client.Invoke(new Messages_GetChatInviteImporters
@ -3423,12 +3423,13 @@ namespace TL
/// <param name="url">Web app URL</param> /// <param name="url">Web app URL</param>
/// <param name="theme_params"><a href="https://corefork.telegram.org/api/bots/webapps#theme-parameters">Theme parameters »</a></param> /// <param name="theme_params"><a href="https://corefork.telegram.org/api/bots/webapps#theme-parameters">Theme parameters »</a></param>
/// <param name="platform">Short name of the application; 0-64 English letters, digits, and underscores</param> /// <param name="platform">Short name of the application; 0-64 English letters, digits, and underscores</param>
public static Task<SimpleWebViewResult> Messages_RequestSimpleWebView(this Client client, InputUserBase bot, string url, string platform, DataJSON theme_params = null, bool from_switch_webview = false) public static Task<SimpleWebViewResult> Messages_RequestSimpleWebView(this Client client, InputUserBase bot, string platform, DataJSON theme_params = null, string url = null, string start_param = null, bool from_switch_webview = false, bool from_side_menu = false)
=> client.Invoke(new Messages_RequestSimpleWebView => client.Invoke(new Messages_RequestSimpleWebView
{ {
flags = (Messages_RequestSimpleWebView.Flags)((theme_params != null ? 0x1 : 0) | (from_switch_webview ? 0x2 : 0)), flags = (Messages_RequestSimpleWebView.Flags)((theme_params != null ? 0x1 : 0) | (url != null ? 0x8 : 0) | (start_param != null ? 0x10 : 0) | (from_switch_webview ? 0x2 : 0) | (from_side_menu ? 0x4 : 0)),
bot = bot, bot = bot,
url = url, url = url,
start_param = start_param,
theme_params = theme_params, theme_params = theme_params,
platform = platform, platform = platform,
}); });
@ -6600,6 +6601,7 @@ namespace TL.Methods
{ {
has_encrypted_requests_disabled = 0x1, has_encrypted_requests_disabled = 0x1,
has_call_requests_disabled = 0x2, has_call_requests_disabled = 0x2,
confirmed = 0x8,
} }
} }
@ -8647,12 +8649,13 @@ namespace TL.Methods
} }
} }
[TLDef(0x299BEC8E)] [TLDef(0x1A46500A)]
public class Messages_RequestSimpleWebView : IMethod<SimpleWebViewResult> public class Messages_RequestSimpleWebView : IMethod<SimpleWebViewResult>
{ {
public Flags flags; public Flags flags;
public InputUserBase bot; public InputUserBase bot;
public string url; [IfFlag(3)] public string url;
[IfFlag(4)] public string start_param;
[IfFlag(0)] public DataJSON theme_params; [IfFlag(0)] public DataJSON theme_params;
public string platform; public string platform;
@ -8660,6 +8663,9 @@ namespace TL.Methods
{ {
has_theme_params = 0x1, has_theme_params = 0x1,
from_switch_webview = 0x2, from_switch_webview = 0x2,
from_side_menu = 0x4,
has_url = 0x8,
has_start_param = 0x10,
} }
} }

View file

@ -6,7 +6,7 @@ namespace TL
{ {
public static class Layer public static class Layer
{ {
public const int Version = 162; // fetched 06/09/2023 16:21:22 public const int Version = 163; // fetched 18/09/2023 17:16:36
internal const int SecretChats = 144; internal const int SecretChats = 144;
internal const int MTProto2 = 73; internal const int MTProto2 = 73;
internal const uint VectorCtor = 0x1CB5C415; internal const uint VectorCtor = 0x1CB5C415;
@ -271,6 +271,7 @@ namespace TL
[0x07761198] = typeof(UpdateChatParticipants), [0x07761198] = typeof(UpdateChatParticipants),
[0xE5BDF8DE] = typeof(UpdateUserStatus), [0xE5BDF8DE] = typeof(UpdateUserStatus),
[0xA7848924] = typeof(UpdateUserName), [0xA7848924] = typeof(UpdateUserName),
[0x8951ABEF] = typeof(UpdateNewAuthorization),
[0x12BCBD9A] = typeof(UpdateNewEncryptedMessage), [0x12BCBD9A] = typeof(UpdateNewEncryptedMessage),
[0x1710F156] = typeof(UpdateEncryptedChatTyping), [0x1710F156] = typeof(UpdateEncryptedChatTyping),
[0xB4A2E88D] = typeof(UpdateEncryption), [0xB4A2E88D] = typeof(UpdateEncryption),
@ -285,7 +286,7 @@ namespace TL
[0x9C974FDF] = typeof(UpdateReadHistoryInbox), [0x9C974FDF] = typeof(UpdateReadHistoryInbox),
[0x2F2F21BF] = typeof(UpdateReadHistoryOutbox), [0x2F2F21BF] = typeof(UpdateReadHistoryOutbox),
[0x7F891213] = typeof(UpdateWebPage), [0x7F891213] = typeof(UpdateWebPage),
[0x68C13933] = typeof(UpdateReadMessagesContents), [0xF8227181] = typeof(UpdateReadMessagesContents),
[0x108D941F] = typeof(UpdateChannelTooLong), [0x108D941F] = typeof(UpdateChannelTooLong),
[0x635B4C09] = typeof(UpdateChannel), [0x635B4C09] = typeof(UpdateChannel),
[0x62BA04D9] = typeof(UpdateNewChannelMessage), [0x62BA04D9] = typeof(UpdateNewChannelMessage),
@ -1011,7 +1012,7 @@ namespace TL
[0x2DBF3432] = typeof(Phone_GroupCallStreamRtmpUrl), [0x2DBF3432] = typeof(Phone_GroupCallStreamRtmpUrl),
[0x4576F3F0] = typeof(AttachMenuBotIconColor), [0x4576F3F0] = typeof(AttachMenuBotIconColor),
[0xB2A7386B] = typeof(AttachMenuBotIcon), [0xB2A7386B] = typeof(AttachMenuBotIcon),
[0xC8AA2CD2] = typeof(AttachMenuBot), [0xD90D8DFE] = typeof(AttachMenuBot),
[0xF1D88A5C] = null,//AttachMenuBotsNotModified [0xF1D88A5C] = null,//AttachMenuBotsNotModified
[0x3C4301C0] = typeof(AttachMenuBots), [0x3C4301C0] = typeof(AttachMenuBots),
[0x93BF667F] = typeof(AttachMenuBotsBot), [0x93BF667F] = typeof(AttachMenuBotsBot),

View file

@ -13,7 +13,7 @@
<PackageId>WTelegramClient</PackageId> <PackageId>WTelegramClient</PackageId>
<Version>0.0.0</Version> <Version>0.0.0</Version>
<Authors>Wizou</Authors> <Authors>Wizou</Authors>
<Description>Telegram Client API (MTProto) library written 100% in C# and .NET Standard | Latest API layer: 162&#10;&#10;Release Notes:&#10;$(ReleaseNotes.Replace("|", "%0D%0A").Replace(" - ","%0D%0A- ").Replace(" ", "%0D%0A%0D%0A"))</Description> <Description>Telegram Client API (MTProto) library written 100% in C# and .NET Standard | Latest API layer: 163&#10;&#10;Release Notes:&#10;$(ReleaseNotes.Replace("|", "%0D%0A").Replace(" - ","%0D%0A- ").Replace(" ", "%0D%0A%0D%0A"))</Description>
<Copyright>Copyright © Olivier Marcoux 2021-2023</Copyright> <Copyright>Copyright © Olivier Marcoux 2021-2023</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression> <PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/wiz0u/WTelegramClient</PackageProjectUrl> <PackageProjectUrl>https://github.com/wiz0u/WTelegramClient</PackageProjectUrl>