Skip to content
Nitan Alexandru Marcel edited this page Aug 5, 2020 · 6 revisions

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))