diff --git a/EXAMPLES.md b/EXAMPLES.md index 841f5c5..eb91e4b 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -298,7 +298,9 @@ for (int offset_id = 0; ;) offset_id = messages.Messages[^1].ID; } ``` -*Note: If you want to stop at a specific msg ID, use Messages_GetHistory `min_id` argument. For example, `min_id: dialog.read_inbox_max_id`* +Notes: +- To stop at a specific msg ID, use Messages_GetHistory `min_id` argument. For example, `min_id: dialog.read_inbox_max_id` +- To mark the message history as read, use: `await client.ReadHistory(peer);` ### Monitor all Telegram events happening for the user diff --git a/FAQ.md b/FAQ.md index a22152a..5e3dea8 100644 --- a/FAQ.md +++ b/FAQ.md @@ -163,6 +163,7 @@ However, note that those Channel-compatible methods will require an `InputChanne That object must be created with both fields `channel_id` and `access_hash` correctly filled. You can read more about this in [FAQ #4](#access-hash). + #### 10. `chats.chats[id]` fails. My chats list is empty or does not contain the chat id. There can be several reasons why `chats.chats` doesn't contain the chat you expect: @@ -259,6 +260,38 @@ If those missing messages are never obtained during the session, incoming messag - As recommended, new encryption keys are negotiated every 100 sent/received messages or after one week. If remote client doesn't complete this negotiation before reaching 200 messages, the Secret Chat is aborted. + +#### 15. The example codes don't compile on my machine + +The snippets of example codes found in the [ReadMe](README.md) or [Examples](EXAMPLES.md) pages were written for .NET 5 / C# 9 minimum. +If you're having compiler problem on code constructs such as `using`, `foreach`, `[^1]` or about "Deconstruct", +that typically means you're still using an obsolete version of .NET (Framework 4.x or Core) + +Here are the recommended actions to fix your problem: +- Create a new project for .NET 6+ (in Visual Studio 2019 or more recent): + - Select File > New > Project + - Search for "C# Console" + - Select the **Console App**, but NOT Console App (.NET Framework) ! + - On the framework selection page, choose .NET 6.0 or more recent + - Now you can start developing for WTelegramClient 🙂 +- If you don't want to target a recent version of .NET, you can upgrade your existing project to use the latest version of the C# language: + - Close Visual Studio + - Edit your *.csproj file **with Notepad** + - Within the first ``, add the following line: + `latest` + - Save, close Notepad and reopen your project in Visual Studio + - If you still have issues on some `foreach` constructs, add this class somewhere in your project: + ```csharp + static class Extensions + { + public static void Deconstruct(this KeyValuePair tuple, out T1 key, out T2 value) + { + key = tuple.Key; + value = tuple.Value; + } + } + ``` + ## Troubleshooting guide diff --git a/README.md b/README.md index e25529a..e8a0773 100644 --- a/README.md +++ b/README.md @@ -151,7 +151,8 @@ await client.SendMessageAsync(target, "Hello, World"); ``` ➡️ You can find lots of useful code snippets in [EXAMPLES.md](https://github.com/wiz0u/WTelegramClient/blob/master/EXAMPLES.md) -and in the [Examples subdirectory](https://github.com/wiz0u/WTelegramClient/tree/master/Examples). +and in the [Examples subdirectory](https://github.com/wiz0u/WTelegramClient/tree/master/Examples). +➡️ Check [the FAQ](https://github.com/wiz0u/WTelegramClient/blob/master/FAQ.md#compile) if example codes doesn't compile correctly on your machine, or other troubleshooting. # Terminology in Telegram Client API diff --git a/src/Client.Helpers.cs b/src/Client.Helpers.cs index db97629..980d9f1 100644 --- a/src/Client.Helpers.cs +++ b/src/Client.Helpers.cs @@ -657,6 +657,15 @@ namespace WTelegram public Task DeleteMessages(InputPeer peer, params int[] id) => peer is InputPeerChannel channel ? this.Channels_DeleteMessages(channel, id) : this.Messages_DeleteMessages(id); + + /// Marks message history as read. See
and
Possible codes: 400 (details)
+ /// Target user, channel or group + /// If a positive value is passed, only messages with identifiers less or equal than the given one will be marked read + public async Task ReadHistory(InputPeer peer, int max_id = default) => peer switch + { + InputPeerChannel channel => await this.Channels_ReadHistory(channel, max_id), + _ => (await this.Messages_ReadHistory(peer, max_id)) != null + }; #endregion } } diff --git a/src/TL.Schema.cs b/src/TL.Schema.cs index cc61da5..d012742 100644 --- a/src/TL.Schema.cs +++ b/src/TL.Schema.cs @@ -6560,7 +6560,7 @@ namespace TL /// Message entity representing a spoiler See [TLDef(0x32CA960F)] public class MessageEntitySpoiler : MessageEntity { } - /// Represents a custom emoji See + /// Represents a custom emoji.
Note that this entity must wrap exactly one regular emoji (the one contained in .alt) in the related text, otherwise the server will ignore it. See
[TLDef(0xC8CF05F8, inheritBefore = true)] public class MessageEntityCustomEmoji : MessageEntity { diff --git a/src/TL.SchemaFuncs.cs b/src/TL.SchemaFuncs.cs index af4a1a7..5fca2b0 100644 --- a/src/TL.SchemaFuncs.cs +++ b/src/TL.SchemaFuncs.cs @@ -3056,7 +3056,7 @@ namespace TL /// React to message See Possible codes: 400,403 (details) /// Whether a bigger and longer reaction should be shown - /// Add this reaction to the recent reactions list + /// Add this reaction to the recent reactions list ». /// Peer /// Message ID to react to /// Reaction (a UTF8 emoji)