ptgc
MTProto client for Dart

FAQ

Is this against Telegram’s Terms of Service?

Automating a user account (as opposed to a bot) carries real risk of being flagged or banned if used aggressively — mass messaging, joining many chats in a short window, or scraping at high volume are the usual triggers. Use conservative rate limits, and don’t do anything with a user account that Telegram’s bot API would let you do with a bot instead.

Why does ptgc exist alongside ptgb?

ptgb talks to Telegram as a bot — great coverage of the Bot API, but bots fundamentally can’t do everything a user account can. Bots can’t message users who haven’t started a conversation with them, can’t join a chat by invite link on their own, and — the main reason ptgc exists — often can’t manage membership (ban/kick/restrict) with the same flexibility a logged-in account has. If a bot can do what you need, prefer ptgb; it’s the lower-risk, officially-sanctioned path.

Do I need API_ID/API_HASH for every account, or just once?

Once per application, not per account. The same api_id/api_hash pair (from my.telegram.org/apps) can authenticate any number of different phone numbers — each just gets its own session file.

What happens if I lose my session file?

You’ll need to go through auth.sendCode/signIn (and checkPassword, if you have 2FA) again. The account itself isn’t affected — sessions are just a way to skip re-authenticating, not the account’s only credential.

Can I run more than one TelegramClient at once?

Yes — each is independent as long as they use different SessionStores (different files, or separate MemorySessionStore instances). Running two TelegramClients against the same session concurrently isn’t supported.

Why did Members.list/Members.get return nothing for a user I can see in the app?

Most likely ptgc hasn’t cached that chat’s access hash yet this session — see Peer Cache. Call Chats.listDialogs() or Chats.resolveUsername() once first so the chat (and its members) are resolvable.

Why does restrict() throw a StateError for a chat I know is a group?

restrict() only works on supergroups/channels — basic groups (capped at 200 members, created with Chats.createGroup) don’t support partial restrictions, only full ban()/kick(). If you expect fine-grained restrictions, create the chat with Chats.createSupergroup instead of createGroup.

Where do I report a bug or ask a question?

GitHub Issues — see Contributing.