diff --git a/EXAMPLES.md b/EXAMPLES.md index e3b29c3..6c3d1a3 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -276,8 +276,13 @@ for (int offset_id = 0; ;) var messages = await client.Messages_GetHistory(peer, offset_id); if (messages.Messages.Length == 0) break; foreach (var msgBase in messages.Messages) + { + var from = messages.UserOrChat(msgBase.From ?? msgBase.Peer); // from can be User/Chat/Channel if (msgBase is Message msg) - Console.WriteLine(msg.message); + Console.WriteLine($"{from}> {msg.message} {msg.media}"); + else if (msgBase is MessageService ms) + Console.WriteLine($"{from} [{ms.action.GetType().Name[13..]}]"); + } offset_id = messages.Messages[^1].ID; } ``` diff --git a/FAQ.md b/FAQ.md index 2093458..f9b762c 100644 --- a/FAQ.md +++ b/FAQ.md @@ -247,11 +247,11 @@ The following choices were made while implementing Secret Chats in WTelegramClie - It may not support remote antique Telegram clients *(prior to 2018, still using insecure MTProto 1.0)* - It doesn't store outgoing messages *(so if remote client was offline for a week and ask us to resend old messages, we will send void data)* - It doesn't store incoming messages on disk *(it's up to you if you want to store them)* -- If you pass `DecryptMessage` parameter `fillGaps: true` *(the default)*, incoming messages are ensured to be delivered to you in correct order. -If for some (weird) reason, we received them in incorrect order, messages are kept in memory until the requested missing messages are obtained. +- If you pass `DecryptMessage` parameter `fillGaps: true` *(default)*, incoming messages are ensured to be delivered to you in correct order. +If for some reason, we received them in incorrect order, messages are kept in memory until the requested missing messages are obtained. If those missing messages are never obtained during the session, incoming messages might get stuck and lost. -- SecretChats file data is only valid for the current user, so make sure to select the right file *(or a new file name)* if you change logged-in user. -- If you want to accept Secret Chats request only from specific user, you must check it in OnUpdate before: +- SecretChats file data is only valid for the current user, so make sure to pick the right file *(or a new file name)* if you change logged-in user. +- If you want to accept incoming Secret Chats request only from specific user, you must check it in OnUpdate before: `await Secrets.HandleUpdate(ue, ue.chat is EncryptedChatRequested ecr && ecr.admin_id == EXPECTED_USER_ID);` - 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. diff --git a/README.md b/README.md index 5b4fa8a..b4ad071 100644 --- a/README.md +++ b/README.md @@ -160,7 +160,7 @@ In the API, Telegram uses some terms/classnames that can be confusing as they di - `Channel` : A (large or public) chat group *(sometimes called [supergroup](https://corefork.telegram.org/api/channel#supergroups))* or a [broadcast channel](https://corefork.telegram.org/api/channel#channels) (the `broadcast` flag differentiate those) - `Chat` : A private [basic chat group](https://corefork.telegram.org/api/channel#basic-groups) with less than 200 members -(it may be migrated to a supergroup `Channel` with a new ID when it gets bigger or public, in which case the old `Chat` will still exist but be `deactivated`) +(it may be migrated to a supergroup `Channel` with a new ID when it gets bigger or public, in which case the old `Chat` will still exist but will be `deactivated`) **⚠️ Most chat groups you see are really of type `Channel`, not `Chat`!** - chats : In plural or general meaning, it means either `Chat` or `Channel` - `Peer` : Either a `Chat`, a `Channel` or a `User` diff --git a/src/Client.cs b/src/Client.cs index 4d4f23a..30ccbce 100644 --- a/src/Client.cs +++ b/src/Client.cs @@ -1101,9 +1101,9 @@ namespace WTelegram } } } - catch + catch (Exception ex) when (ex is not RpcException { Message: "FLOOD_WAIT_X" }) { - await this.Auth_CancelCode(phone_number, sentCode.phone_code_hash); + try { await this.Auth_CancelCode(phone_number, sentCode.phone_code_hash); } catch { } throw; } if (authorization is Auth_AuthorizationSignUpRequired signUpRequired)