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.

From the official documentation:

Note that all API client libraries are strictly monitored to prevent abuse.
If you use the Telegram API for flooding, spamming, faking subscriber and view counters of channels, you will be banned forever.
Due to excessive abuse of the Telegram API, all accounts that sign up or log in using unofficial Telegram clients are automatically
put under observation
to avoid violations of the Terms of Service.

Here are some advices:

  • This client is unofficial, Telegram treats such clients suspiciously, especially fresh ones.
  • Use regular bots instead of userbots whenever possible.
  • If you still want to automate things with a user, use it passively (i.e. receive more than sending).
  • When using it with a user:
    • Do not use QR code login, this will result in permaban.
    • Do it with extreme care.
    • Do not use VoIP numbers.
    • Do not abuse, spam or use it for other suspicious activities.
    • Implement a rate limiting system.
  • Avoid repetitive polling or repetitive sequence of actions/requests: Save the initial results of your queries, and update those results when you're informed of a change through `Update` events.
  • If a phone number is brand new, it will be closely monitored by Telegram for abuse, and it can even already be considered a bad user due to bad behavior from the previous owner of that phone number (which may happens often with VoIP or other easy-to-buy-online numbers, so expect fast ban)
  • You may want to use your new phone number account with an official Telegram client and act like a normal user for some time (some weeks/months), before using it for automation with WTelegramClient.
  • When creating a new API ID/Hash, I recommend you use your own phone number with long history of normal Telegram usage, rather than a brand new phone number with short history.
  • In particular, DON'T create an API ID/Hash for every phone numbers you will control. One API ID/Hash represents your application, which can be used to control several user accounts.
  • If you actually do use the software to spam, scam, or other stuff annoying to everybody, GTFO and don't cry that you got banned using software. Some people don't seem to realize by themselves that what they plan to do with the library is actually negative for the community and are surprised that they got caught.
  • We don't support such use of the software, and will not help people asking for support if we suspect them of mass-user manipulation.
  • If your client displays Telegram channels to your users, you have to support and display official sponsored messages.

Broadcasting to Users

My bot is hitting limits, how do I avoid this?

When sending messages inside a particular chat, avoid sending more than one message per second. We may allow short bursts that go over this limit, but eventually you'll begin receiving 429 errors.

If you're sending bulk notifications to multiple users, the API will not allow more than 30 messages per second or so. Consider spreading out notifications over large intervals of 8—12 hours for best results.

Also note that your bot will not be able to send more than 20 messages per minute to the same group.

How can I message all of my bot's subscribers at once?

Unfortunately, at this moment we don't have methods for sending bulk messages, e.g. notifications. We may add something along these lines in the future.

In order to avoid hitting our limits when sending out mass notifications, consider spreading them over longer intervals, e.g. 8-12 hours. The API will not allow bulk notifications to more than ~30 users per second, if you go over that, you'll start getting 429 errors.