doc updates

This commit is contained in:
Wizou 2022-11-26 15:16:04 +01:00
parent a8d6656c05
commit bd629e7384
2 changed files with 48 additions and 45 deletions

36
FAQ.md
View file

@ -1,11 +1,13 @@
## FAQ
# FAQ
Before asking questions, make sure to **[read through the ReadMe first](README.md)**,
take a look at the [example programs](EXAMPLES.md) or [StackOverflow questions](https://stackoverflow.com/questions/tagged/wtelegramclient),
and refer to the [API method list](https://corefork.telegram.org/methods) for the full range of Telegram services available in this library.
➡️ Use Ctrl-F to search this page for the information you seek
<a name="remove-logs"></a>
#### 1. How to remove the Console logs?
## 1. How to remove the Console logs?
Writing the library logs to the Console is the default behavior of the `WTelegram.Helpers.Log` delegate.
You can change the delegate with the `+=` operator to **also** write them somewhere else, or with the `=` operator to prevent them from being printed to screen and instead write them somewhere (file, logger, ...).
@ -14,7 +16,7 @@ In any case, it is not recommended to totally ignore those logs because you woul
Read the [example about logging settings](EXAMPLES.md#logging) for how to write logs to a file.
<a name="multiple-users"></a>
#### 2. How to handle multiple user accounts
## 2. How to handle multiple user accounts
The WTelegram.session file contains the authentication keys negociated for the current user.
@ -32,7 +34,7 @@ Your api_id/api_hash represents your application, and shouldn't change with each
<a name="GUI"></a>
<a name="ASPNET"></a>
#### 3. How to use the library in a WinForms, WPF or ASP.NET application
## 3. How to use the library in a WinForms, WPF or ASP.NET application
The library should work without a problem in such applications.
The difficulty might be in your Config callback when the user must enter the verification code or password, as you can't use `Console.ReadLine` here.
@ -48,7 +50,7 @@ calling `client.Login(...)` as the user provides the requested configuration ele
You can download such full example apps [for WinForms](Examples/WinForms_app.zip) and [for ASP.NET](Examples/ASPnet_webapp.zip)
<a name="access-hash"></a>
#### 4. How to use IDs? Where to get the access_hash? Why the error `CHANNEL_INVALID` or `USER_ID_INVALID`?
## 4. How to use IDs? Where to get the access_hash? Why the error `CHANNEL_INVALID` or `USER_ID_INVALID`?
Having only the ID is **not enough**: An `access_hash` is required by Telegram when dealing with a channel, user, photo, document, etc...
This serves as a proof that the logged-in user is entitled to access it (otherwise, anybody with the ID could access it)
@ -72,14 +74,14 @@ You can then retrieve it with `client.GetAccessHashFor<User/Channel/Photo/Docume
⚠️ *An `access_hash` obtained from a User/Channel structure with flag `min` may not be usable for most requests. See [Min constructors](https://core.telegram.org/api/min).*
<a name="dev-versions"></a>
#### 5. I need to test a feature that has been recently developed but seems not available in my program
## 5. I need to test a feature that has been recently developed but seems not available in my program
The developmental versions of the library are now available as **pre-release** on Nuget (with `-dev` in the version number)
So make sure you tick the checkbox "Include prerelease" in Nuget manager and/or navigate to the Versions list then select the highest `x.x.x-dev.x` version to install in your program.
<a name="wrong-server"></a>
#### 6. Telegram asks me to signup (firstname, lastname) even for an existing account
## 6. Telegram asks me to signup (firstname, lastname) even for an existing account
This happens when you connect to Telegram Test servers instead of Production servers.
On these separate test servers, all created accounts and chats are periodically deleted, so you shouldn't use them under normal circumstances.
@ -96,7 +98,7 @@ If you use the Github source project in an old .NET Framework 4.x or .NET Core x
To fix this, you should also switch to using the [WTelegramClient Nuget package](https://www.nuget.org/packages/WTelegramClient) as it will install the required dependencies for it to work.
<a name="abuse"></a>
#### 7. I get errors FLOOD_WAIT_X or PEER_FLOOD, PHONE_NUMBER_BANNED, USER_DEACTIVATED_BAN. I can't import phone numbers.
## 7. I get errors FLOOD_WAIT_X or PEER_FLOOD, PHONE_NUMBER_BANNED, USER_DEACTIVATED_BAN. I can't import phone numbers.
You can get these kind of problems if you abuse Telegram [Terms of Service](https://telegram.org/tos), or the [API Terms of Service](https://core.telegram.org/api/terms), or make excessive requests.
@ -111,7 +113,7 @@ If you think your phone number was banned from Telegram for a wrong reason, you
In any case, WTelegramClient is not responsible for the bad usage of the library and we are not affiliated to Telegram teams, so there is nothing we can do.
<a name="prevent-ban"></a>
#### 8. How to NOT get banned from Telegram?
## 8. How to NOT get banned from Telegram?
**Do not share publicly your app's ID and hash!** They cannot be regenerated and are bound to your Telegram account.
@ -147,7 +149,7 @@ We don't support such use of the library, and will not help people asking for su
11. If your client displays Telegram channels to your users, you have to support and display [official sponsored messages](https://core.telegram.org/api/sponsored-messages).
<a name="chat-id"></a>
#### 9. Why the error `CHAT_ID_INVALID`?
## 9. Why the error `CHAT_ID_INVALID`?
Most chat groups you see are likely of type `Channel`, not `Chat`.
This difference is important to understand. Please [read about the Terminology in ReadMe](README.md#terminology).
@ -162,7 +164,7 @@ That object must be created with both fields `channel_id` and `access_hash` corr
<a name="chats-chats"></a>
<a name="chat-not-found"></a>
#### 10. `chats.chats[id]` fails. My chats list is empty or does not contain the chat I'm looking for.
## 10. `chats.chats[id]` fails. My chats list is empty or does not contain the chat I'm looking for.
There can be several reasons why `chats.chats` doesn't contain the chat you expect:
- You're searching for a user instead of a chat ID.
@ -182,7 +184,7 @@ To help determine if `chats.chats` is empty or does not contain a certain chat,
or simply use a debugger: Place a breakpoint after the `Messages_GetAllChats` call, run the program up to there, and use a Watch pane to display the content of the chats.chats dictionary.
<a name="shutdown"></a>
#### 11. I get "Connection shut down" errors in my logs
## 11. I get "Connection shut down" errors in my logs
There are various reasons why you may get this error. Here are the explanation and how to solve it:
@ -207,7 +209,7 @@ In this case, you can use the `PingInterval` property to increase the delay betw
5) If you're using an [MTProxy](EXAMPLES.md#proxy), some of them are known to be quite unstable. You may want to try switching to another MTProxy that is more stable.
<a name="TLSharp"></a>
#### 12. How to migrate from TLSharp? How to sign-in/sign-up/register account properly?
## 12. How to migrate from TLSharp? How to sign-in/sign-up/register account properly?
First, make sure you read the [ReadMe documentation](README.md) completely, it contains essential information and a quick tutorial to easily understand how to correctly use the library.
@ -234,7 +236,7 @@ In particular, it will detect and handle automatically and properly the various
Contrary to TLSharp, WTelegramClient supports MTProto v2.0 (more secured), transport obfuscation, protocol security checks, MTProto [Proxy](EXAMPLES.md#proxy), real-time updates, multiple DC connections, API documentation in Intellisense...
<a name="heroku"></a><a name="vps"></a><a name="host"></a>
#### 13. How to host my userbot online?
## 13. How to host my userbot online?
If you need your userbot to run 24/7, you would typically design your userbot as a Console program, compiled for Linux or Windows,
and hosted online on any [VPS Hosting](https://www.google.com/search?q=vps+hosting) (Virtual Private Server).
@ -244,7 +246,7 @@ There are many cheap VPS Hosting offers available, for example Heroku:
See [Examples/Program_Heroku.cs](Examples/Program_Heroku.cs) for such an implementation and the steps to host/deploy it.
<a name="secrets"></a>
#### 14. Secret Chats implementation details
## 14. Secret Chats implementation details
The following choices were made while implementing Secret Chats in WTelegramClient:
- It may not support remote antique Telegram clients *(prior to 2018, still using insecure MTProto 1.0)*
@ -260,7 +262,7 @@ If those missing messages are never obtained during the session, incoming messag
If remote client doesn't complete this negotiation before reaching 200 messages, the Secret Chat is aborted.
<a name="compile"></a>
#### 15. The example codes don't compile on my machine
## 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",
@ -294,7 +296,7 @@ Here are the recommended actions to fix your problem:
Also, remember to add a `using TL;` at the top of your files to have access to all the Telegram API methods.
<a name="troubleshoot"></a>
## Troubleshooting guide
# Troubleshooting guide
Here is a list of common issues and how to fix them so that your program work correctly:
1) Are you using the Nuget package or the library source code?