diff --git a/EXAMPLES.md b/EXAMPLES.md index 5f0bc5f..bbea892 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -59,7 +59,7 @@ var sent2 = await client.SendMessageAsync(InputPeer.Self, text2, entities: entit // if you need to convert a sent/received Message to Markdown: (easier to store) text2 = client.EntitiesToMarkdown(sent2.message, sent2.entities); ``` -See [MarkdownV2 formatting style](https://core.telegram.org/bots/api/#markdownv2-style) and [HTML formatting style](https://core.telegram.org/bots/api/#html-style) for details. +See [HTML formatting style](https://core.telegram.org/bots/api/#html-style) and [MarkdownV2 formatting style](https://core.telegram.org/bots/api/#markdownv2-style) for details. *Note: For the `tg://user?id=` notation to work, that user's access hash must have been collected first ([see below](#collect-access-hash))* @@ -112,7 +112,7 @@ await Task.Delay(5000); ``` -### List all chats (groups/channels) the user is in and send a message to one +### List all chats (groups/channels NOT users) that we joined and send a message to one ```csharp var chats = await client.Messages_GetAllChats(); foreach (var (id, chat) in chats.chats) @@ -129,6 +129,21 @@ Notes: but the old `Chat` will be marked with flag [deactivated] and should not be used anymore. See [Terminology in ReadMe](README.md#terminology). - You can find a longer version of this method call in [Examples/Program_GetAllChats.cs](Examples/Program_GetAllChats.cs) + +### List all dialogs (chats/groups/channels/user chat) we are currently in +```csharp +var dialogs = await client.Messages_GetAllDialogs(); +foreach (var dialog in dialogs.dialogs) + switch (dialogs.UserOrChat(dialog)) + { + case User user when user.IsActive: Console.WriteLine("User " + user); break; + case ChatBase chat when chat.IsActive: Console.WriteLine(chat); break; + } +``` + +*Note: the lists returned by Messages_GetAllDialogs contains the `access_hash` for those chats and users.* +See also the `Main` method in [Examples/Program_ListenUpdates.cs](Examples/Program_ListenUpdates.cs). + ### Schedule a message to be sent to a chat ```csharp @@ -171,21 +186,6 @@ await client.SendAlbumAsync(InputPeer.Self, inputMedias, "My first album"); ``` *Note: Don't mix Photos and file Documents in your album, it doesn't work well* - -### List all dialogs (chats/groups/channels/user chat) the user is in -```csharp -var dialogs = await client.Messages_GetAllDialogs(); -foreach (var dialog in dialogs.dialogs) - switch (dialogs.UserOrChat(dialog)) - { - case User user when user.IsActive: Console.WriteLine("User " + user); break; - case ChatBase chat when chat.IsActive: Console.WriteLine(chat); break; - } -``` - -*Note: the lists returned by Messages_GetAllDialogs contains the `access_hash` for those chats and users.* -See also the `Main` method in [Examples/Program_ListenUpdates.cs](Examples/Program_ListenUpdates.cs). - ### Get all members from a chat For a basic Chat: *(see Terminology in [ReadMe](README.md#terminology))* diff --git a/Examples/Program_ListenUpdates.cs b/Examples/Program_ListenUpdates.cs index 9060e7b..fd25eb6 100644 --- a/Examples/Program_ListenUpdates.cs +++ b/Examples/Program_ListenUpdates.cs @@ -42,6 +42,7 @@ namespace WTelegramClientTest { case UpdateNewMessage unm: await DisplayMessage(unm.message); break; case UpdateEditMessage uem: await DisplayMessage(uem.message, true); break; + // Note: UpdateNewChannelMessage and UpdateEditChannelMessage are also handled by above cases case UpdateDeleteChannelMessages udcm: Console.WriteLine($"{udcm.messages.Length} message(s) deleted in {Chat(udcm.channel_id)}"); break; case UpdateDeleteMessages udm: Console.WriteLine($"{udm.messages.Length} message(s) deleted"); break; case UpdateUserTyping uut: Console.WriteLine($"{User(uut.user_id)} is {uut.action}"); break; diff --git a/src/Client.cs b/src/Client.cs index d766895..a1be6f9 100644 --- a/src/Client.cs +++ b/src/Client.cs @@ -690,8 +690,8 @@ namespace WTelegram return tcpClient; } - /// Establish connection to Telegram servers - /// Config callback is queried for: server_address + /// Establish connection to Telegram servers without negociating a user session + /// Usually you shouldn't need to call this method: Use LoginUserIfNeeded instead.
Config callback is queried for: server_address
/// Most methods of this class are async (Task), so please use public async Task ConnectAsync() { @@ -893,7 +893,7 @@ namespace WTelegram } /// Login as a user (if not already logged-in). - ///
(this method calls ConnectAsync if necessary)
+ ///
(this method calls ConnectAsync if necessary) /// Config callback is queried for: phone_number, verification_code
and eventually first_name, last_name (signup required), password (2FA auth), user_id (alt validation)
/// (optional) Preference for verification_code sending /// Proceed to logout and login if active user session cannot be resumed successfully