Login failed: CancelCode but don't make things worse

This commit is contained in:
Wizou 2022-10-10 21:55:56 +02:00
parent 2cee5b8e6e
commit fdc05e5514
4 changed files with 13 additions and 8 deletions

View file

@ -276,8 +276,13 @@ for (int offset_id = 0; ;)
var messages = await client.Messages_GetHistory(peer, offset_id); var messages = await client.Messages_GetHistory(peer, offset_id);
if (messages.Messages.Length == 0) break; if (messages.Messages.Length == 0) break;
foreach (var msgBase in messages.Messages) 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) 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; offset_id = messages.Messages[^1].ID;
} }
``` ```

8
FAQ.md
View file

@ -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 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 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)* - 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 you pass `DecryptMessage` parameter `fillGaps: true` *(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 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. 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. - 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 Secret Chats request only from specific user, you must check it in OnUpdate before: - 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);` `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. - 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. If remote client doesn't complete this negotiation before reaching 200 messages, the Secret Chat is aborted.

View file

@ -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))* - `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) 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 - `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`!** **⚠️ Most chat groups you see are really of type `Channel`, not `Chat`!**
- chats : In plural or general meaning, it means either `Chat` or `Channel` - chats : In plural or general meaning, it means either `Chat` or `Channel`
- `Peer` : Either a `Chat`, a `Channel` or a `User` - `Peer` : Either a `Chat`, a `Channel` or a `User`

View file

@ -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; throw;
} }
if (authorization is Auth_AuthorizationSignUpRequired signUpRequired) if (authorization is Auth_AuthorizationSignUpRequired signUpRequired)