mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-21 17:06:36 +03:00
Page:
Privacy settings
Pages
Admin Permissions
Deleted, Limitted or Deactivated Accounts
Docs Overhaul
Forwarding messages
Home
Increasing View Count
Joining a chat or channel
MTProto vs HTTP Bot API
Privacy settings
Projects using Telethon
Recent actions
Retrieving all chat members
Scheduling Functions
Searching messages
Sending more than just messages
Sending spoilers and custom emoji
Session Storages
Special links
Stories
Telegram API in Other Languages
Video avatars ("profile photos")
_Footer.py
6
Privacy settings
Nitan Alexandru Marcel edited this page 2020-08-05 11:54:42 -04:00
Table of Contents
There are 8 "types" (keys) of privacy settings, which are separate from each other:
- Status Timestamp - Whether users can see your last active timestamp (also affects whether you can see the other person's)
- Chat Invite - Whether you can be invited to chats
- Phone Call - Whether you will accept phone calls
- Phone P2P - Whether you allow P2P communication during VoIP calls
- Forwards - Whether messages forwarded from you will be anonymous
- Profile Photo - Whether people will be able to see your profile picture
- Phone Number - Whether people will be able to see your phone number
- Added By Phone - Whether people can add you to their contact list by your phone number
For each of these, you have 8 modes (rules):
- All telegram users
- Your contacts only
- Only selected users
- Everyone from a certain chat
- Everyone except your contacts
- Everyone except selected users
- Everyone except users from a certain chat
- Nobody
To set any of these, you need a key to work on and a list of values, which will be a global rule, such as InputPrivacyValueAllowAll
and exceptions, such as allowing or disallowing specific users.
Last seen example
To allow no one except "@best_friend" to see your last seen, you would use this:
from telethon import TelegramClient
from telethon.tl.functions.account import SetPrivacyRequest
from telethon.tl.types import InputPrivacyKeyStatusTimestamp, InputPrivacyValueAllowUsers,\
InputPrivacyValueDisallowAll
client = TelegramClient(session, api_id, api_hash).start()
bff = client.get_input_entity('@best_friend')
key = InputPrivacyKeyStatusTimestamp() # working with last seen privacy
rule = InputPrivacyValueDisallowAll() # main rule is to disallow everyone
exceptions = InputPrivacyValueAllowUsers([bff]) # more people can be allowed
values = [rule, exceptions]
client(SetPrivacyRequest(key, values))